use steam_user::{SteamUser, SteamUserError};
use tracing::info;
#[tokio::main]
async fn main() -> Result<(), SteamUserError> {
tracing_subscriber::fmt::init();
let community = SteamUser::new(&["steamLoginSecure=76561198012345678||YOUR_ACCESS_TOKEN", "sessionid=YOUR_SESSION_ID"])?;
let (logged_in, family_view_restricted) = community.logged_in().await?;
info!("Logged in: {}", logged_in);
info!("Family view restricted: {}", family_view_restricted);
if !logged_in {
info!("Not logged in. Please provide valid cookies.");
return Ok(());
}
if let Some(steam_id) = community.steam_id() {
info!("Steam ID: {}", steam_id.steam_id64());
}
match community.get_notifications().await {
Ok(notifications) => {
info!("\n=== Notifications ===");
info!(" Trade offers: {}", notifications.trades);
info!(" Comments: {}", notifications.comments);
info!(" Items: {}", notifications.items);
info!(" Invites: {}", notifications.invites);
info!(" Gifts: {}", notifications.gifts);
info!(" Chat messages: {}", notifications.chat);
}
Err(e) => {
info!("Failed to get notifications: {}", e);
}
}
match community.get_friends_list().await {
Ok(friends) => {
info!("\n=== Friends ===");
info!("Total friends: {}", friends.len());
for (steam_id, relationship) in friends.iter().take(5) {
info!(" {} - Relationship: {}", steam_id.steam_id64(), relationship);
}
if friends.len() > 5 {
info!(" ... and {} more", friends.len() - 5);
}
}
Err(e) => {
info!("Failed to get friends list: {}", e);
}
}
match community.get_trade_url().await {
Ok(Some(url)) => {
info!("\n=== Trade URL ===");
info!(" URL: {}", url);
}
Ok(None) => {
info!("\n=== Trade URL ===");
info!(" No trade URL found.");
}
Err(e) => {
info!("Failed to get trade URL: {}", e);
}
}
Ok(())
}