Merge remote-tracking branch 'refs/remotes/Kwoth/1.0' into math

# Conflicts:
#	src/NadekoBot/Modules/Searches/Searches.cs
This commit is contained in:
appelemac 2016-08-21 19:32:17 +02:00
commit 89a0eb93e6
55 changed files with 169 additions and 137 deletions

View File

@ -10,6 +10,7 @@ using System.Threading.Tasks;
using NadekoBot.Services;
using NadekoBot.Attributes;
using System.Text.RegularExpressions;
using Discord.WebSocket;
//todo fix delmsgoncmd
//todo DB
@ -18,7 +19,7 @@ namespace NadekoBot.Modules.Administration
[Module(".", AppendSpace = false)]
public partial class Administration : DiscordModule
{
public Administration(ILocalization loc, CommandService cmds, IBotConfiguration config, IDiscordClient client) : base(loc, cmds, config, client)
public Administration(ILocalization loc, CommandService cmds, IBotConfiguration config, DiscordSocketClient client) : base(loc, cmds, config, client)
{
}
@ -462,7 +463,7 @@ namespace NadekoBot.Modules.Administration
{
var channel = msg.Channel as ITextChannel;
int limit = (count < 100) ? count : 100;
var enumerable = (await msg.Channel.GetMessagesAsync(limit: limit));
var enumerable = (await msg.Channel.GetMessagesAsync(limit: limit)).Where(m => m.Author == user);
await msg.Channel.DeleteMessagesAsync(enumerable);
}
////todo owner only

View File

@ -4,7 +4,7 @@ using Discord.WebSocket;
using NadekoBot.Attributes;
using System.Threading.Tasks;
namespace NadekoBot.Modules.Administration.Commands
namespace NadekoBot.Modules.Administration
{
//todo DB
public partial class Administration
@ -12,8 +12,9 @@ namespace NadekoBot.Modules.Administration.Commands
[Group]
public class AutoAssignRole
{
public AutoAssignRole(DiscordSocketClient _client)
public AutoAssignRole()
{
var _client = NadekoBot.Client;
_client.UserJoined += (user) =>
{
//var config = SpecificConfigurations.Default.Of(e.Server.Id);

View File

@ -8,7 +8,7 @@
//using System.Linq;
////todo DB
//namespace NadekoBot.Modules.Administration.Commands
//namespace NadekoBot.Modules.Administration
//{
// class CrossServerTextChannel : DiscordCommand
// {

View File

@ -6,7 +6,7 @@
//using System.Linq;
////todo DB
//namespace NadekoBot.Modules.Administration.Commands
//namespace NadekoBot.Modules.Administration
//{
// internal class IncidentsCommands : DiscordCommand
// {

View File

@ -11,7 +11,7 @@
////todo DB
////todo Add flags for every event
//namespace NadekoBot.Modules.Administration.Commands
//namespace NadekoBot.Modules.Administration
//{
// internal class LogCommand : DiscordCommand
// {

View File

@ -8,7 +8,7 @@
//using System.Timers;
////todo DB
////todo persist restarts
//namespace NadekoBot.Modules.Administration.Commands
//namespace NadekoBot.Modules.Administration
//{
// class MessageRepeater : DiscordCommand
// {

View File

@ -13,7 +13,7 @@
//using Timer = System.Timers.Timer;
////todo DB
//namespace NadekoBot.Modules.Administration.Commands
//namespace NadekoBot.Modules.Administration
//{
// internal class PlayingRotate : DiscordCommand
// {

View File

@ -9,7 +9,7 @@ using System.Collections.Concurrent;
using System.Threading.Tasks;
//todo rewrite to accept msg/sec (for example 1/5 - 1 message every 5 seconds)
namespace NadekoBot.Modules.Administration.Commands
namespace NadekoBot.Modules.Administration
{
public partial class Administration
{
@ -21,16 +21,16 @@ namespace NadekoBot.Modules.Administration.Commands
private static readonly TimeSpan ratelimitTime = new TimeSpan(0, 0, 0, 5);
private DiscordSocketClient _client { get; }
public RatelimitCommand(DiscordSocketClient client)
public RatelimitCommand()
{
this._client = client;
this._client = NadekoBot.Client;
_client.MessageReceived += async (imsg) =>
{
var channel = imsg.Channel as ITextChannel;
if (channel == null || await imsg.IsAuthor(client))
if (channel == null || await imsg.IsAuthor(_client))
return;
ConcurrentDictionary<ulong, DateTime> userTimePair;
if (!RatelimitingChannels.TryGetValue(channel.Id, out userTimePair)) return;

View File

@ -8,7 +8,7 @@
//using System.Text;
//using System.Threading.Tasks;
////todo DB
//namespace NadekoBot.Modules.Administration.Commands
//namespace NadekoBot.Modules.Administration
//{
// internal class SelfAssignedRolesCommand : DiscordCommand
// {

View File

@ -6,7 +6,7 @@
//using System.Threading.Tasks;
////todo owner only
//namespace NadekoBot.Modules.Administration.Commands
//namespace NadekoBot.Modules.Administration
//{
// public partial class Administration
// {

View File

@ -7,7 +7,7 @@
//// todo DB
//// todo rewrite
//namespace NadekoBot.Modules.Administration.Commands
//namespace NadekoBot.Modules.Administration
//{
// internal class ServerGreetCommand : DiscordCommand
// {

View File

@ -11,7 +11,7 @@
////todo DB
////todo rewrite
//namespace NadekoBot.Modules.Administration.Commands
//namespace NadekoBot.Modules.Administration
//{
// internal class VoicePlusTextCommand : DiscordCommand
// {

View File

@ -8,6 +8,7 @@ using System.Threading.Tasks;
using Discord;
using NadekoBot.Services;
using NadekoBot.Attributes;
using Discord.WebSocket;
//todo DB
namespace NadekoBot.Modules.ClashOfClans
@ -17,7 +18,7 @@ namespace NadekoBot.Modules.ClashOfClans
{
public static ConcurrentDictionary<ulong, List<ClashWar>> ClashWars { get; set; } = new ConcurrentDictionary<ulong, List<ClashWar>>();
public ClashOfClans(ILocalization loc, CommandService cmds, IBotConfiguration config, IDiscordClient client) : base(loc, cmds, config, client)
public ClashOfClans(ILocalization loc, CommandService cmds, IBotConfiguration config, DiscordSocketClient client) : base(loc, cmds, config, client)
{
}

View File

@ -1,5 +1,6 @@
using Discord;
using Discord.Commands;
using Discord.WebSocket;
using NadekoBot.Services;
using NLog;
@ -10,10 +11,10 @@ namespace NadekoBot.Modules
protected ILocalization _l;
protected CommandService _commands;
protected IBotConfiguration _config;
protected IDiscordClient _client;
protected DiscordSocketClient _client;
protected Logger _log;
public DiscordModule(ILocalization loc, CommandService cmds, IBotConfiguration config,IDiscordClient client)
public DiscordModule(ILocalization loc, CommandService cmds, IBotConfiguration config, DiscordSocketClient client)
{
_l = loc;
_commands = cmds;

View File

@ -10,7 +10,7 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace NadekoBot.Modules.Gambling.Commands
namespace NadekoBot.Modules.Gambling
{
public partial class Gambling
{

View File

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq;
namespace NadekoBot.Modules.Gambling.Commands.Models
namespace NadekoBot.Modules.Gambling.Models
{
public class Cards
{

View File

@ -7,6 +7,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NadekoBot.Services;
using Discord.WebSocket;
//todo DB
namespace NadekoBot.Modules.Gambling
@ -14,7 +15,7 @@ namespace NadekoBot.Modules.Gambling
[Module("$", AppendSpace = false)]
public partial class Gambling : DiscordModule
{
public Gambling(ILocalization loc, CommandService cmds, IBotConfiguration config, IDiscordClient client) : base(loc, cmds, config, client)
public Gambling(ILocalization loc, CommandService cmds, IBotConfiguration config, DiscordSocketClient client) : base(loc, cmds, config, client)
{
}

View File

@ -8,7 +8,7 @@ using System.Threading.Tasks;
// taken from
// http://www.codeproject.com/Tips/207582/L-t-Tr-nsl-t-r-Leet-Translator (thanks)
// because i don't want to waste my time on this cancerous command
namespace NadekoBot.Modules.Games.Commands
namespace NadekoBot.Modules.Games
{
public partial class GamesModule
{

View File

@ -14,7 +14,7 @@
////todo DI into partials
////todo DB
//namespace NadekoBot.Modules.Games.Commands
//namespace NadekoBot.Modules.Games
//{
// /// <summary>
// /// Flower picking/planting idea is given to me by its

View File

@ -8,7 +8,7 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace NadekoBot.Modules.Games.Commands
namespace NadekoBot.Modules.Games
{
public partial class GamesModule
{

View File

@ -12,7 +12,7 @@
////todo DB
////todo Rewrite?
//namespace NadekoBot.Modules.Games.Commands
//namespace NadekoBot.Modules.Games
//{
// public static class SentencesProvider
// {

View File

@ -9,7 +9,7 @@ using System.Threading.Tasks;
// todo rewrite?
// todo DB
namespace NadekoBot.Modules.Games.Commands.Trivia
namespace NadekoBot.Modules.Games.Trivia
{
public class TriviaGame
{

View File

@ -5,7 +5,7 @@ using System.Linq;
using System.Text.RegularExpressions;
// THANKS @ShoMinamimoto for suggestions and coding help
namespace NadekoBot.Modules.Games.Commands.Trivia
namespace NadekoBot.Modules.Games.Trivia
{
public class TriviaQuestion
{

View File

@ -4,7 +4,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace NadekoBot.Modules.Games.Commands.Trivia
namespace NadekoBot.Modules.Games.Trivia
{
public class TriviaQuestionPool
{

View File

@ -1,14 +1,14 @@
using Discord;
using Discord.Commands;
using NadekoBot.Attributes;
using NadekoBot.Modules.Games.Commands.Trivia;
using NadekoBot.Modules.Games.Trivia;
using System;
using System.Collections.Concurrent;
using System.Linq;
using System.Threading.Tasks;
//todo Rewrite? Fix trivia not stopping bug
namespace NadekoBot.Modules.Games.Commands
namespace NadekoBot.Modules.Games
{
public partial class GamesModule
{

View File

@ -7,6 +7,7 @@ using System;
using System.Linq;
using System.Collections.Generic;
using NadekoBot.Extensions;
using Discord.WebSocket;
namespace NadekoBot.Modules.Games
{
@ -15,8 +16,9 @@ namespace NadekoBot.Modules.Games
{
//todo DB
private IEnumerable<string> _8BallResponses;
public Games(ILocalization loc, CommandService cmds, IBotConfiguration config, IDiscordClient client) : base(loc, cmds, config, client)
public Games(ILocalization loc, CommandService cmds, IBotConfiguration config, DiscordSocketClient client) : base(loc, cmds, config, client)
{
_8BallResponses = config.EightBallResponses;
}
[LocalizedCommand, LocalizedDescription, LocalizedSummary]

View File

@ -8,6 +8,7 @@ using NadekoBot.Attributes;
using System;
using System.IO;
using System.Text;
using Discord.WebSocket;
namespace NadekoBot.Modules.Help
{
@ -20,7 +21,7 @@ namespace NadekoBot.Modules.Help
return str + String.Format(str, NadekoBot.Credentials.ClientId);
}
}
public Help(ILocalization loc, CommandService cmds, IBotConfiguration config, IDiscordClient client) : base(loc, cmds, config, client)
public Help(ILocalization loc, CommandService cmds, IBotConfiguration config, DiscordSocketClient client) : base(loc, cmds, config, client)
{
}

View File

@ -10,13 +10,14 @@ using System.Net.Http;
using System.Text.RegularExpressions;
using System.Xml.Linq;
using System.Net;
using Discord.WebSocket;
namespace NadekoBot.Modules.NSFW
{
[Module("~", AppendSpace = false)]
public class NSFW : DiscordModule
{
public NSFW(ILocalization loc, CommandService cmds, IBotConfiguration config, IDiscordClient client) : base(loc, cmds, config, client)
public NSFW(ILocalization loc, CommandService cmds, IBotConfiguration config, DiscordSocketClient client) : base(loc, cmds, config, client)
{
}

View File

@ -3,13 +3,14 @@ using Discord;
using NadekoBot.Attributes;
using System.Threading.Tasks;
using NadekoBot.Services;
using Discord.WebSocket;
namespace NadekoBot.Modules.Games.Commands
namespace NadekoBot.Modules.Games
{
[Module(">", AppendSpace = false)]
public partial class Pokemon : DiscordModule
{
public Pokemon(ILocalization loc, CommandService cmds, IBotConfiguration config, IDiscordClient client) : base(loc, cmds, config, client)
public Pokemon(ILocalization loc, CommandService cmds, IBotConfiguration config, DiscordSocketClient client) : base(loc, cmds, config, client)
{
}

View File

@ -7,7 +7,7 @@
//using System.Threading.Tasks;
//// todo RestSharp
//namespace NadekoBot.Modules.Searches.Commands
//namespace NadekoBot.Modules.Searches
//{
// public partial class SearchesModule
// {

View File

@ -8,7 +8,7 @@
//using System.Threading.Tasks;
////todo Unit Conversion lib
//namespace NadekoBot.Modules.Searches.Commands
//namespace NadekoBot.Modules.Searches
//{
// class ConverterCommand : DiscordCommand
// {

View File

@ -6,7 +6,7 @@
//using System.Threading.Tasks;
//todo mathos parser replacement
//namespace NadekoBot.Modules.Searches.Commands
//namespace NadekoBot.Modules.Searches
//{
// class CalcCommand : DiscordCommand
// {

View File

@ -1,4 +1,4 @@
using NadekoBot.Modules.Searches.Commands.Models;
using NadekoBot.Modules.Searches.Models;
using System;
using System.Collections.Generic;
using System.Linq;
@ -17,7 +17,7 @@ using System.Threading.Tasks;
* Last Updated: Feb, 2016
*******************************************************************************/
namespace NadekoBot.Modules.Searches.Commands.IMDB
namespace NadekoBot.Modules.Searches.IMDB
{
public static class ImdbScraper
{
@ -49,7 +49,7 @@ namespace NadekoBot.Modules.Searches.Commands.IMDB
public static async Task<string> GetIMDBId(string MovieName)
{
string imdbUrl = await GetIMDbUrlAsync(System.Uri.EscapeUriString(MovieName));
return match(@"http://www.imdb.com/title/(tt\d{7})", imdbUrl);
return Match(@"http://www.imdb.com/title/(tt\d{7})", imdbUrl);
}
//Get IMDb URL from search results
private static async Task<string> GetIMDbUrlAsync(string MovieName)
@ -65,17 +65,17 @@ namespace NadekoBot.Modules.Searches.Commands.IMDB
private static async Task ParseIMDbPage(string imdbUrl, bool GetExtraInfo, ImdbMovie mov)
{
string html = await GetUrlDataAsync(imdbUrl + "combined");
mov.Id = match(@"<link rel=""canonical"" href=""http://www.imdb.com/title/(tt\d{7})/combined"" />", html);
mov.Id = Match(@"<link rel=""canonical"" href=""http://www.imdb.com/title/(tt\d{7})/combined"" />", html);
if (!string.IsNullOrEmpty(mov.Id))
{
mov.Status = true;
mov.Title = match(@"<title>(IMDb \- )*(.*?) \(.*?</title>", html, 2);
mov.OriginalTitle = match(@"title-extra"">(.*?)<", html);
mov.Year = match(@"<title>.*?\(.*?(\d{4}).*?).*?</title>", match(@"(<title>.*?</title>)", html));
mov.Rating = match(@"<b>(\d.\d)/10</b>", html);
mov.Genres = MatchAll(@"<a.*?>(.*?)</a>", match(@"Genre.?:(.*?)(</div>|See more)", html)).Cast<string>().ToList();
mov.Plot = match(@"Plot:</h5>.*?<div class=""info-content"">(.*?)(<a|</div)", html);
mov.Poster = match(@"<div class=""photo"">.*?<a name=""poster"".*?><img.*?src=""(.*?)"".*?</div>", html);
mov.Title = Match(@"<title>(IMDb \- )*(.*?) \(.*?</title>", html, 2);
mov.OriginalTitle = Match(@"title-extra"">(.*?)<", html);
mov.Year = Match(@"<title>.*?\(.*?(\d{4}).*?).*?</title>", Match(@"(<title>.*?</title>)", html));
mov.Rating = Match(@"<b>(\d.\d)/10</b>", html);
mov.Genres = MatchAll(@"<a.*?>(.*?)</a>", Match(@"Genre.?:(.*?)(</div>|See more)", html)).Cast<string>().ToList();
mov.Plot = Match(@"Plot:</h5>.*?<div class=""info-content"">(.*?)(<a|</div)", html);
mov.Poster = Match(@"<div class=""photo"">.*?<a name=""poster"".*?><img.*?src=""(.*?)"".*?</div>", html);
if (!string.IsNullOrEmpty(mov.Poster) && mov.Poster.IndexOf("media-imdb.com") > 0)
{
mov.Poster = Regex.Replace(mov.Poster, @"_V1.*?.jpg", "_V1._SY200.jpg");
@ -97,7 +97,7 @@ namespace NadekoBot.Modules.Searches.Commands.IMDB
{
Dictionary<string, string> release = new Dictionary<string, string>();
string releasehtml = await GetUrlDataAsync("http://www.imdb.com/title/" + mov.Id + "/releaseinfo");
foreach (string r in MatchAll(@"<tr class="".*?"">(.*?)</tr>", match(@"<table id=""release_dates"" class=""subpage_data spFirst"">\n*?(.*?)</table>", releasehtml)))
foreach (string r in MatchAll(@"<tr class="".*?"">(.*?)</tr>", Match(@"<table id=""release_dates"" class=""subpage_data spFirst"">\n*?(.*?)</table>", releasehtml)))
{
Match rd = new Regex(@"<td>(.*?)</td>\n*?.*?<td class=.*?>(.*?)</td>", RegexOptions.Multiline).Match(r);
release[StripHTML(rd.Groups[1].Value.Trim())] = StripHTML(rd.Groups[2].Value.Trim());
@ -105,7 +105,7 @@ namespace NadekoBot.Modules.Searches.Commands.IMDB
//mov.ReleaseDates = release;
Dictionary<string, string> aka = new Dictionary<string, string>();
List<string> list = MatchAll(@".*?<tr class="".*?"">(.*?)</tr>", match(@"<table id=""akas"" class=.*?>\n*?(.*?)</table>", releasehtml));
List<string> list = MatchAll(@".*?<tr class="".*?"">(.*?)</tr>", Match(@"<table id=""akas"" class=.*?>\n*?(.*?)</table>", releasehtml));
foreach (string r in list)
{
Match rd = new Regex(@"\n*?.*?<td>(.*?)</td>\n*?.*?<td>(.*?)</td>", RegexOptions.Multiline).Match(r);
@ -122,11 +122,11 @@ namespace NadekoBot.Modules.Searches.Commands.IMDB
List<string> list = new List<string>();
string mediaurl = "http://www.imdb.com/title/" + mov.Id + "/mediaindex";
string mediahtml = await GetUrlDataAsync(mediaurl);
int pagecount = MatchAll(@"<a href=""\?page=(.*?)"">", match(@"<span style=""padding: 0 1em;"">(.*?)</span>", mediahtml)).Count;
int pagecount = MatchAll(@"<a href=""\?page=(.*?)"">", Match(@"<span style=""padding: 0 1em;"">(.*?)</span>", mediahtml)).Count;
for (int p = 1; p <= pagecount + 1; p++)
{
mediahtml = await GetUrlDataAsync(mediaurl + "?page=" + p);
foreach (Match m in new Regex(@"src=""(.*?)""", RegexOptions.Multiline).Matches(match(@"<div class=""thumb_list"" style=""font-size: 0px;"">(.*?)</div>", mediahtml)))
foreach (Match m in new Regex(@"src=""(.*?)""", RegexOptions.Multiline).Matches(Match(@"<div class=""thumb_list"" style=""font-size: 0px;"">(.*?)</div>", mediahtml)))
{
String image = m.Groups[1].Value;
list.Add(Regex.Replace(image, @"_V1\..*?.jpg", "_V1._SY0.jpg"));
@ -147,7 +147,7 @@ namespace NadekoBot.Modules.Searches.Commands.IMDB
}
/*******************************[ Helper Methods ]********************************/
//Match single instance
private static string match(string regex, string html, int i = 1)
private static string Match(string regex, string html, int i = 1)
{
return new Regex(regex, RegexOptions.Multiline).Match(html).Groups[i].Value.Trim();
}

View File

@ -1,9 +1,10 @@
using Discord;
using Discord.Commands;
using NadekoBot.Attributes;
using NadekoBot.Modules.Searches.Commands.Models;
using NadekoBot.Modules.Searches.Models;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NLog;
using System;
using System.Collections.Generic;
using System.IO;
@ -11,21 +12,34 @@ using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
namespace NadekoBot.Modules.Searches.Commands
namespace NadekoBot.Modules.Searches
{
public partial class SearchesModule
public partial class Searches
{
[Group]
public class JokeCommands
{
//todo DB
private List<WoWJoke> wowJokes;
private List<WoWJoke> wowJokes = new List<WoWJoke>();
private List<MagicItem> magicItems;
private Logger _log;
public JokeCommands()
{
wowJokes = JsonConvert.DeserializeObject<List<WoWJoke>>(File.ReadAllText("data/wowjokes.json"));
magicItems = JsonConvert.DeserializeObject<List<MagicItem>>(File.ReadAllText("data/magicitems.json"));
_log = LogManager.GetCurrentClassLogger();
if (File.Exists("data/wowjokes.json"))
{
wowJokes = JsonConvert.DeserializeObject<List<WoWJoke>>(File.ReadAllText("data/wowjokes.json"));
}
else
_log.Warn("data/wowjokes.json is missing. WOW Jokes are not loaded.");
if (File.Exists("data/magicitems.json"))
{
magicItems = JsonConvert.DeserializeObject<List<MagicItem>>(File.ReadAllText("data/magicitems.json"));
}
else
_log.Warn("data/magicitems.json is missing. Magic items are not loaded.");
}
[LocalizedCommand, LocalizedDescription, LocalizedSummary]

View File

@ -11,7 +11,7 @@ using System.Text;
using System.Threading.Tasks;
//todo drawing
namespace NadekoBot.Modules.Searches.Commands
namespace NadekoBot.Modules.Searches
{
public partial class Searches
{

View File

@ -11,14 +11,10 @@ using NadekoBot.Attributes;
using System.Net.Http;
using NadekoBot.Extensions;
namespace NadekoBot.Modules.Searches.Commands
namespace NadekoBot.Modules.Searches
{
public partial class SearchesModule : DiscordModule
public partial class Searches
{
public SearchesModule(ILocalization loc, CommandService cmds, IBotConfiguration config, IDiscordClient client) : base(loc, cmds, config, client)
{
}
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
[RequireContext(ContextType.Guild)]
public async Task Memelist(IMessage imsg)

View File

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Net;
namespace NadekoBot.Modules.Searches.Commands.Models
namespace NadekoBot.Modules.Searches.Models
{
public class ImdbMovie
{

View File

@ -1,4 +1,4 @@
namespace NadekoBot.Modules.Searches.Commands.Models
namespace NadekoBot.Modules.Searches.Models
{
class MagicItem
{

View File

@ -1,6 +1,6 @@
using System.Collections.Generic;
namespace NadekoBot.Modules.Searches.Commands.Models
namespace NadekoBot.Modules.Searches.Models
{
public class SearchPokemon
{

View File

@ -1,4 +1,4 @@
namespace NadekoBot.Modules.Searches.Commands.Models
namespace NadekoBot.Modules.Searches.Models
{
public class WikipediaApiModel
{

View File

@ -1,4 +1,4 @@
namespace NadekoBot.Modules.Searches.Commands.Models
namespace NadekoBot.Modules.Searches.Models
{
public class WoWJoke
{

View File

@ -7,7 +7,7 @@
//using System.Text.RegularExpressions;
//todo DI into partials
//namespace NadekoBot.Modules.Searches.Commands
//namespace NadekoBot.Modules.Searches
//{
// internal class OsuCommands : DiscordCommand
// {

View File

@ -1,15 +1,16 @@
using Discord;
using Discord.Commands;
using NadekoBot.Attributes;
using NadekoBot.Modules.Searches.Commands.Models;
using NadekoBot.Modules.Searches.Models;
using Newtonsoft.Json;
using NLog;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
namespace NadekoBot.Modules.Searches.Commands
namespace NadekoBot.Modules.Searches
{
public partial class SearchesModule : DiscordModule
public partial class Searches
{
[Group]
public class PokemonSearchCommands
@ -21,12 +22,21 @@ namespace NadekoBot.Modules.Searches.Commands
public const string PokemonAbilitiesFile = "data/pokemon/pokemon_abilities.json";
public const string PokemonListFile = "data/pokemon/pokemon_list.json";
private Logger _log;
public PokemonSearchCommands()
{
if(File.Exists(PokemonListFile))
pokemons = JsonConvert.DeserializeObject<Dictionary<string, SearchPokemon>>(File.ReadAllText(PokemonListFile));
pokemonAbilities = JsonConvert.DeserializeObject<Dictionary<string, SearchPokemonAbility>>(File.ReadAllText(PokemonAbilitiesFile));
_log = LogManager.GetCurrentClassLogger();
if (File.Exists(PokemonListFile))
{
pokemons = JsonConvert.DeserializeObject<Dictionary<string, SearchPokemon>>(File.ReadAllText(PokemonListFile));
}
else
_log.Warn(PokemonListFile + " is missing. Pokemon abilities not loaded.");
if (File.Exists(PokemonAbilitiesFile))
pokemonAbilities = JsonConvert.DeserializeObject<Dictionary<string, SearchPokemonAbility>>(File.ReadAllText(PokemonAbilitiesFile));
else
_log.Warn(PokemonAbilitiesFile + " is missing. Pokemon abilities not loaded.");
}
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
@ -71,4 +81,4 @@ namespace NadekoBot.Modules.Searches.Commands
}
}
}
}
}

View File

@ -10,9 +10,9 @@
//using System.Threading;
//todo DB
//namespace NadekoBot.Modules.Searches.Commands
//namespace NadekoBot.Modules.Searches
//{
// public partial class SearchesModule : DiscordModule
// public partial class Searches
// {
// [Group]
// public class StreamNotificationCommands
@ -72,7 +72,7 @@
// }, null, TimeSpan.Zero, TimeSpan.FromSeconds(15));
// }
// public StreamNotifications(ILocalization loc, CommandService cmds, IBotConfiguration config, IDiscordClient client) : base(loc, cmds, config, client)
// public StreamNotifications(ILocalization loc, CommandService cmds, IBotConfiguration config, DiscordSocketClient client) : base(loc, cmds, config, client)
// {
// }

View File

@ -1,6 +1,5 @@
using Discord;
using Discord.Commands;
using NadekoBot.Modules.Searches.Commands.IMDB;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
@ -12,8 +11,9 @@ using NadekoBot.Attributes;
using NadekoBot.Extensions;
using System.Text.RegularExpressions;
using System.Net;
using NadekoBot.Modules.Searches.Commands.Models;
using NCalc;
using Discord.WebSocket;
using NadekoBot.Modules.Searches.Models;
using NadekoBot.Modules.Searches.IMDB;
namespace NadekoBot.Modules.Searches
{
@ -22,19 +22,10 @@ namespace NadekoBot.Modules.Searches
{
private IYoutubeService _yt { get; }
public Searches(ILocalization loc, CommandService cmds, IBotConfiguration config, IDiscordClient client, IYoutubeService youtube) : base(loc, cmds, config, client)
public Searches(ILocalization loc, CommandService cmds, IBotConfiguration config, DiscordSocketClient client, IYoutubeService youtube) : base(loc, cmds, config, client)
{
_yt = youtube;
}
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
[RequireContext(ContextType.Guild)]
public async Task Calc(IMessage msg, [Remainder] string calculation)
{
var channel = msg.Channel as ITextChannel;
}
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
[RequireContext(ContextType.Guild)]
public async Task Weather(IMessage imsg, string city, string country)
@ -257,7 +248,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
[RequireContext(ContextType.Guild)]
public async Task UrbanDictionary(IMessage imsg, [Remainder] string query = null)
public async Task Ud(IMessage imsg, [Remainder] string query = null)
{
var channel = imsg.Channel as ITextChannel;

View File

@ -5,13 +5,14 @@ using NadekoBot.Extensions;
using System;
using System.Threading.Tasks;
using NadekoBot.Services;
using Discord.WebSocket;
namespace NadekoBot.Modules.Translator
{
[Module("~", AppendSpace = false)]
public class Translator : DiscordModule
{
public Translator(ILocalization loc, CommandService cmds, IBotConfiguration config, IDiscordClient client) : base(loc, cmds, config, client)
public Translator(ILocalization loc, CommandService cmds, IBotConfiguration config, DiscordSocketClient client) : base(loc, cmds, config, client)
{
}

View File

@ -9,7 +9,7 @@
//using System.Text.RegularExpressions;
//using System.Timers;
//namespace NadekoBot.Modules.Utility.Commands
//namespace NadekoBot.Modules.Utility
//{
// class Remind : DiscordCommand
// {

View File

@ -10,6 +10,7 @@ using NadekoBot.Extensions;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Reflection;
using Discord.WebSocket;
namespace NadekoBot.Modules.Utility
{
@ -17,7 +18,7 @@ namespace NadekoBot.Modules.Utility
[Module(".", AppendSpace = false)]
public partial class Utility : DiscordModule
{
public Utility(ILocalization loc, CommandService cmds, IBotConfiguration config, IDiscordClient client) : base(loc, cmds, config, client)
public Utility(ILocalization loc, CommandService cmds, IBotConfiguration config, DiscordSocketClient client) : base(loc, cmds, config, client)
{
}

View File

@ -52,7 +52,7 @@ namespace NadekoBot
var depMap = new DependencyMap();
depMap.Add<ILocalization>(Localizer);
depMap.Add<IBotConfiguration>(Config);
depMap.Add<IDiscordClient>(Client);
depMap.Add<DiscordSocketClient>(Client);
depMap.Add<CommandService>(Commands);
depMap.Add<IYoutubeService>(Youtube);

View File

@ -575,27 +575,27 @@ namespace NadekoBot.Resources {
/// <summary>
/// Looks up a localized string similar to Shows a mentioned person&apos;s avatar..
/// </summary>
public static string av_desc {
public static string avatar_desc {
get {
return ResourceManager.GetString("av_desc", resourceCulture);
return ResourceManager.GetString("avatar_desc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to `~av &quot;@SomeGuy&quot;`.
/// </summary>
public static string av_summary {
public static string avatar_summary {
get {
return ResourceManager.GetString("av_summary", resourceCulture);
return ResourceManager.GetString("avatar_summary", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to av.
/// </summary>
public static string av_text {
public static string avatar_text {
get {
return ResourceManager.GetString("av_text", resourceCulture);
return ResourceManager.GetString("avatar_text", resourceCulture);
}
}
@ -7406,27 +7406,27 @@ namespace NadekoBot.Resources {
/// <summary>
/// Looks up a localized string similar to Shows weather data for a specified city and a country. BOTH ARE REQUIRED. Use country abbrevations..
/// </summary>
public static string we_desc {
public static string weather_desc {
get {
return ResourceManager.GetString("we_desc", resourceCulture);
return ResourceManager.GetString("weather_desc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to `~we Moscow RF`.
/// </summary>
public static string we_summary {
public static string weather_summary {
get {
return ResourceManager.GetString("we_summary", resourceCulture);
return ResourceManager.GetString("weather_summary", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to we.
/// </summary>
public static string we_text {
public static string weather_text {
get {
return ResourceManager.GetString("we_text", resourceCulture);
return ResourceManager.GetString("weather_text", resourceCulture);
}
}
@ -7541,27 +7541,27 @@ namespace NadekoBot.Resources {
/// <summary>
/// Looks up a localized string similar to Searches youtubes and shows the first result.
/// </summary>
public static string yt_desc {
public static string youtube_desc {
get {
return ResourceManager.GetString("yt_desc", resourceCulture);
return ResourceManager.GetString("youtube_desc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to `~yt query`.
/// </summary>
public static string yt_summary {
public static string youtube_summary {
get {
return ResourceManager.GetString("yt_summary", resourceCulture);
return ResourceManager.GetString("youtube_summary", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to yt.
/// </summary>
public static string yt_text {
public static string youtube_text {
get {
return ResourceManager.GetString("yt_text", resourceCulture);
return ResourceManager.GetString("youtube_text", resourceCulture);
}
}
}

View File

@ -2115,22 +2115,22 @@
<data name="memegen_summary" xml:space="preserve">
<value>`~memegen biw "gets iced coffee" "in the winter"`</value>
</data>
<data name="we_text" xml:space="preserve">
<data name="weather_text" xml:space="preserve">
<value>we</value>
</data>
<data name="we_desc" xml:space="preserve">
<data name="weather_desc" xml:space="preserve">
<value>Shows weather data for a specified city and a country. BOTH ARE REQUIRED. Use country abbrevations.</value>
</data>
<data name="we_summary" xml:space="preserve">
<data name="weather_summary" xml:space="preserve">
<value>`~we Moscow RF`</value>
</data>
<data name="yt_text" xml:space="preserve">
<data name="youtube_text" xml:space="preserve">
<value>yt</value>
</data>
<data name="yt_desc" xml:space="preserve">
<data name="youtube_desc" xml:space="preserve">
<value>Searches youtubes and shows the first result</value>
</data>
<data name="yt_summary" xml:space="preserve">
<data name="youtube_summary" xml:space="preserve">
<value>`~yt query`</value>
</data>
<data name="ani_text" xml:space="preserve">
@ -2349,13 +2349,13 @@
<data name="videocall_summary" xml:space="preserve">
<value>`~videocall "@SomeGuy"`</value>
</data>
<data name="av_text" xml:space="preserve">
<data name="avatar_text" xml:space="preserve">
<value>av</value>
</data>
<data name="av_desc" xml:space="preserve">
<data name="avatar_desc" xml:space="preserve">
<value>Shows a mentioned person's avatar.</value>
</data>
<data name="av_summary" xml:space="preserve">
<data name="avatar_summary" xml:space="preserve">
<value>`~av "@SomeGuy"`</value>
</data>
<data name="hentai_text" xml:space="preserve">

View File

@ -4,12 +4,15 @@ using System.Collections.Generic;
using System.IO;
using Discord;
using System.Linq;
using NLog;
namespace NadekoBot.Services.Impl
{
//todo load creds
public class BotCredentials : IBotCredentials
{
private Logger _log;
public string ClientId { get; }
public string GoogleApiKey { get; }
@ -24,10 +27,16 @@ namespace NadekoBot.Services.Impl
public BotCredentials()
{
var cm = JsonConvert.DeserializeObject<CredentialsModel>(File.ReadAllText("./credentials.json"));
Token = cm.Token;
OwnerIds = cm.OwnerIds;
LoLApiKey = cm.LoLApiKey;
_log = LogManager.GetCurrentClassLogger();
if (File.Exists("./credentials.json"))
{
var cm = JsonConvert.DeserializeObject<CredentialsModel>(File.ReadAllText("./credentials.json"));
Token = cm.Token;
OwnerIds = cm.OwnerIds;
LoLApiKey = cm.LoLApiKey;
}
else
_log.Fatal("credentials.json is missing. Failed to start.");
}
private class CredentialsModel {

View File

@ -5,7 +5,7 @@ using NadekoBot.Modules.Permissions.Classes;
using System;
using System.Text.RegularExpressions;
namespace NadekoBot.Modules.Permissions.Commands
namespace NadekoBot.Modules.Permissions
{
internal class FilterInvitesCommand : DiscordCommand
{

View File

@ -5,7 +5,7 @@ using NadekoBot.Modules.Permissions.Classes;
using System;
using System.Linq;
namespace NadekoBot.Modules.Permissions.Commands
namespace NadekoBot.Modules.Permissions
{
internal class FilterWords : DiscordCommand
{

View File

@ -1,6 +1,6 @@
{
"version": "1.0.0-*",
"description": "General purposee Discord bot written in C#.",
"description": "General purpose Discord bot written in C#.",
"authors": [ "Kwoth" ],
"copyright": "Kwoth",
"buildOptions": {