Advertisement
Guest User

Untitled

a guest
Feb 3rd, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using SteamKit2;
  7.  
  8. namespace tutorialbot
  9. {
  10. class Program
  11. {
  12. static string user, pass;
  13.  
  14. static SteamClient steamClient;
  15. static CallbackManager manager;
  16. static SteamUser steamUser;
  17. static bool isRunning = false;
  18.  
  19. static void Main(string[] args)
  20. {
  21. Console.Title = "A bot";
  22. Console.WriteLine("CTRL+C quits the program.");
  23.  
  24. Console.Write("Username: ");
  25. user = Console.ReadLine();
  26. Console.Write("Password: ");
  27. pass = Console.ReadLine();
  28.  
  29. SteamLogIn();
  30.  
  31. }
  32. static void SteamLogIn()
  33. {
  34. steamClient = new SteamClient();
  35. manager = new CallbackManager(steamClient);
  36. steamUser = steamClient.GetHandler<SteamUser>();
  37.  
  38. new Callback<SteamClient.ConnectedCallback>(OnConnected, manager);
  39.  
  40. new Callback<SteamUser.LoggedOnCallback>(OnLoggedOn, manager);
  41.  
  42. isRunning = true;
  43.  
  44. Console.WriteLine("Connecting to steam...\n");
  45.  
  46. steamClient.Connect();
  47.  
  48.  
  49. while(isRunning)
  50. {
  51. manager.RunWaitCallbacks(TimeSpan.FromSeconds(1));
  52. }
  53. Console.ReadKey();
  54. }
  55. static void OnConnected(SteamClient.ConnectedCallback callback)
  56. {
  57. if(callback.Result != EResult.OK)
  58. {
  59. Console.WriteLine("Unable to connect to Steam{0}", callback.Result);
  60. isRunning = false;
  61. return;
  62. }
  63. Console.WriteLine("Connected to Steam. \nLogging in {0}...\n",user);
  64.  
  65. steamUser.LogOn(new SteamUser.LogOnDetails
  66. {
  67. Username = user,
  68. Password = pass,
  69. });
  70. }
  71.  
  72. static void OnLoggedOn(SteamUser.LoggedOnCallback callback)
  73. {
  74. if(callback.Result != EResult.AccountLogonDenied)
  75. {
  76. Console.WriteLine("This accountis steamGuard protected.");
  77. return;
  78. }
  79. if(callback.Result != EResult.OK)
  80. {
  81. Console.WriteLine("Unable to log in to Steam {0}\n", callback);
  82. isRunning = false;
  83. return;
  84. }
  85. Console.WriteLine("{0} succesfully logged in!",user);
  86. Console.ReadKey();
  87. Environment.Exit(0);
  88. }
  89. }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement