Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using SteamKit2;
- using System.Net;
- using SteamKit2.Internal;
- using System.Threading;
- namespace gibtuxpls
- {
- class Program
- {
- static SteamClient client;
- static CallbackManager manager;
- static SteamUser user;
- static SteamFriends friends;
- static string username, password, authCode;
- static void Main( string[] args )
- {
- client = new SteamClient();
- manager = new CallbackManager( client );
- user = client.GetHandler<SteamUser>();
- friends = client.GetHandler<SteamFriends>();
- new Callback<SteamClient.DisconnectedCallback>( OnDisconnected, manager );
- new Callback<SteamClient.ConnectedCallback>( OnConnected, manager );
- new Callback<SteamUser.LoggedOffCallback>( OnLoggedOff, manager );
- new Callback<SteamUser.LoggedOnCallback>( OnLoggedOn, manager );
- Console.WriteLine( "Connecting to Steam..." );
- client.Connect( Dns.GetHostAddresses( "cm0.steampowered.com" ).FirstOrDefault() );
- while ( true )
- {
- manager.RunWaitCallbacks();
- }
- }
- static void OnDisconnected( SteamClient.DisconnectedCallback callback )
- {
- Console.WriteLine( "Disconnected from Steam, reconnecting in 5..." );
- Thread.Sleep( TimeSpan.FromSeconds( 5 ) );
- client.Connect( Dns.GetHostAddresses( "cm0.steampowered.com" ).FirstOrDefault() );
- }
- static void OnConnected( SteamClient.ConnectedCallback callback )
- {
- if ( callback.Result != EResult.OK )
- {
- Console.WriteLine( "Unable to connect to Steam: {0}", callback.Result );
- return;
- }
- Console.WriteLine( "Connected!" );
- if ( string.IsNullOrEmpty( username ) )
- {
- Console.Write( "Username: " );
- username = Console.ReadLine();
- }
- if ( string.IsNullOrEmpty( password ) )
- {
- Console.Write( "Password: " );
- password = Console.ReadLine();
- }
- user.LogOn( new SteamUser.LogOnDetails
- {
- Username = username,
- Password = password,
- AuthCode = authCode,
- OSOverride = EOSType.Linux24,
- } );
- }
- static void OnLoggedOff( SteamUser.LoggedOffCallback callback )
- {
- Console.WriteLine( "Logged off of Steam: {0}", callback.Result );
- }
- static void OnLoggedOn( SteamUser.LoggedOnCallback callback )
- {
- if ( callback.Result == EResult.AccountLogonDenied )
- {
- Console.WriteLine( "SteamGuard authcode required!" );
- Console.Write( "Auth code: " );
- 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( "Logged onto Steam, launching TF2..." );
- var clientMsg = new ClientMsgProtobuf<CMsgClientGamesPlayed>( EMsg.ClientGamesPlayedNoDataBlob );
- clientMsg.Body.games_played.Add( new CMsgClientGamesPlayed.GamePlayed
- {
- game_id = 440,
- } );
- client.Send( clientMsg );
- Console.WriteLine( "Done! Check your TF2 inventory now." );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement