public async ValueTask <GameClient> Obtain() { var client = await GoogleLogin.GetClientFromCookieAsync(_googleCookie).ConfigureAwait(false); await client.ConnectAsync().ConfigureAwait(false); return(new GameClient(client)); }
public async Task Open(string worldid) { WorldId = worldid; string[] data = File.ReadAllLines("../../../cookie.txt"); bool isGoogleToken = data[0] == "google" ? true : false; if (isGoogleToken) { client = await GoogleLogin.GetClientFromCookieAsync(data[1]); } else { client = new Client(data[1]); } await client.ConnectAsync(); try { Con = (Connection)client.CreateWorldConnection(WorldId); await Program.SayPrivate(ScannerOpenedBy, "[Scanner] Logged in!"); Console.Write("Opened scanner in "); Console.Write(WorldId, Color.Orange); Console.WriteLine("!"); Con.OnMessage += async(s, m) => { try { await MessageHandler(m); } catch (Exception e) { Console.WriteLine("Bot almost crashed!"); Console.Write(e); } }; await Con.SendAsync(MessageType.Init, 0); //Thread.Sleep(-1); } catch { await Program.SayPrivate(ScannerOpenedBy, "[Scanner] Failed to log in!"); } }
static async Task Main2(string[] data) { Console.WriteLine("Logging in..."); try { bool isGoogleToken = data[0] == "google" ? true : false; Client client; if (isGoogleToken) { client = await GoogleLogin.GetClientFromCookieAsync(data[1]); } else { client = new Client(data[1]); } await client.ConnectAsync(); Con = (Connection)client.CreateWorldConnection(WorldId); Con.OnMessage += async(s, m) => { try { await Main3(m); } catch (Exception e) { Console.WriteLine("Bot almost crashed!"); Console.Write(e); } }; await Con.SendAsync(MessageType.Init, 0); Thread.Sleep(-1); } catch { Console.WriteLine("Login failed! Update google cookie!"); } }