A Rust library that provides a wrapper around the steam-vent crate for logging in to Steam and operating on the Steam Group Chats.
Actually all we need just to post !sub requests on our Steam Group Chat ;)
Here's a basic example of how to use this library to login to Steam and send messages:
use std::{env, error::Error};
use SC_Sub_Poster::{LogOn, ChatRoomClient};
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
// Initialize logging
tracing_subscriber::fmt::init();
// Create a client using credentials from environment variables
let account = env::var("STEAM_ACCOUNT").expect("STEAM_ACCOUNT not set");
let password = env::var("STEAM_PASSWORD").expect("STEAM_PASSWORD not set");
// Login to Steam
let logon = LogOn::new(&account, &password).await?;
println!("✓ Login successful! Steam ID: {}", logon.steam_id().steam3());
let snapshot = logon.session_snapshot();
println!("Session cell id: {}", snapshot.cell_id);
// Create chat room client
let chat_client = ChatRoomClient::new(logon.connection().clone());
// Get your chat rooms
let chat_rooms = chat_client.groups().get_my_chat_rooms().await?;
println!("Found {} chat rooms", chat_rooms.len());
// Send a message to a specific group chat
let group_id: u64 = 6887767; // Replace with your group ID
let chat_id: u64 = 22190790; // Replace with your chat ID
let message = "Hello from Rust!";
let response = chat_client
.messaging()
.send_group_message(group_id, chat_id, message, true)
.await?;
println!("✓ Message sent successfully!");
println!("Modified message: {}", response.modified_message);
Ok(())
}Set these environment variables before running:
export STEAM_ACCOUNT="your_steam_username"
export STEAM_PASSWORD="your_steam_password"
export CHAT_GROUP_ID="your_group_id" # Optional
export CHAT_ID="your_chat_id" # Optional- Message Preprocessing: Automatically processes BBCode formatting and mentions
- Mention Support: Handle
@all,@here, and[U:1:xxxxx]SteamID mentions with serde-safe wrappers - Real-time Listening: Listen for incoming friend and group messages with error-aware callbacks
- Enhanced Messages: Get detailed information about processed messages, including immutable session snapshots
- Tracing Spans: Built-in
tracinginstrumentation for logon, chat dispatch and preprocessing
For more advanced usage, see the examples/chat_demo.rs file.
LogOn::newandLogOn::new_anonymousreturn a boxedLogonErrorthat can be downcast for retry hints (ErrorInventoryEntry).- Notification loops expose
listen_for_*_messages_withhelpers that bubble transport failures rather than silently retrying forever.
This library depends on:
steam-vent- Steam network interactiontokio- Async runtimetracing- Loggingserde- Serialization
LGPL-3.0-only