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 System.Threading.Tasks;
- using SteamKit2;
- namespace tutorialbot
- {
- class Program
- {
- static string user, pass;
- static SteamClient steamClient;
- static CallbackManager manager;
- static SteamUser steamUser;
- static bool isRunning = false;
- static void Main(string[] args)
- {
- Console.Title = "A bot";
- Console.WriteLine("CTRL+C quits the program.");
- Console.Write("Username: ");
- user = Console.ReadLine();
- Console.Write("Password: ");
- pass = Console.ReadLine();
- SteamLogIn();
- }
- static void SteamLogIn()
- {
- steamClient = new SteamClient();
- manager = new CallbackManager(steamClient);
- steamUser = steamClient.GetHandler<SteamUser>();
- new Callback<SteamClient.ConnectedCallback>(OnConnected, manager);
- new Callback<SteamUser.LoggedOnCallback>(OnLoggedOn, manager);
- isRunning = true;
- Console.WriteLine("Connecting to steam...\n");
- steamClient.Connect();
- while(isRunning)
- {
- manager.RunWaitCallbacks(TimeSpan.FromSeconds(1));
- }
- Console.ReadKey();
- }
- static void OnConnected(SteamClient.ConnectedCallback callback)
- {
- if(callback.Result != EResult.OK)
- {
- Console.WriteLine("Unable to connect to Steam{0}", callback.Result);
- isRunning = false;
- return;
- }
- Console.WriteLine("Connected to Steam. \nLogging in {0}...\n",user);
- steamUser.LogOn(new SteamUser.LogOnDetails
- {
- Username = user,
- Password = pass,
- });
- }
- static void OnLoggedOn(SteamUser.LoggedOnCallback callback)
- {
- if(callback.Result != EResult.AccountLogonDenied)
- {
- Console.WriteLine("This accountis steamGuard protected.");
- return;
- }
- if(callback.Result != EResult.OK)
- {
- Console.WriteLine("Unable to log in to Steam {0}\n", callback);
- isRunning = false;
- return;
- }
- Console.WriteLine("{0} succesfully logged in!",user);
- Console.ReadKey();
- Environment.Exit(0);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement