Guest User

Program

a guest
Apr 9th, 2016
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.67 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 KattBot
  9. {
  10.     class Program
  11.     {
  12.         public static string Password { get; set; }
  13.  
  14.         public static string Username { get; set; }
  15.  
  16.         static string user, pass;
  17.  
  18.         static SteamClient steamClient;
  19.         static CallbackManager manager;
  20.         static SteamUser steamUser;
  21.  
  22.         static bool isRunning = false;
  23.  
  24.         static void Main(string[] args)
  25.         {
  26.             Console.Title = "A Bot";
  27.             Console.WriteLine("Ctrl+C to Quit");
  28.  
  29.             Console.Write("Username: ");
  30.             user = Console.ReadLine();
  31.  
  32.             Console.Write("Password: ");
  33.             pass = Console.ReadLine();
  34.  
  35.             SteamLogIn();
  36.         }
  37.  
  38.         static void SteamLogIn()
  39.         {
  40.             steamClient = new SteamClient();
  41.  
  42.             manager = new CallbackManager(steamClient);
  43.  
  44.             steamUser = steamClient.GetHandler<SteamUser>();
  45.  
  46.             new Callback<SteamClient.ConnectedCallback>(OnConnected, manager);
  47.  
  48.             new Callback<SteamUser.LoggedOnCallback>(OnLoggedOn, manager);
  49.  
  50.  
  51.             steamClient.Connect();
  52.  
  53.             isRunning = true;
  54.             while (isRunning)
  55.             {
  56.                 manager.RunWaitCallbacks(TimeSpan.FromSeconds(1));
  57.             }
  58.             Console.ReadKey();
  59.         }
  60.         static void OnConnected(SteamClient.ConnectedCallback callback)
  61.         {
  62.             if(callback.Result != EResult.OK)
  63.             {
  64.                 Console.WriteLine = ("Unable to connect to Steam: {0}", callback.Result);
  65.                 isRunning = false;
  66.                 return;
  67.             }
  68.  
  69.             Console.WriteLine("Connected to Steam. \nLogging in{0}...\n",user);
  70.  
  71.             steamUser.LogOn(new SteamUser.LogOnDetails());
  72.             {
  73.                 Username = user;
  74.                 Password = pass;
  75.             }
  76.         }
  77.  
  78.         static void OnLoggedOn(SteamUser.LoggedOnCallback callback)
  79.         {
  80.             if (callback.Result == EResult.AccountLogonDenied)
  81.             {
  82.                 Console.WriteLine("This Account is SteamGuard Protected.");
  83.                 isRunning = false;
  84.                 return;
  85.             }
  86.             if (callback.Result != EResult.OK)
  87.             {
  88.                 Console.WriteLine("Unable to log in to Steam: {0}\n", callback.Result);
  89.                 isRunning = false;
  90.                 return;
  91.             }
  92.             Console.WriteLine("{0} succesfully logged in!", user);
  93.             Console.ReadKey();
  94.             Environment.Exit(0);
  95.         }
  96.  
  97.  
  98.     }
  99. }
Add Comment
Please, Sign In to add comment