Added option to login with a token.

This commit is contained in:
Master Kwoth 2016-04-09 14:15:02 +02:00
parent 62797a88f1
commit e4114b4f97
2 changed files with 14 additions and 7 deletions

View File

@ -5,9 +5,10 @@ namespace NadekoBot.Classes.JSONModels
{ {
public string Username = "myemail@email.com"; public string Username = "myemail@email.com";
public string Password = "xxxxxxx"; public string Password = "xxxxxxx";
public string Token = "";
public ulong BotId = 1231231231231; public ulong BotId = 1231231231231;
public string GoogleAPIKey = ""; public string GoogleAPIKey = "";
public ulong[] OwnerIds = {123123123123, 5675675679845}; public ulong[] OwnerIds = { 123123123123, 5675675679845 };
public string TrelloAppKey = ""; public string TrelloAppKey = "";
public string SoundCloudClientID = ""; public string SoundCloudClientID = "";
public string MashapeKey = ""; public string MashapeKey = "";

View File

@ -68,9 +68,10 @@ namespace NadekoBot
Config.Quotes = JsonConvert.DeserializeObject<List<Quote>>(File.ReadAllText("data/quotes.json")); Config.Quotes = JsonConvert.DeserializeObject<List<Quote>>(File.ReadAllText("data/quotes.json"));
Config.PokemonTypes = JsonConvert.DeserializeObject<List<PokemonType>>(File.ReadAllText("data/PokemonTypes.json")); Config.PokemonTypes = JsonConvert.DeserializeObject<List<PokemonType>>(File.ReadAllText("data/PokemonTypes.json"));
} }
catch catch (Exception ex)
{ {
Console.WriteLine("Failed loading configuration."); Console.WriteLine("Failed loading configuration.");
Console.WriteLine(ex);
Console.ReadKey(); Console.ReadKey();
return; return;
} }
@ -88,7 +89,7 @@ namespace NadekoBot
} }
//if password is not entered, prompt for password //if password is not entered, prompt for password
if (string.IsNullOrWhiteSpace(Creds.Password)) if (string.IsNullOrWhiteSpace(Creds.Password) && !string.IsNullOrWhiteSpace(Creds.Token))
{ {
Console.WriteLine("Password blank. Please enter your password:\n"); Console.WriteLine("Password blank. Please enter your password:\n");
Creds.Password = Console.ReadLine(); Creds.Password = Console.ReadLine();
@ -166,7 +167,7 @@ namespace NadekoBot
modules.Add(new Conversations(), "Conversations", ModuleFilter.None); modules.Add(new Conversations(), "Conversations", ModuleFilter.None);
modules.Add(new GamblingModule(), "Gambling", ModuleFilter.None); modules.Add(new GamblingModule(), "Gambling", ModuleFilter.None);
modules.Add(new GamesModule(), "Games", ModuleFilter.None); modules.Add(new GamesModule(), "Games", ModuleFilter.None);
modules.Add(new Music(), "Music", ModuleFilter.None); //modules.Add(new Music(), "Music", ModuleFilter.None);
modules.Add(new Searches(), "Searches", ModuleFilter.None); modules.Add(new Searches(), "Searches", ModuleFilter.None);
modules.Add(new NSFW(), "NSFW", ModuleFilter.None); modules.Add(new NSFW(), "NSFW", ModuleFilter.None);
modules.Add(new ClashOfClans(), "ClashOfClans", ModuleFilter.None); modules.Add(new ClashOfClans(), "ClashOfClans", ModuleFilter.None);
@ -180,12 +181,17 @@ namespace NadekoBot
{ {
try try
{ {
await Client.Connect(Creds.Username, Creds.Password); if (string.IsNullOrWhiteSpace(Creds.Token))
await Client.Connect(Creds.Username, Creds.Password);
else
await Client.Connect(Creds.Token);
} }
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine($"Probably wrong EMAIL or PASSWORD.\n{ex.Message}"); if (string.IsNullOrWhiteSpace(Creds.Token))
Console.ReadKey(); Console.WriteLine($"Probably wrong EMAIL or PASSWORD.");
else
Console.WriteLine($"Token is wrong. Don't set a token if you don't have an official BOT account.");
Console.WriteLine(ex); Console.WriteLine(ex);
Console.ReadKey(); Console.ReadKey();
return; return;