Advertisement
Guest User

tux

a guest
Feb 15th, 2013
660
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.79 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using SteamKit2;
  6. using System.Net;
  7. using SteamKit2.Internal;
  8. using System.Threading;
  9.  
  10. namespace gibtuxpls
  11. {
  12. class Program
  13. {
  14. static SteamClient client;
  15.  
  16. static CallbackManager manager;
  17.  
  18. static SteamUser user;
  19. static SteamFriends friends;
  20.  
  21. static string username, password, authCode;
  22.  
  23.  
  24. static void Main( string[] args )
  25. {
  26. client = new SteamClient();
  27.  
  28. manager = new CallbackManager( client );
  29.  
  30. user = client.GetHandler<SteamUser>();
  31. friends = client.GetHandler<SteamFriends>();
  32.  
  33. new Callback<SteamClient.DisconnectedCallback>( OnDisconnected, manager );
  34. new Callback<SteamClient.ConnectedCallback>( OnConnected, manager );
  35.  
  36. new Callback<SteamUser.LoggedOffCallback>( OnLoggedOff, manager );
  37. new Callback<SteamUser.LoggedOnCallback>( OnLoggedOn, manager );
  38.  
  39. Console.WriteLine( "Connecting to Steam..." );
  40. client.Connect( Dns.GetHostAddresses( "cm0.steampowered.com" ).FirstOrDefault() );
  41.  
  42. while ( true )
  43. {
  44. manager.RunWaitCallbacks();
  45. }
  46. }
  47.  
  48.  
  49. static void OnDisconnected( SteamClient.DisconnectedCallback callback )
  50. {
  51. Console.WriteLine( "Disconnected from Steam, reconnecting in 5..." );
  52.  
  53. Thread.Sleep( TimeSpan.FromSeconds( 5 ) );
  54.  
  55. client.Connect( Dns.GetHostAddresses( "cm0.steampowered.com" ).FirstOrDefault() );
  56. }
  57.  
  58. static void OnConnected( SteamClient.ConnectedCallback callback )
  59. {
  60. if ( callback.Result != EResult.OK )
  61. {
  62. Console.WriteLine( "Unable to connect to Steam: {0}", callback.Result );
  63. return;
  64. }
  65.  
  66. Console.WriteLine( "Connected!" );
  67.  
  68. if ( string.IsNullOrEmpty( username ) )
  69. {
  70. Console.Write( "Username: " );
  71. username = Console.ReadLine();
  72. }
  73.  
  74. if ( string.IsNullOrEmpty( password ) )
  75. {
  76. Console.Write( "Password: " );
  77. password = Console.ReadLine();
  78. }
  79.  
  80. user.LogOn( new SteamUser.LogOnDetails
  81. {
  82. Username = username,
  83. Password = password,
  84.  
  85. AuthCode = authCode,
  86.  
  87. OSOverride = EOSType.Linux24,
  88. } );
  89. }
  90.  
  91. static void OnLoggedOff( SteamUser.LoggedOffCallback callback )
  92. {
  93. Console.WriteLine( "Logged off of Steam: {0}", callback.Result );
  94. }
  95.  
  96. static void OnLoggedOn( SteamUser.LoggedOnCallback callback )
  97. {
  98. if ( callback.Result == EResult.AccountLogonDenied )
  99. {
  100. Console.WriteLine( "SteamGuard authcode required!" );
  101. Console.Write( "Auth code: " );
  102. authCode = Console.ReadLine();
  103.  
  104. return;
  105. }
  106.  
  107. if ( callback.Result != EResult.OK )
  108. {
  109. Console.WriteLine( "Unable to logon to Steam: {0} / {1}", callback.Result, callback.ExtendedResult );
  110. return;
  111. }
  112.  
  113. Console.WriteLine( "Logged onto Steam, launching TF2..." );
  114.  
  115. var clientMsg = new ClientMsgProtobuf<CMsgClientGamesPlayed>( EMsg.ClientGamesPlayedNoDataBlob );
  116.  
  117. clientMsg.Body.games_played.Add( new CMsgClientGamesPlayed.GamePlayed
  118. {
  119. game_id = 440,
  120. } );
  121.  
  122. client.Send( clientMsg );
  123.  
  124. Console.WriteLine( "Done! Check your TF2 inventory now." );
  125. }
  126.  
  127.  
  128. }
  129. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement