Client id added to creds, no more username/pass, cleanup, HelpString added to creds (-h command). No more support for normal user accounts.

This commit is contained in:
Master Kwoth 2016-06-15 19:03:00 +02:00
parent c9a0b39d69
commit 5b379f7ffa
8 changed files with 43 additions and 92 deletions

View File

@ -728,7 +728,7 @@ namespace NadekoBot.Modules.Administration
{ {
if (e.GetArg("new_name") == null) return; if (e.GetArg("new_name") == null) return;
await client.CurrentUser.Edit(NadekoBot.Creds.Password, e.GetArg("new_name")).ConfigureAwait(false); await client.CurrentUser.Edit("", e.GetArg("new_name")).ConfigureAwait(false);
}); });
cgb.CreateCommand(Prefix + "newavatar") cgb.CreateCommand(Prefix + "newavatar")
@ -744,7 +744,7 @@ namespace NadekoBot.Modules.Administration
var avatarAddress = e.GetArg("img"); var avatarAddress = e.GetArg("img");
var imageStream = await SearchHelper.GetResponseStreamAsync(avatarAddress).ConfigureAwait(false); var imageStream = await SearchHelper.GetResponseStreamAsync(avatarAddress).ConfigureAwait(false);
var image = System.Drawing.Image.FromStream(imageStream); var image = System.Drawing.Image.FromStream(imageStream);
await client.CurrentUser.Edit(NadekoBot.Creds.Password, avatar: image.ToStream()).ConfigureAwait(false); await client.CurrentUser.Edit("", avatar: image.ToStream()).ConfigureAwait(false);
// Send confirm. // Send confirm.
await e.Channel.SendMessage("New avatar set.").ConfigureAwait(false); await e.Channel.SendMessage("New avatar set.").ConfigureAwait(false);

View File

@ -4,18 +4,13 @@ using Discord.Modules;
using NadekoBot.Classes.Conversations.Commands; using NadekoBot.Classes.Conversations.Commands;
using NadekoBot.DataModels; using NadekoBot.DataModels;
using NadekoBot.Extensions; using NadekoBot.Extensions;
using NadekoBot.Classes; using NadekoBot.Modules.Conversations.Commands;
using System.Drawing.Drawing2D;
using NadekoBot.Modules.Permissions.Classes; using NadekoBot.Modules.Permissions.Classes;
using NadekoBot.Properties;
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using NadekoBot.Modules.Conversations.Commands;
namespace NadekoBot.Modules.Conversations namespace NadekoBot.Modules.Conversations
{ {
@ -188,32 +183,6 @@ namespace NadekoBot.Modules.Conversations
await e.Channel.SendMessage(str).ConfigureAwait(false); await e.Channel.SendMessage(str).ConfigureAwait(false);
}); });
if (!NadekoBot.Config.DontJoinServers)
{
cgb.CreateCommand("j")
.Description("Joins a server using a code.")
.Parameter("id", ParameterType.Required)
.Do(async e =>
{
var invite = await client.GetInvite(e.Args[0]).ConfigureAwait(false);
if (invite != null)
{
try
{
await invite.Accept().ConfigureAwait(false);
}
catch
{
await e.Channel.SendMessage("Failed to accept invite.").ConfigureAwait(false);
}
await e.Channel.SendMessage("I got in!").ConfigureAwait(false);
return;
}
await e.Channel.SendMessage("Invalid code.").ConfigureAwait(false);
});
}
cgb.CreateCommand("slm") cgb.CreateCommand("slm")
.Description("Shows the message where you were last mentioned in this channel (checks last 10k messages)") .Description("Shows the message where you were last mentioned in this channel (checks last 10k messages)")
.Do(async e => .Do(async e =>

View File

@ -28,15 +28,14 @@ namespace NadekoBot.Classes.Help.Commands
await e.Channel.SendMessage($"`Help for '{com.Text}':` {com.Description}").ConfigureAwait(false); await e.Channel.SendMessage($"`Help for '{com.Text}':` {com.Description}").ConfigureAwait(false);
}).ConfigureAwait(false); }).ConfigureAwait(false);
}; };
public static string HelpString => (NadekoBot.IsBot public static string HelpString {
? $"To add me to your server, use this link -> <https://discordapp.com/oauth2/authorize?client_id=170254782546575360&scope=bot&permissions=66186303>\n" get {
: $"To invite me to your server, just send me an invite link here.") + var str = string.IsNullOrWhiteSpace(NadekoBot.Creds.ClientId) && !NadekoBot.Config.DontJoinServers
$"You can use `{NadekoBot.Config.CommandPrefixes.Help}modules` command to see a list of all modules.\n" + ? String.Format("To add me to your server, use this link -> <https://discordapp.com/oauth2/authorize?client_id={0}&scope=bot&permissions=66186303>\n", NadekoBot.Creds.ClientId)
$"You can use `{NadekoBot.Config.CommandPrefixes.Help}commands ModuleName`" + : "";
$" (for example `{NadekoBot.Config.CommandPrefixes.Help}commands Administration`) to see a list of all of the commands in that module.\n" + return str + String.Format(NadekoBot.Config.HelpString, NadekoBot.Config.CommandPrefixes.Help);
$"For a specific command help, use `{NadekoBot.Config.CommandPrefixes.Help}h \"Command name\"` (for example `-h \"!m q\"`)\n\n" + }
"**LIST OF COMMANDS CAN BE FOUND ON THIS LINK**\n\n <https://github.com/Kwoth/NadekoBot/blob/master/commandlist.md>\n\n" + }
"Nadeko Support Server: <https://discord.gg/0ehQwTK2RBjAxzEY>";
public static string DMHelpString => NadekoBot.Config.DMHelpString; public static string DMHelpString => NadekoBot.Config.DMHelpString;

View File

@ -40,7 +40,6 @@ namespace NadekoBot
public static LocalizedStrings Locale { get; set; } = new LocalizedStrings(); public static LocalizedStrings Locale { get; set; } = new LocalizedStrings();
public static string BotMention { get; set; } = ""; public static string BotMention { get; set; } = "";
public static bool Ready { get; set; } = false; public static bool Ready { get; set; } = false;
public static bool IsBot { get; set; } = false;
private static Channel OwnerPrivateChannel { get; set; } private static Channel OwnerPrivateChannel { get; set; }
@ -88,10 +87,10 @@ namespace NadekoBot
} }
//if password is not entered, prompt for password //if password is not entered, prompt for password
if (string.IsNullOrWhiteSpace(Creds.Password) && string.IsNullOrWhiteSpace(Creds.Token)) if (string.IsNullOrWhiteSpace(Creds.Token))
{ {
Console.WriteLine("Password blank. Please enter your password:\n"); Console.WriteLine("Token blank. Please enter your bot's token:\n");
Creds.Password = Console.ReadLine(); Creds.Token = Console.ReadLine();
} }
Console.WriteLine(string.IsNullOrWhiteSpace(Creds.GoogleAPIKey) Console.WriteLine(string.IsNullOrWhiteSpace(Creds.GoogleAPIKey)
@ -182,20 +181,11 @@ namespace NadekoBot
{ {
try try
{ {
if (string.IsNullOrWhiteSpace(Creds.Token)) await Client.Connect(Creds.Token).ConfigureAwait(false);
await Client.Connect(Creds.Username, Creds.Password).ConfigureAwait(false);
else
{
await Client.Connect(Creds.Token).ConfigureAwait(false);
IsBot = true;
}
} }
catch (Exception ex) catch (Exception ex)
{ {
if (string.IsNullOrWhiteSpace(Creds.Token)) Console.WriteLine($"Token is wrong. Don't set a token if you don't have an official BOT account.");
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;
@ -253,31 +243,13 @@ namespace NadekoBot
if (ConfigHandler.IsBlackListed(e)) if (ConfigHandler.IsBlackListed(e))
return; return;
if (!NadekoBot.Config.DontJoinServers && !IsBot)
{
try
{
await (await Client.GetInvite(e.Message.Text).ConfigureAwait(false)).Accept().ConfigureAwait(false);
await e.Channel.SendMessage("I got in!").ConfigureAwait(false);
return;
}
catch
{
if (e.User.Id == 109338686889476096)
{ //carbonitex invite
await e.Channel.SendMessage("Failed to join the server.").ConfigureAwait(false);
return;
}
}
}
if (Config.ForwardMessages && !NadekoBot.Creds.OwnerIds.Contains(e.User.Id) && OwnerPrivateChannel != null) if (Config.ForwardMessages && !NadekoBot.Creds.OwnerIds.Contains(e.User.Id) && OwnerPrivateChannel != null)
await OwnerPrivateChannel.SendMessage(e.User + ": ```\n" + e.Message.Text + "\n```").ConfigureAwait(false); await OwnerPrivateChannel.SendMessage(e.User + ": ```\n" + e.Message.Text + "\n```").ConfigureAwait(false);
if (repliedRecently) return; if (repliedRecently) return;
repliedRecently = true; repliedRecently = true;
if (e.Message.RawText != "-h") if (e.Message.RawText != NadekoBot.Config.CommandPrefixes.Help + "h")
await e.Channel.SendMessage(HelpCommand.DMHelpString).ConfigureAwait(false); await e.Channel.SendMessage(HelpCommand.DMHelpString).ConfigureAwait(false);
await Task.Delay(2000).ConfigureAwait(false); await Task.Delay(2000).ConfigureAwait(false);
repliedRecently = false; repliedRecently = false;

View File

@ -131,6 +131,17 @@ namespace NadekoBot.Classes.JSONModels
public string CurrencySign { get; set; } = "🌸"; public string CurrencySign { get; set; } = "🌸";
public string CurrencyName { get; set; } = "NadekoFlower"; public string CurrencyName { get; set; } = "NadekoFlower";
public string DMHelpString { get; set; } = "Type `-h` for help."; public string DMHelpString { get; set; } = "Type `-h` for help.";
public string HelpString { get; set; } = @"You can use `{0}modules` command to see a list of all modules.
You can use `{0}commands ModuleName`
(for example `{0}commands Administration`) to see a list of all of the commands in that module.
For a specific command help, use `{0}h ""Command name""` (for example `-h ""!m q""`)
**LIST OF COMMANDS CAN BE FOUND ON THIS LINK**
<https://github.com/Kwoth/NadekoBot/blob/master/commandlist.md>
Nadeko Support Server: <https://discord.gg/0ehQwTK2RBjAxzEY>";
} }
public class CommandPrefixesModel public class CommandPrefixesModel

View File

@ -6,17 +6,17 @@ namespace NadekoBot.Classes.JSONModels
{ {
public class Credentials public class Credentials
{ {
public string Username = "myemail@email.com"; public string Token { get; set; } = "";
public string Password = "xxxxxxx"; public string ClientId { get; set; } = "";
public string Token = ""; public ulong BotId { get; set; } = 1231231231231;
public ulong BotId = 1231231231231; public string GoogleAPIKey { get; set; } = "";
public string GoogleAPIKey = ""; public ulong[] OwnerIds { get; set; } = { 123123123123, 5675675679845 };
public ulong[] OwnerIds = { 123123123123, 5675675679845 }; public string TrelloAppKey { get; set; } = "";
public string TrelloAppKey = ""; public string SoundCloudClientID { get; set; } = "";
public string SoundCloudClientID = ""; public string MashapeKey { get; set; } = "";
public string MashapeKey = ""; public string LOLAPIKey { get; set; } = "";
public string LOLAPIKey = ""; public string CarbonKey { get; set; } = "";
public string CarbonKey = "";
} }
[DebuggerDisplay("{items[0].id.playlistId}")] [DebuggerDisplay("{items[0].id.playlistId}")]
public class YoutubePlaylistSearch public class YoutubePlaylistSearch

View File

@ -1,7 +1,6 @@
{ {
"Username": "myemail@email.com",
"Password": "xxxxxxx",
"Token": "", "Token": "",
"ClientId": "",
"BotId": 1231231231231, "BotId": 1231231231231,
"GoogleAPIKey": "", "GoogleAPIKey": "",
"OwnerIds": [ "OwnerIds": [

View File

@ -120,5 +120,6 @@
], ],
"CurrencySign": "🌸", "CurrencySign": "🌸",
"CurrencyName": "NadekoFlower", "CurrencyName": "NadekoFlower",
"DMHelpString": "Type `-h` for help." "DMHelpString": "Type `-h` for help.",
"HelpString": "You can use `{0}modules` command to see a list of all modules.\r\nYou can use `{0}commands ModuleName`\r\n(for example `{0}commands Administration`) to see a list of all of the commands in that module.\r\nFor a specific command help, use `{0}h \"Command name\"` (for example `-h \"!m q\"`)\r\n\r\n\r\n**LIST OF COMMANDS CAN BE FOUND ON THIS LINK**\r\n<https://github.com/Kwoth/NadekoBot/blob/master/commandlist.md>\r\n\r\n\r\nNadeko Support Server: <https://discord.gg/0ehQwTK2RBjAxzEY>"
} }