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;
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")
@ -744,7 +744,7 @@ namespace NadekoBot.Modules.Administration
var avatarAddress = e.GetArg("img");
var imageStream = await SearchHelper.GetResponseStreamAsync(avatarAddress).ConfigureAwait(false);
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.
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.DataModels;
using NadekoBot.Extensions;
using NadekoBot.Classes;
using System.Drawing.Drawing2D;
using NadekoBot.Modules.Conversations.Commands;
using NadekoBot.Modules.Permissions.Classes;
using NadekoBot.Properties;
using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using NadekoBot.Modules.Conversations.Commands;
namespace NadekoBot.Modules.Conversations
{
@ -188,32 +183,6 @@ namespace NadekoBot.Modules.Conversations
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")
.Description("Shows the message where you were last mentioned in this channel (checks last 10k messages)")
.Do(async e =>
@ -306,7 +275,7 @@ namespace NadekoBot.Modules.Conversations
}
private static Func<CommandEventArgs, Task> SayYes()
=> async e => await e.Channel.SendMessage("Yes. :)").ConfigureAwait(false);
}

View File

@ -28,15 +28,14 @@ namespace NadekoBot.Classes.Help.Commands
await e.Channel.SendMessage($"`Help for '{com.Text}':` {com.Description}").ConfigureAwait(false);
}).ConfigureAwait(false);
};
public static string HelpString => (NadekoBot.IsBot
? $"To add me to your server, use this link -> <https://discordapp.com/oauth2/authorize?client_id=170254782546575360&scope=bot&permissions=66186303>\n"
: $"To invite me to your server, just send me an invite link here.") +
$"You can use `{NadekoBot.Config.CommandPrefixes.Help}modules` command to see a list of all modules.\n" +
$"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" +
$"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 HelpString {
get {
var str = string.IsNullOrWhiteSpace(NadekoBot.Creds.ClientId) && !NadekoBot.Config.DontJoinServers
? 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)
: "";
return str + String.Format(NadekoBot.Config.HelpString, NadekoBot.Config.CommandPrefixes.Help);
}
}
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 string BotMention { get; set; } = "";
public static bool Ready { get; set; } = false;
public static bool IsBot { get; set; } = false;
private static Channel OwnerPrivateChannel { get; set; }
@ -88,10 +87,10 @@ namespace NadekoBot
}
//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");
Creds.Password = Console.ReadLine();
Console.WriteLine("Token blank. Please enter your bot's token:\n");
Creds.Token = Console.ReadLine();
}
Console.WriteLine(string.IsNullOrWhiteSpace(Creds.GoogleAPIKey)
@ -182,20 +181,11 @@ namespace NadekoBot
{
try
{
if (string.IsNullOrWhiteSpace(Creds.Token))
await Client.Connect(Creds.Username, Creds.Password).ConfigureAwait(false);
else
{
await Client.Connect(Creds.Token).ConfigureAwait(false);
IsBot = true;
}
await Client.Connect(Creds.Token).ConfigureAwait(false);
}
catch (Exception ex)
{
if (string.IsNullOrWhiteSpace(Creds.Token))
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($"Token is wrong. Don't set a token if you don't have an official BOT account.");
Console.WriteLine(ex);
Console.ReadKey();
return;
@ -253,31 +243,13 @@ namespace NadekoBot
if (ConfigHandler.IsBlackListed(e))
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)
await OwnerPrivateChannel.SendMessage(e.User + ": ```\n" + e.Message.Text + "\n```").ConfigureAwait(false);
if (repliedRecently) return;
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 Task.Delay(2000).ConfigureAwait(false);
repliedRecently = false;

View File

@ -131,6 +131,17 @@ namespace NadekoBot.Classes.JSONModels
public string CurrencySign { get; set; } = "🌸";
public string CurrencyName { get; set; } = "NadekoFlower";
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

View File

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

View File

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

View File

@ -120,5 +120,6 @@
],
"CurrencySign": "🌸",
"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>"
}