using SteamKit2.GC;
using SteamKit2.GC.Dota.Internal;
using SteamKit2;
var user = "user";
var pass = "pass";
uint APPID = 570;
string authCode = null, twoFactorAuth = null;
var steamClient = new SteamClient();
var manager = new CallbackManager( steamClient );
var steamUser = steamClient.GetHandler<SteamUser>();
manager.Subscribe<SteamClient.ConnectedCallback>( OnConnected );
manager.Subscribe<SteamUser.LoggedOnCallback>( OnLoggedOn );
Console.WriteLine( "Connecting to Steam..." );
steamClient.Connect();
SteamGameCoordinator gameCoordinator;
while ( true )
manager.RunWaitCallbacks( TimeSpan.FromSeconds( 1 ) );
void OnConnected( SteamClient.ConnectedCallback callback )
{
Console.WriteLine( "Connected to Steam! Logging in '{0}'...", user );
steamUser.LogOn( new SteamUser.LogOnDetails
{
Username = user,
Password = pass
} );
}
void OnLoggedOn(SteamUser.LoggedOnCallback callback)
{
bool isSteamGuard = callback.Result == EResult.AccountLogonDenied;
bool is2FA = callback.Result == EResult.AccountLoginDeniedNeedTwoFactor;
gameCoordinator = steamClient.GetHandler<SteamGameCoordinator>();
if (isSteamGuard || is2FA)
{
Console.WriteLine("This account is SteamGuard protected!");
if (is2FA)
{
Console.Write("Please enter your 2 factor auth code from your authenticator app: ");
twoFactorAuth = Console.ReadLine();
}
else
{
Console.Write("Please enter the auth code sent to the email at {0}: ", callback.EmailDomain);
authCode = Console.ReadLine();
}
return;
}
if (callback.Result != EResult.OK)
{
Console.WriteLine("Unable to logon to Steam: {0} / {1}", callback.Result, callback.ExtendedResult);
return;
}
Console.WriteLine("Successfully logged on!");
var r = new ClientGCMsgProtobuf<CMsgInviteToParty>((uint)EGCBaseMsg.k_EMsgGCInviteToParty);
r.Body.steam_id = 76561197960287930;
gameCoordinator.Send( r, APPID );
}