trivia, help module converted
This commit is contained in:
@@ -1,10 +1,6 @@
|
||||
using Discord;
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NadekoBot.Modules
|
||||
{
|
||||
|
@@ -1,7 +1,6 @@
|
||||
using Discord;
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Attributes;
|
||||
using NadekoBot.Classes;
|
||||
using NadekoBot.Extensions;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
@@ -1,7 +1,6 @@
|
||||
using Discord;
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Attributes;
|
||||
using NadekoBot.Classes;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
|
@@ -1,6 +1,4 @@
|
||||
using Discord;
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Classes;
|
||||
using NadekoBot.Extensions;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
|
@@ -1,7 +1,6 @@
|
||||
using Discord;
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Attributes;
|
||||
using NadekoBot.Classes;
|
||||
using NadekoBot.Modules.Games.Commands.Trivia;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
|
140
src/NadekoBot/Modules/Help/HelpModule.cs
Normal file
140
src/NadekoBot/Modules/Help/HelpModule.cs
Normal file
@@ -0,0 +1,140 @@
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Extensions;
|
||||
using System.Linq;
|
||||
using Discord;
|
||||
using NadekoBot.Services;
|
||||
using System.Threading.Tasks;
|
||||
using NadekoBot.Attributes;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace NadekoBot.Modules.Help
|
||||
{
|
||||
[Module("-", AppendSpace = false)]
|
||||
public partial class HelpModule : DiscordModule
|
||||
{
|
||||
public string HelpString {
|
||||
get {
|
||||
var str = "To add me to your server, use this link -> <https://discordapp.com/oauth2/authorize?client_id={0}&scope=bot&permissions=66186303>\n";
|
||||
return str + String.Format(str, NadekoBot.Credentials.ClientId);
|
||||
}
|
||||
}
|
||||
public HelpModule(ILocalization loc, CommandService cmds, IBotConfiguration config, IDiscordClient client) : base(loc, cmds, config, client)
|
||||
{
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Modules(IMessage imsg)
|
||||
{
|
||||
var channel = imsg.Channel as IGuildChannel;
|
||||
|
||||
await imsg.Channel.SendMessageAsync("`List of modules:` \n• " + string.Join("\n• ", _commands.Modules.Select(m => m.Name)) + $"\n`Type \"-commands module_name\" to get a list of commands in that module.`")
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Commands(IMessage imsg, [Remainder] string module)
|
||||
{
|
||||
var channel = imsg.Channel as IGuildChannel;
|
||||
|
||||
module = module?.Trim().ToUpperInvariant();
|
||||
if (string.IsNullOrWhiteSpace(module))
|
||||
return;
|
||||
var cmds = _commands.Commands.Where(c => c.Module.Name.ToUpperInvariant() == module)
|
||||
.OrderBy(c => c.Text)
|
||||
.AsEnumerable();
|
||||
var cmdsArray = cmds as Command[] ?? cmds.ToArray();
|
||||
if (!cmdsArray.Any())
|
||||
{
|
||||
await imsg.Channel.SendMessageAsync("That module does not exist.").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
if (module != "customreactions" && module != "conversations")
|
||||
{
|
||||
//todo aliases
|
||||
await imsg.Channel.SendTableAsync("`List Of Commands:`\n", cmdsArray, el => $"{el.Text,-15}").ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
await imsg.Channel.SendMessageAsync("`List Of Commands:`\n• " + string.Join("\n• ", cmdsArray.Select(c => $"{c.Text}")));
|
||||
}
|
||||
await imsg.Channel.SendMessageAsync($"`You can type \"-h command_name\" to see the help about that specific command.`").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Help(IMessage imsg, [Remainder] string comToFind)
|
||||
{
|
||||
var channel = imsg.Channel as IGuildChannel;
|
||||
|
||||
comToFind = comToFind?.ToLowerInvariant();
|
||||
if (string.IsNullOrWhiteSpace(comToFind))
|
||||
{
|
||||
await (await (imsg.Author as IGuildUser).CreateDMChannelAsync()).SendMessageAsync(HelpString).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
var com = _commands.Commands.FirstOrDefault(c => c.Text.ToLowerInvariant() == comToFind);
|
||||
|
||||
//todo aliases
|
||||
if (com != null)
|
||||
await imsg.Channel.SendMessageAsync($@"**__Help for:__ `{com.Text}`**
|
||||
**Desc:** {com.Description}
|
||||
**Usage:** {com.Summary}").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Hgit(IMessage imsg)
|
||||
{
|
||||
var helpstr = new StringBuilder();
|
||||
|
||||
var lastModule = "";
|
||||
foreach (var com in _commands.Commands)
|
||||
{
|
||||
if (com.Module.Name != lastModule)
|
||||
{
|
||||
helpstr.AppendLine("\n### " + com.Module.Name + " ");
|
||||
helpstr.AppendLine("Command and aliases | Description | Usage");
|
||||
helpstr.AppendLine("----------------|--------------|-------");
|
||||
lastModule = com.Module.Name;
|
||||
}
|
||||
//todo aliases
|
||||
helpstr.AppendLine($"`{com.Text}` | {com.Description} | {com.Summary}");
|
||||
}
|
||||
helpstr = helpstr.Replace((await NadekoBot.Client.GetCurrentUserAsync()).Username , "@BotName");
|
||||
#if DEBUG
|
||||
File.WriteAllText("../../../docs/Commands List.md", helpstr.ToString());
|
||||
#else
|
||||
File.WriteAllText("commandlist.md", helpstr.ToString());
|
||||
#endif
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Guide(IMessage imsg)
|
||||
{
|
||||
var channel = imsg.Channel as IGuildChannel;
|
||||
|
||||
await imsg.Channel.SendMessageAsync(
|
||||
@"**LIST OF COMMANDS**: <http://nadekobot.readthedocs.io/en/latest/Commands%20List/>
|
||||
**Hosting Guides and docs can be found here**: <http://nadekobot.rtfd.io>").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Donate(IMessage imsg)
|
||||
{
|
||||
var channel = imsg.Channel as IGuildChannel;
|
||||
|
||||
await imsg.Channel.SendMessageAsync(
|
||||
$@"You can support the project on patreon. <https://patreon.com/nadekobot> or
|
||||
You can send donations to `nadekodiscordbot@gmail.com`
|
||||
Don't forget to leave your discord name or id in the message.
|
||||
|
||||
**Thank you** ♥️").ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
@@ -8,7 +8,6 @@ using System.Threading.Tasks;
|
||||
using NadekoBot.Services;
|
||||
using System.Net.Http;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace NadekoBot.Modules.NSFW
|
||||
@@ -16,9 +15,6 @@ namespace NadekoBot.Modules.NSFW
|
||||
[Module("~", AppendSpace = false)]
|
||||
public class NSFWModule : DiscordModule
|
||||
{
|
||||
|
||||
private readonly Random rng = new Random();
|
||||
|
||||
public NSFWModule(ILocalization loc, CommandService cmds, IBotConfiguration config, IDiscordClient client) : base(loc, cmds, config, client)
|
||||
{
|
||||
}
|
||||
@@ -117,7 +113,7 @@ namespace NadekoBot.Modules.NSFW
|
||||
JToken obj;
|
||||
using (var http = new HttpClient())
|
||||
{
|
||||
obj = JArray.Parse(await http.GetStringAsync($"http://api.oboobs.ru/boobs/{rng.Next(0, 9380)}").ConfigureAwait(false))[0];
|
||||
obj = JArray.Parse(await http.GetStringAsync($"http://api.oboobs.ru/boobs/{ new Random().Next(0, 9880) }").ConfigureAwait(false))[0];
|
||||
}
|
||||
await imsg.Channel.SendMessageAsync($"http://media.oboobs.ru/{ obj["preview"].ToString() }").ConfigureAwait(false);
|
||||
}
|
||||
@@ -138,7 +134,7 @@ namespace NadekoBot.Modules.NSFW
|
||||
JToken obj;
|
||||
using (var http = new HttpClient())
|
||||
{
|
||||
obj = JArray.Parse(await http.GetStringAsync($"http://api.obutts.ru/butts/{rng.Next(0, 3373)}").ConfigureAwait(false))[0];
|
||||
obj = JArray.Parse(await http.GetStringAsync($"http://api.obutts.ru/butts/{ new Random().Next(0, 3873) }").ConfigureAwait(false))[0];
|
||||
}
|
||||
await imsg.Channel.SendMessageAsync($"http://media.obutts.ru/{ obj["preview"].ToString() }").ConfigureAwait(false);
|
||||
}
|
||||
|
@@ -1,12 +1,8 @@
|
||||
using NadekoBot.Modules.Searches.Commands.Models;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
@@ -1,5 +1,4 @@
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Classes;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NadekoBot.Modules.Searches.Commands.Models
|
||||
{
|
||||
|
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NadekoBot.Modules.Searches.Commands.Models
|
||||
namespace NadekoBot.Modules.Searches.Commands.Models
|
||||
{
|
||||
public class WikipediaApiModel
|
||||
{
|
||||
|
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NadekoBot.Modules.Searches.Commands.Models
|
||||
namespace NadekoBot.Modules.Searches.Commands.Models
|
||||
{
|
||||
public class WoWJoke
|
||||
{
|
||||
|
@@ -4,19 +4,15 @@ using NadekoBot.Modules.Searches.Commands.IMDB;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using NadekoBot.Services;
|
||||
using System.Threading.Tasks;
|
||||
using NadekoBot.Attributes;
|
||||
using NadekoBot.Extensions;
|
||||
using Discord.API;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Net;
|
||||
using NadekoBot.Modules.Searches.Commands.Models;
|
||||
using Google.Apis.YouTube.v3;
|
||||
|
||||
namespace NadekoBot.Modules.Searches
|
||||
{
|
||||
@@ -306,7 +302,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
http.DefaultRequestHeaders.Add("X-Mashape-Key", NadekoBot.Credentials.MashapeKey);
|
||||
res = await http.GetStringAsync($"https://tagdef.p.mashape.com/one.{Uri.EscapeUriString(arg)}.json").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
var items = JObject.Parse(res);
|
||||
@@ -355,7 +351,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
if (string.IsNullOrWhiteSpace(usrStr))
|
||||
return;
|
||||
|
||||
var usr = (await channel.Guild.GetUsersAsync()).Where(u=>u.Username.ToUpperInvariant() == usrStr).FirstOrDefault();
|
||||
var usr = (await channel.Guild.GetUsersAsync()).Where(u => u.Username.ToUpperInvariant() == usrStr).FirstOrDefault();
|
||||
|
||||
if (usr == null || string.IsNullOrWhiteSpace(usr.AvatarUrl))
|
||||
return;
|
||||
@@ -495,5 +491,4 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
145
src/NadekoBot/Modules/Trello/TrelloModule.cs
Normal file
145
src/NadekoBot/Modules/Trello/TrelloModule.cs
Normal file
@@ -0,0 +1,145 @@
|
||||
//using Discord.Modules;
|
||||
//using Manatee.Trello;
|
||||
//using Manatee.Trello.ManateeJson;
|
||||
//using NadekoBot.Extensions;
|
||||
//using NadekoBot.Modules.Permissions.Classes;
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using System.Timers;
|
||||
//using Action = Manatee.Trello.Action;
|
||||
////todo rewrite
|
||||
//namespace NadekoBot.Modules.Trello
|
||||
//{
|
||||
// internal class TrelloModule : DiscordModule
|
||||
// {
|
||||
// private readonly Timer t = new Timer { Interval = 2000 };
|
||||
// public override string Prefix { get; } = NadekoBot.Config.CommandPrefixes.Trello;
|
||||
|
||||
// public override void Install(ModuleManager manager)
|
||||
// {
|
||||
|
||||
// var client = manager.Client;
|
||||
|
||||
// var serializer = new ManateeSerializer();
|
||||
// TrelloConfiguration.Serializer = serializer;
|
||||
// TrelloConfiguration.Deserializer = serializer;
|
||||
// TrelloConfiguration.JsonFactory = new ManateeFactory();
|
||||
// TrelloConfiguration.RestClientProvider = new Manatee.Trello.WebApi.WebApiClientProvider();
|
||||
// TrelloAuthorization.Default.AppKey = NadekoBot.Creds.TrelloAppKey;
|
||||
// //TrelloAuthorization.Default.UserToken = "[your user token]";
|
||||
|
||||
// Discord.Channel bound = null;
|
||||
// Board board = null;
|
||||
|
||||
// List<string> last5ActionIDs = null;
|
||||
// t.Elapsed += async (s, e) =>
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// if (board == null || bound == null)
|
||||
// return; //do nothing if there is no bound board
|
||||
|
||||
// board.Refresh();
|
||||
// var cur5Actions = board.Actions.Take(board.Actions.Count() < 5 ? board.Actions.Count() : 5);
|
||||
// var cur5ActionsArray = cur5Actions as Action[] ?? cur5Actions.ToArray();
|
||||
|
||||
// if (last5ActionIDs == null)
|
||||
// {
|
||||
// last5ActionIDs = cur5ActionsArray.Select(a => a.Id).ToList();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// foreach (var a in cur5ActionsArray.Where(ca => !last5ActionIDs.Contains(ca.Id)))
|
||||
// {
|
||||
// await bound.Send("**--TRELLO NOTIFICATION--**\n" + a.ToString()).ConfigureAwait(false);
|
||||
// }
|
||||
// last5ActionIDs.Clear();
|
||||
// last5ActionIDs.AddRange(cur5ActionsArray.Select(a => a.Id));
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// Console.WriteLine("Timer failed " + ex.ToString());
|
||||
// }
|
||||
// };
|
||||
|
||||
// manager.CreateCommands("", cgb =>
|
||||
// {
|
||||
|
||||
// cgb.AddCheck(PermissionChecker.Instance);
|
||||
|
||||
// cgb.CreateCommand(Prefix + "bind")
|
||||
// .Description("Bind a trello bot to a single channel. " +
|
||||
// "You will receive notifications from your board when something is added or edited." +
|
||||
// $" **Bot Owner Only!**| `{Prefix}bind [board_id]`")
|
||||
// .Parameter("board_id", Discord.Commands.ParameterType.Required)
|
||||
// .Do(async e =>
|
||||
// {
|
||||
// if (!NadekoBot.IsOwner(e.User.Id)) return;
|
||||
// if (bound != null) return;
|
||||
// try
|
||||
// {
|
||||
// bound = e.Channel;
|
||||
// board = new Board(e.GetArg("board_id").Trim());
|
||||
// board.Refresh();
|
||||
// await imsg.Channel.SendMessageAsync("Successfully bound to this channel and board " + board.Name);
|
||||
// t.Start();
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// Console.WriteLine("Failed to join the board. " + ex.ToString());
|
||||
// }
|
||||
// });
|
||||
|
||||
// cgb.CreateCommand(Prefix + "unbind")
|
||||
// .Description($"Unbinds a bot from the channel and board. **Bot Owner Only!**| `{Prefix}unbind`")
|
||||
// .Do(async e =>
|
||||
// {
|
||||
// if (!NadekoBot.IsOwner(e.User.Id)) return;
|
||||
// if (bound == null || bound != e.Channel) return;
|
||||
// t.Stop();
|
||||
// bound = null;
|
||||
// board = null;
|
||||
// await imsg.Channel.SendMessageAsync("Successfully unbound trello from this channel.").ConfigureAwait(false);
|
||||
|
||||
// });
|
||||
|
||||
// cgb.CreateCommand(Prefix + "lists")
|
||||
// .Alias(Prefix + "list")
|
||||
// .Description($"Lists all lists, yo ;) **Bot Owner Only!**| `{Prefix}list`")
|
||||
// .Do(async e =>
|
||||
// {
|
||||
// if (!NadekoBot.IsOwner(e.User.Id)) return;
|
||||
// if (bound == null || board == null || bound != e.Channel) return;
|
||||
// await imsg.Channel.SendMessageAsync("Lists for a board '" + board.Name + "'\n" + string.Join("\n", board.Lists.Select(l => "**• " + l.ToString() + "**")))
|
||||
// .ConfigureAwait(false);
|
||||
// });
|
||||
|
||||
// cgb.CreateCommand(Prefix + "cards")
|
||||
// .Description($"Lists all cards from the supplied list. You can supply either a name or an index. **Bot Owner Only!**| `{Prefix}cards index`")
|
||||
// .Parameter("list_name", Discord.Commands.ParameterType.Unparsed)
|
||||
// .Do(async e =>
|
||||
// {
|
||||
// if (!NadekoBot.IsOwner(e.User.Id)) return;
|
||||
// if (bound == null || board == null || bound != e.Channel || e.GetArg("list_name") == null) return;
|
||||
|
||||
// int num;
|
||||
// var success = int.TryParse(e.GetArg("list_name"), out num);
|
||||
// List list = null;
|
||||
// if (success && num <= board.Lists.Count() && num > 0)
|
||||
// list = board.Lists[num - 1];
|
||||
// else
|
||||
// list = board.Lists.FirstOrDefault(l => l.Name == e.GetArg("list_name"));
|
||||
|
||||
|
||||
// if (list != null)
|
||||
// await imsg.Channel.SendMessageAsync("There are " + list.Cards.Count() + " cards in a **" + list.Name + "** list\n" + string.Join("\n", list.Cards.Select(c => "**• " + c.ToString() + "**")))
|
||||
// .ConfigureAwait(false);
|
||||
// else
|
||||
// await imsg.Channel.SendMessageAsync("No such list.")
|
||||
// .ConfigureAwait(false);
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
//}
|
Reference in New Issue
Block a user