Merge remote-tracking branch 'Kwoth/dev' into dev

This commit is contained in:
Shikhir Arora 2017-03-02 01:47:53 -05:00
commit 4dda0a24d7
27 changed files with 16848 additions and 407 deletions

View File

@ -452,7 +452,6 @@ namespace NadekoBot.Modules.Administration
{ {
if (count < 1) if (count < 1)
return; return;
count += 1;
await Context.Message.DeleteAsync().ConfigureAwait(false); await Context.Message.DeleteAsync().ConfigureAwait(false);
int limit = (count < 100) ? count : 100; int limit = (count < 100) ? count : 100;
var enumerable = (await Context.Channel.GetMessagesAsync(limit: limit).Flatten().ConfigureAwait(false)); var enumerable = (await Context.Channel.GetMessagesAsync(limit: limit).Flatten().ConfigureAwait(false));

View File

@ -18,8 +18,14 @@ namespace NadekoBot.Modules.Administration
{ {
private ImmutableDictionary<string, string> supportedLocales { get; } = new Dictionary<string, string>() private ImmutableDictionary<string, string> supportedLocales { get; } = new Dictionary<string, string>()
{ {
{"en-US", "English, United States" }, {"en-US", "English, United States"},
{"sr-cyrl-rs", "Serbian, Cyrillic" } {"fr-FR", "French, France"},
{"ru-RU", "Russian, Russia"},
{"de-DE", "German, Germany"},
//{"nl-NL", "Dutch, Netherlands"},
//{"ja-JP", "Japanese, Japan"},
{"pt-BR", "Portuguese, Brazil"},
//{"sr-Cyrl-RS", "Serbian, Serbia - Cyrillic"}
}.ToImmutableDictionary(); }.ToImmutableDictionary();
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -94,9 +100,10 @@ namespace NadekoBot.Modules.Administration
[OwnerOnly] [OwnerOnly]
public async Task LanguagesList() public async Task LanguagesList()
{ {
await ReplyConfirmLocalized("lang_list", await Context.Channel.EmbedAsync(new EmbedBuilder().WithOkColor()
string.Join("\n", supportedLocales.Select(x => $"{Format.Code(x.Key)} => {x.Value}"))) .WithTitle(GetText("lang_list", ""))
.ConfigureAwait(false); .WithDescription(string.Join("\n",
supportedLocales.Select(x => $"{Format.Code(x.Key), -10} => {x.Value}"))));
} }
} }
} }

View File

@ -529,7 +529,7 @@ namespace NadekoBot.Modules.Administration
else if (afterVch == null) else if (afterVch == null)
{ {
str = "🎙" + Format.Code(prettyCurrentTime) + logChannel.Guild.GetLogText("user_vleft", str = "🎙" + Format.Code(prettyCurrentTime) + logChannel.Guild.GetLogText("user_vleft",
"👤" + Format.Code(prettyCurrentTime), "👤" + Format.Bold(usr.Username + "#" + usr.Discriminator), "👤" + Format.Bold(usr.Username + "#" + usr.Discriminator),
Format.Bold(beforeVch.Name ?? "")); Format.Bold(beforeVch.Name ?? ""));
} }
if (str != null) if (str != null)

View File

@ -11,15 +11,13 @@ using NadekoBot.Services.Database.Models;
using System.Linq; using System.Linq;
using NadekoBot.Extensions; using NadekoBot.Extensions;
using System.Threading; using System.Threading;
using System.Diagnostics;
using NLog;
namespace NadekoBot.Modules.ClashOfClans namespace NadekoBot.Modules.ClashOfClans
{ {
[NadekoModule("ClashOfClans", ",")] [NadekoModule("ClashOfClans", ",")]
public class ClashOfClans : NadekoTopLevelModule public class ClashOfClans : NadekoTopLevelModule
{ {
public static ConcurrentDictionary<ulong, List<ClashWar>> ClashWars { get; set; } = new ConcurrentDictionary<ulong, List<ClashWar>>(); public static ConcurrentDictionary<ulong, List<ClashWar>> ClashWars { get; set; }
private static Timer checkWarTimer { get; } private static Timer checkWarTimer { get; }
@ -82,11 +80,9 @@ namespace NadekoBot.Modules.ClashOfClans
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[RequireUserPermission(GuildPermission.ManageMessages)]
public async Task CreateWar(int size, [Remainder] string enemyClan = null) public async Task CreateWar(int size, [Remainder] string enemyClan = null)
{ {
if (!(Context.User as IGuildUser).GuildPermissions.ManageChannels)
return;
if (string.IsNullOrWhiteSpace(enemyClan)) if (string.IsNullOrWhiteSpace(enemyClan))
return; return;

View File

@ -110,7 +110,7 @@ namespace NadekoBot.Modules.Gambling
{ {
var toWin = (int)Math.Round(amount * NadekoBot.BotConfig.BetflipMultiplier); var toWin = (int)Math.Round(amount * NadekoBot.BotConfig.BetflipMultiplier);
str = Context.User.Mention + " " + GetText("flip_guess", toWin + CurrencySign); str = Context.User.Mention + " " + GetText("flip_guess", toWin + CurrencySign);
await CurrencyHandler.AddCurrencyAsync(Context.User, GetText("betflip_gamble"), toWin, false).ConfigureAwait(false); await CurrencyHandler.AddCurrencyAsync(Context.User, "Betflip Gamble", toWin, false).ConfigureAwait(false);
} }
else else
{ {

View File

@ -276,7 +276,7 @@ $@"--
{ {
if (!_votes.Any()) if (!_votes.Any())
{ {
await _channel.SendErrorAsync(GetText("acrophobia"), GetText("no_votes_cast")).ConfigureAwait(false); await _channel.SendErrorAsync(GetText("acrophobia"), GetText("acro_no_votes_cast")).ConfigureAwait(false);
return; return;
} }
var table = _votes.OrderByDescending(v => v.Value); var table = _votes.OrderByDescending(v => v.Value);

View File

@ -201,7 +201,7 @@ namespace NadekoBot.Modules.Games.Trivia
return; return;
} }
await Channel.SendConfirmAsync(GetText("trivia_game"), await Channel.SendConfirmAsync(GetText("trivia_game"),
GetText("guess", guildUser.Mention, Format.Bold(CurrentQuestion.Answer))).ConfigureAwait(false); GetText("trivia_guess", guildUser.Mention, Format.Bold(CurrentQuestion.Answer))).ConfigureAwait(false);
} }
catch (Exception ex) { _log.Warn(ex); } catch (Exception ex) { _log.Warn(ex); }

View File

@ -270,11 +270,6 @@ namespace NadekoBot.Modules.Music.Classes
//aidiakapi ftw //aidiakapi ftw
public static unsafe byte[] AdjustVolume(byte[] audioSamples, float volume) public static unsafe byte[] AdjustVolume(byte[] audioSamples, float volume)
{ {
Contract.Requires(audioSamples != null);
Contract.Requires(audioSamples.Length % 2 == 0);
Contract.Requires(volume >= 0f && volume <= 1f);
Contract.Assert(BitConverter.IsLittleEndian);
if (Math.Abs(volume - 1f) < 0.0001f) return audioSamples; if (Math.Abs(volume - 1f) < 0.0001f) return audioSamples;
// 16-bit precision for the multiplication // 16-bit precision for the multiplication

View File

@ -301,7 +301,7 @@ namespace NadekoBot.Modules.Music
uow.GuildConfigs.For(Context.Guild.Id, set => set).DefaultMusicVolume = val / 100.0f; uow.GuildConfigs.For(Context.Guild.Id, set => set).DefaultMusicVolume = val / 100.0f;
uow.Complete(); uow.Complete();
} }
await ReplyConfirmLocalized("defvol_set").ConfigureAwait(false); await ReplyConfirmLocalized("defvol_set", val).ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -592,7 +592,7 @@ namespace NadekoBot.Modules.Music
if (seconds == 0) if (seconds == 0)
await ReplyConfirmLocalized("max_playtime_none").ConfigureAwait(false); await ReplyConfirmLocalized("max_playtime_none").ConfigureAwait(false);
else else
await ReplyConfirmLocalized("max_playtime_set").ConfigureAwait(false); await ReplyConfirmLocalized("max_playtime_set", seconds).ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -690,7 +690,7 @@ namespace NadekoBot.Modules.Music
return; return;
} }
IUserMessage msg = null; IUserMessage msg = null;
try { msg = await ReplyConfirmLocalized("attempting_to_queue", Format.Bold(mpl.Songs.Count.ToString())).ConfigureAwait(false); } catch (Exception ex) { _log.Warn(ex); } try { msg = await Context.Channel.SendMessageAsync(GetText("attempting_to_queue", Format.Bold(mpl.Songs.Count.ToString()))).ConfigureAwait(false); } catch (Exception ex) { _log.Warn(ex); }
foreach (var item in mpl.Songs) foreach (var item in mpl.Songs)
{ {
var usr = (IGuildUser)Context.User; var usr = (IGuildUser)Context.User;
@ -818,7 +818,7 @@ namespace NadekoBot.Modules.Music
MusicPlayer musicPlayer; MusicPlayer musicPlayer;
if (!MusicPlayers.TryGetValue(Context.Guild.Id, out musicPlayer)) if (!MusicPlayers.TryGetValue(Context.Guild.Id, out musicPlayer))
{ {
await ReplyErrorLocalized("player_none").ConfigureAwait(false); await ReplyErrorLocalized("no_player").ConfigureAwait(false);
return; return;
} }

View File

@ -69,7 +69,7 @@ namespace NadekoBot.Modules
LogManager.GetCurrentClassLogger().Warn(lowerModuleTypeName + "_" + key + " key is missing from " + cultureInfo + " response strings. PLEASE REPORT THIS."); LogManager.GetCurrentClassLogger().Warn(lowerModuleTypeName + "_" + key + " key is missing from " + cultureInfo + " response strings. PLEASE REPORT THIS.");
text = NadekoBot.ResponsesResourceManager.GetString(lowerModuleTypeName + "_" + key, _usCultureInfo) ?? $"Error: dkey {lowerModuleTypeName + "_" + key} not found!"; text = NadekoBot.ResponsesResourceManager.GetString(lowerModuleTypeName + "_" + key, _usCultureInfo) ?? $"Error: dkey {lowerModuleTypeName + "_" + key} not found!";
if (string.IsNullOrWhiteSpace(text)) if (string.IsNullOrWhiteSpace(text))
return "I cant tell if you command is executed, because there was an error printing out the response. Key '" + return "I can't tell you is the command executed, because there was an error printing out the response. Key '" +
lowerModuleTypeName + "_" + key + "' " + "is missing from resources. Please report this."; lowerModuleTypeName + "_" + key + "' " + "is missing from resources. Please report this.";
} }
return text; return text;

View File

@ -30,17 +30,19 @@ namespace NadekoBot.Modules.Searches
{ {
try try
{ {
var headers = new Dictionary<string, string> { var headers = new Dictionary<string, string>
{"grant_type", "client_credentials"}, {
{"client_id", "kwoth-w0ki9"}, {"grant_type", "client_credentials"},
{"client_secret", "Qd6j4FIAi1ZK6Pc7N7V4Z"}, {"client_id", "kwoth-w0ki9"},
}; {"client_secret", "Qd6j4FIAi1ZK6Pc7N7V4Z"},
};
using (var http = new HttpClient()) using (var http = new HttpClient())
{ {
http.AddFakeHeaders(); //http.AddFakeHeaders();
http.DefaultRequestHeaders.Clear();
var formContent = new FormUrlEncodedContent(headers); var formContent = new FormUrlEncodedContent(headers);
var response = await http.PostAsync("http://anilist.co/api/auth/access_token", formContent).ConfigureAwait(false); var response = await http.PostAsync("https://anilist.co/api/auth/access_token", formContent).ConfigureAwait(false);
var stringContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false); var stringContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
anilistToken = JObject.Parse(stringContent)["access_token"].ToString(); anilistToken = JObject.Parse(stringContent)["access_token"].ToString();
} }

View File

@ -9,11 +9,11 @@ using NadekoBot.Services.Database.Models;
using NLog; using NLog;
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Discord.WebSocket;
namespace NadekoBot.Modules.Utility namespace NadekoBot.Modules.Utility
{ {
@ -34,24 +34,18 @@ namespace NadekoBot.Modules.Utility
private CancellationTokenSource source { get; set; } private CancellationTokenSource source { get; set; }
private CancellationToken token { get; set; } private CancellationToken token { get; set; }
public Repeater Repeater { get; } public Repeater Repeater { get; }
public ITextChannel Channel { get; } public SocketGuild Guild { get; }
public ITextChannel Channel { get; private set; }
public RepeatRunner(Repeater repeater, ITextChannel channel = null) public RepeatRunner(Repeater repeater, ITextChannel channel = null)
{ {
_log = LogManager.GetCurrentClassLogger(); _log = LogManager.GetCurrentClassLogger();
Repeater = repeater; Repeater = repeater;
//if (channel == null) Channel = channel;
//{
// var guild = NadekoBot.Client.GetGuild(repeater.GuildId);
// Channel = guild.GetTextChannel(repeater.ChannelId);
//}
//else
// Channel = channel;
Channel = channel ?? NadekoBot.Client.GetGuild(repeater.GuildId)?.GetTextChannel(repeater.ChannelId); Guild = NadekoBot.Client.GetGuild(repeater.GuildId);
if (Channel == null) if(Guild!=null)
return; Task.Run(Run);
Task.Run(Run);
} }
@ -72,10 +66,21 @@ namespace NadekoBot.Modules.Utility
// continue; // continue;
if (oldMsg != null) if (oldMsg != null)
try { await oldMsg.DeleteAsync(); } catch { } try
{
await oldMsg.DeleteAsync();
}
catch
{
// ignored
}
try try
{ {
oldMsg = await Channel.SendMessageAsync(toSend).ConfigureAwait(false); if (Channel == null)
Channel = Guild.GetTextChannel(Repeater.ChannelId);
if (Channel != null)
oldMsg = await Channel.SendMessageAsync(toSend).ConfigureAwait(false);
} }
catch (HttpException ex) when (ex.HttpCode == System.Net.HttpStatusCode.Forbidden) catch (HttpException ex) when (ex.HttpCode == System.Net.HttpStatusCode.Forbidden)
{ {
@ -93,7 +98,9 @@ namespace NadekoBot.Modules.Utility
} }
} }
} }
catch (OperationCanceledException) { } catch (OperationCanceledException)
{
}
} }
public void Reset() public void Reset()
@ -109,7 +116,8 @@ namespace NadekoBot.Modules.Utility
public override string ToString() public override string ToString()
{ {
return $"{Channel.Mention} | {(int)Repeater.Interval.TotalHours}:{Repeater.Interval:mm} | {Repeater.Message.TrimTo(33)}"; return
$"{Channel.Mention} | {(int) Repeater.Interval.TotalHours}:{Repeater.Interval:mm} | {Repeater.Message.TrimTo(33)}";
} }
} }
@ -120,8 +128,9 @@ namespace NadekoBot.Modules.Utility
await Task.Delay(5000).ConfigureAwait(false); await Task.Delay(5000).ConfigureAwait(false);
Repeaters = new ConcurrentDictionary<ulong, ConcurrentQueue<RepeatRunner>>(NadekoBot.AllGuildConfigs Repeaters = new ConcurrentDictionary<ulong, ConcurrentQueue<RepeatRunner>>(NadekoBot.AllGuildConfigs
.ToDictionary(gc => gc.GuildId, .ToDictionary(gc => gc.GuildId,
gc => new ConcurrentQueue<RepeatRunner>(gc.GuildRepeaters.Select(gr => new RepeatRunner(gr)) gc => new ConcurrentQueue<RepeatRunner>(gc.GuildRepeaters
.Where(gr => gr.Channel != null)))); .Select(gr => new RepeatRunner(gr))
.Where(x => x.Guild != null))));
_ready = true; _ready = true;
}); });
} }
@ -192,7 +201,7 @@ namespace NadekoBot.Modules.Utility
if (Repeaters.TryUpdate(Context.Guild.Id, new ConcurrentQueue<RepeatRunner>(repeaterList), rep)) if (Repeaters.TryUpdate(Context.Guild.Id, new ConcurrentQueue<RepeatRunner>(repeaterList), rep))
await Context.Channel.SendConfirmAsync(GetText("message_repeater"), await Context.Channel.SendConfirmAsync(GetText("message_repeater"),
GetText("repeater_stopped" , index + 1) + $"\n\n{repeater}").ConfigureAwait(false); GetText("repeater_stopped", index + 1) + $"\n\n{repeater}").ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -228,9 +237,9 @@ namespace NadekoBot.Modules.Utility
await uow.CompleteAsync().ConfigureAwait(false); await uow.CompleteAsync().ConfigureAwait(false);
} }
var rep = new RepeatRunner(toAdd, (ITextChannel)Context.Channel); var rep = new RepeatRunner(toAdd, (ITextChannel) Context.Channel);
Repeaters.AddOrUpdate(Context.Guild.Id, new ConcurrentQueue<RepeatRunner>(new[] { rep }), (key, old) => Repeaters.AddOrUpdate(Context.Guild.Id, new ConcurrentQueue<RepeatRunner>(new[] {rep}), (key, old) =>
{ {
old.Enqueue(rep); old.Enqueue(rep);
return old; return old;

View File

@ -273,7 +273,7 @@ namespace NadekoBot.Modules.Utility
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
public async Task ChannelId() public async Task ChannelId()
{ {
await ReplyConfirmLocalized("channelidd", "🆔", Format.Code(Context.Channel.Id.ToString())) await ReplyConfirmLocalized("channelid", "🆔", Format.Code(Context.Channel.Id.ToString()))
.ConfigureAwait(false); .ConfigureAwait(false);
} }
@ -439,7 +439,7 @@ namespace NadekoBot.Modules.Utility
var result = string.Join("\n", tags.Select(m => GetText("showemojis", m, m.Url))); var result = string.Join("\n", tags.Select(m => GetText("showemojis", m, m.Url)));
if (string.IsNullOrWhiteSpace(result)) if (string.IsNullOrWhiteSpace(result))
await ReplyErrorLocalized("emojis_none").ConfigureAwait(false); await ReplyErrorLocalized("showemojis_none").ConfigureAwait(false);
else else
await Context.Channel.SendMessageAsync(result).ConfigureAwait(false); await Context.Channel.SendMessageAsync(result).ConfigureAwait(false);
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -594,7 +594,7 @@ namespace NadekoBot.Resources {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Bot&apos;s language is set to {0} - {0}. /// Looks up a localized string similar to Bot&apos;s language is set to {0} - {1}.
/// </summary> /// </summary>
public static string administration_lang_set_bot_show { public static string administration_lang_set_bot_show {
get { get {
@ -612,7 +612,7 @@ namespace NadekoBot.Resources {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to This server&apos;s language is set to {0} - {0}. /// Looks up a localized string similar to This server&apos;s language is set to {0} - {1}.
/// </summary> /// </summary>
public static string administration_lang_set_show { public static string administration_lang_set_show {
get { get {
@ -1443,7 +1443,7 @@ namespace NadekoBot.Resources {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Text Channel Destroyed . /// Looks up a localized string similar to Text Channel Created.
/// </summary> /// </summary>
public static string administration_text_chan_created { public static string administration_text_chan_created {
get { get {
@ -1650,7 +1650,7 @@ namespace NadekoBot.Resources {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Voice Channel Destroyed. /// Looks up a localized string similar to Voice Channel Created.
/// </summary> /// </summary>
public static string administration_voice_chan_created { public static string administration_voice_chan_created {
get { get {
@ -2180,15 +2180,6 @@ namespace NadekoBot.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Betflip Gamble.
/// </summary>
public static string gambling_betflip_gamble {
get {
return ResourceManager.GetString("gambling_betflip_gamble", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Better luck next time ^_^. /// Looks up a localized string similar to Better luck next time ^_^.
/// </summary> /// </summary>
@ -2235,7 +2226,7 @@ namespace NadekoBot.Resources {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Invalid number specified. You can roll up to {0}-{1} dice at a time.. /// Looks up a localized string similar to Invalid number specified. You can roll {0}-{1} dice at once..
/// </summary> /// </summary>
public static string gambling_dice_invalid_number { public static string gambling_dice_invalid_number {
get { get {
@ -3604,15 +3595,6 @@ namespace NadekoBot.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to No music player active..
/// </summary>
public static string music_player_none {
get {
return ResourceManager.GetString("music_player_none", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Player Queue - Page {0}/{1}. /// Looks up a localized string similar to Player Queue - Page {0}/{1}.
/// </summary> /// </summary>
@ -4605,7 +4587,7 @@ namespace NadekoBot.Resources {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Your auto-translate language has been set to {from}&gt;{to}. /// Looks up a localized string similar to Your auto-translate language has been set to {0}&gt;{1}.
/// </summary> /// </summary>
public static string searches_atl_set { public static string searches_atl_set {
get { get {
@ -4884,7 +4866,7 @@ namespace NadekoBot.Resources {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Joes not loaded.. /// Looks up a localized string similar to Jokes not loaded..
/// </summary> /// </summary>
public static string searches_jokes_not_loaded { public static string searches_jokes_not_loaded {
get { get {
@ -4911,7 +4893,7 @@ namespace NadekoBot.Resources {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Lsit of {0}place tags. /// Looks up a localized string similar to List of {0}place tags.
/// </summary> /// </summary>
public static string searches_list_of_place_tags { public static string searches_list_of_place_tags {
get { get {
@ -5010,7 +4992,7 @@ namespace NadekoBot.Resources {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Failed retreiving osu signature.. /// Looks up a localized string similar to Failed retrieving osu! signature..
/// </summary> /// </summary>
public static string searches_osu_failed { public static string searches_osu_failed {
get { get {
@ -6004,7 +5986,7 @@ namespace NadekoBot.Resources {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Page #{0} of roels for {1}. /// Looks up a localized string similar to Page #{0} of roles for {1}.
/// </summary> /// </summary>
public static string utility_roles_page { public static string utility_roles_page {
get { get {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -480,13 +480,13 @@ Reason: {1}</value>
<value>Bot's default locale is now {0} - {1}</value> <value>Bot's default locale is now {0} - {1}</value>
</data> </data>
<data name="administration_lang_set_bot_show" xml:space="preserve"> <data name="administration_lang_set_bot_show" xml:space="preserve">
<value>Bot's language is set to {0} - {0}</value> <value>Bot's language is set to {0} - {1}</value>
</data> </data>
<data name="administration_lang_set_fail" xml:space="preserve"> <data name="administration_lang_set_fail" xml:space="preserve">
<value>Failed setting locale. Revisit this command's help.</value> <value>Failed setting locale. Revisit this command's help.</value>
</data> </data>
<data name="administration_lang_set_show" xml:space="preserve"> <data name="administration_lang_set_show" xml:space="preserve">
<value>This server's language is set to {0} - {0}</value> <value>This server's language is set to {0} - {1}</value>
</data> </data>
<data name="administration_left" xml:space="preserve"> <data name="administration_left" xml:space="preserve">
<value>{0} has left {1}</value> <value>{0} has left {1}</value>
@ -755,7 +755,7 @@ Reason: {1}</value>
__IgnoredChannels__: {2}</value> __IgnoredChannels__: {2}</value>
</data> </data>
<data name="administration_text_chan_created" xml:space="preserve"> <data name="administration_text_chan_created" xml:space="preserve">
<value>Text Channel Destroyed </value> <value>Text Channel Created</value>
</data> </data>
<data name="administration_text_chan_destroyed" xml:space="preserve"> <data name="administration_text_chan_destroyed" xml:space="preserve">
<value>Text Channel Destroyed </value> <value>Text Channel Destroyed </value>
@ -822,7 +822,7 @@ Reason: {1}</value>
<value>{0} has been **voice unmuted**.</value> <value>{0} has been **voice unmuted**.</value>
</data> </data>
<data name="administration_voice_chan_created" xml:space="preserve"> <data name="administration_voice_chan_created" xml:space="preserve">
<value>Voice Channel Destroyed</value> <value>Voice Channel Created</value>
</data> </data>
<data name="administration_voice_chan_destroyed" xml:space="preserve"> <data name="administration_voice_chan_destroyed" xml:space="preserve">
<value>Voice Channel Destroyed</value> <value>Voice Channel Destroyed</value>
@ -873,9 +873,6 @@ Reason: {1}</value>
<data name="gambling_awarded" xml:space="preserve"> <data name="gambling_awarded" xml:space="preserve">
<value>has awarded {0} to {1}</value> <value>has awarded {0} to {1}</value>
</data> </data>
<data name="gambling_betflip_gamble" xml:space="preserve">
<value>Betflip Gamble</value>
</data>
<data name="gambling_better_luck" xml:space="preserve"> <data name="gambling_better_luck" xml:space="preserve">
<value>Better luck next time ^_^</value> <value>Better luck next time ^_^</value>
</data> </data>
@ -1074,7 +1071,7 @@ Don't forget to leave your discord name or id in the message.
<value>{0} as {1} Won the race and {2}!</value> <value>{0} as {1} Won the race and {2}!</value>
</data> </data>
<data name="gambling_dice_invalid_number" xml:space="preserve"> <data name="gambling_dice_invalid_number" xml:space="preserve">
<value>Invalid number specified. You can roll up to {0}-{1} dice at a time.</value> <value>Invalid number specified. You can roll {0}-{1} dice at once.</value>
</data> </data>
<data name="gambling_dice_rolled" xml:space="preserve"> <data name="gambling_dice_rolled" xml:space="preserve">
<value>rolled {0}</value> <value>rolled {0}</value>
@ -1401,9 +1398,6 @@ Don't forget to leave your discord name or id in the message.
<data name="music_paused" xml:space="preserve"> <data name="music_paused" xml:space="preserve">
<value>Music playback paused.</value> <value>Music playback paused.</value>
</data> </data>
<data name="music_player_none" xml:space="preserve">
<value>No music player active.</value>
</data>
<data name="music_player_queue" xml:space="preserve"> <data name="music_player_queue" xml:space="preserve">
<value>Player Queue - Page {0}/{1}</value> <value>Player Queue - Page {0}/{1}</value>
</data> </data>
@ -1664,7 +1658,7 @@ Don't forget to leave your discord name or id in the message.
<value>your auto-translate language has been removed.</value> <value>your auto-translate language has been removed.</value>
</data> </data>
<data name="searches_atl_set" xml:space="preserve"> <data name="searches_atl_set" xml:space="preserve">
<value>Your auto-translate language has been set to {from}&gt;{to}</value> <value>Your auto-translate language has been set to {0}&gt;{1}</value>
</data> </data>
<data name="searches_atl_started" xml:space="preserve"> <data name="searches_atl_started" xml:space="preserve">
<value>Started automatic translation of messages on this channel.</value> <value>Started automatic translation of messages on this channel.</value>
@ -1757,7 +1751,7 @@ Don't forget to leave your discord name or id in the message.
<value>Invalid source or target language.</value> <value>Invalid source or target language.</value>
</data> </data>
<data name="searches_jokes_not_loaded" xml:space="preserve"> <data name="searches_jokes_not_loaded" xml:space="preserve">
<value>Joes not loaded.</value> <value>Jokes not loaded.</value>
</data> </data>
<data name="searches_latlong" xml:space="preserve"> <data name="searches_latlong" xml:space="preserve">
<value>Lat/Long</value> <value>Lat/Long</value>
@ -1766,7 +1760,7 @@ Don't forget to leave your discord name or id in the message.
<value>Level</value> <value>Level</value>
</data> </data>
<data name="searches_list_of_place_tags" xml:space="preserve"> <data name="searches_list_of_place_tags" xml:space="preserve">
<value>Lsit of {0}place tags</value> <value>List of {0}place tags</value>
<comment>Don't translate {0}place</comment> <comment>Don't translate {0}place</comment>
</data> </data>
<data name="searches_location" xml:space="preserve"> <data name="searches_location" xml:space="preserve">
@ -1800,7 +1794,7 @@ Don't forget to leave your discord name or id in the message.
<value>An osu! API key is required.</value> <value>An osu! API key is required.</value>
</data> </data>
<data name="searches_osu_failed" xml:space="preserve"> <data name="searches_osu_failed" xml:space="preserve">
<value>Failed retreiving osu signature.</value> <value>Failed retrieving osu! signature.</value>
</data> </data>
<data name="searches_over_x" xml:space="preserve"> <data name="searches_over_x" xml:space="preserve">
<value>Found over {0} images. Showing random {0}.</value> <value>Found over {0} images. Showing random {0}.</value>
@ -2137,7 +2131,7 @@ OwnerID: {2}</value>
<value>Page #{0} of all roles on this server:</value> <value>Page #{0} of all roles on this server:</value>
</data> </data>
<data name="utility_roles_page" xml:space="preserve"> <data name="utility_roles_page" xml:space="preserve">
<value>Page #{0} of roels for {1}</value> <value>Page #{0} of roles for {1}</value>
</data> </data>
<data name="utility_rrc_no_colors" xml:space="preserve"> <data name="utility_rrc_no_colors" xml:space="preserve">
<value>No colors are in the correct format. Use `#00ff00` for example.</value> <value>No colors are in the correct format. Use `#00ff00` for example.</value>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -5,9 +5,7 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Discord; using Discord;
using NLog; using NLog;
using System.Diagnostics;
using Discord.Commands; using Discord.Commands;
using NadekoBot.Services.Database.Models;
using NadekoBot.Modules.Permissions; using NadekoBot.Modules.Permissions;
using Discord.Net; using Discord.Net;
using NadekoBot.Extensions; using NadekoBot.Extensions;
@ -22,7 +20,7 @@ using NadekoBot.DataStructures;
namespace NadekoBot.Services namespace NadekoBot.Services
{ {
public class IGuildUserComparer : IEqualityComparer<IGuildUser> public class GuildUserComparer : IEqualityComparer<IGuildUser>
{ {
public bool Equals(IGuildUser x, IGuildUser y) => x.Id == y.Id; public bool Equals(IGuildUser x, IGuildUser y) => x.Id == y.Id;
@ -48,7 +46,7 @@ namespace NadekoBot.Services
public ConcurrentDictionary<ulong, uint> UserMessagesSent { get; } = new ConcurrentDictionary<ulong, uint>(); public ConcurrentDictionary<ulong, uint> UserMessagesSent { get; } = new ConcurrentDictionary<ulong, uint>();
public ConcurrentHashSet<ulong> UsersOnShortCooldown { get; } = new ConcurrentHashSet<ulong>(); public ConcurrentHashSet<ulong> UsersOnShortCooldown { get; } = new ConcurrentHashSet<ulong>();
private Timer clearUsersOnShortCooldown { get; } private readonly Timer _clearUsersOnShortCooldown;
public CommandHandler(DiscordShardedClient client, CommandService commandService) public CommandHandler(DiscordShardedClient client, CommandService commandService)
{ {
@ -56,7 +54,7 @@ namespace NadekoBot.Services
_commandService = commandService; _commandService = commandService;
_log = LogManager.GetCurrentClassLogger(); _log = LogManager.GetCurrentClassLogger();
clearUsersOnShortCooldown = new Timer((_) => _clearUsersOnShortCooldown = new Timer(_ =>
{ {
UsersOnShortCooldown.Clear(); UsersOnShortCooldown.Clear();
}, null, GlobalCommandsCooldown, GlobalCommandsCooldown); }, null, GlobalCommandsCooldown, GlobalCommandsCooldown);
@ -68,7 +66,7 @@ namespace NadekoBot.Services
await Task.Delay(5000).ConfigureAwait(false); await Task.Delay(5000).ConfigureAwait(false);
ownerChannels = (await Task.WhenAll(_client.GetGuilds().SelectMany(g => g.Users) ownerChannels = (await Task.WhenAll(_client.GetGuilds().SelectMany(g => g.Users)
.Where(u => NadekoBot.Credentials.OwnerIds.Contains(u.Id)) .Where(u => NadekoBot.Credentials.OwnerIds.Contains(u.Id))
.Distinct(new IGuildUserComparer()) .Distinct(new GuildUserComparer())
.Select(async u => .Select(async u =>
{ {
try try
@ -141,7 +139,7 @@ namespace NadekoBot.Services
BlacklistCommands.BlacklistedChannels.Contains(usrMsg.Channel.Id) || BlacklistCommands.BlacklistedChannels.Contains(usrMsg.Channel.Id) ||
BlacklistCommands.BlacklistedUsers.Contains(usrMsg.Author.Id); BlacklistCommands.BlacklistedUsers.Contains(usrMsg.Author.Id);
const float oneThousandth = 1.0f / 1000; private const float _oneThousandth = 1.0f / 1000;
private Task LogSuccessfulExecution(SocketUserMessage usrMsg, ExecuteCommandResult exec, SocketTextChannel channel, int exec1, int exec2, int exec3, int total) private Task LogSuccessfulExecution(SocketUserMessage usrMsg, ExecuteCommandResult exec, SocketTextChannel channel, int exec1, int exec2, int exec3, int total)
{ {
_log.Info("Command Executed after {4}/{5}/{6}/{7}s\n\t" + _log.Info("Command Executed after {4}/{5}/{6}/{7}s\n\t" +
@ -153,10 +151,10 @@ namespace NadekoBot.Services
(channel == null ? "PRIVATE" : channel.Guild.Name + " [" + channel.Guild.Id + "]"), // {1} (channel == null ? "PRIVATE" : channel.Guild.Name + " [" + channel.Guild.Id + "]"), // {1}
(channel == null ? "PRIVATE" : channel.Name + " [" + channel.Id + "]"), // {2} (channel == null ? "PRIVATE" : channel.Name + " [" + channel.Id + "]"), // {2}
usrMsg.Content, // {3} usrMsg.Content, // {3}
exec1 * oneThousandth, // {4} exec1 * _oneThousandth, // {4}
exec2 * oneThousandth, // {5} exec2 * _oneThousandth, // {5}
exec3 * oneThousandth, // {6} exec3 * _oneThousandth, // {6}
total * oneThousandth // {7} total * _oneThousandth // {7}
); );
return Task.CompletedTask; return Task.CompletedTask;
} }
@ -174,10 +172,10 @@ namespace NadekoBot.Services
(channel == null ? "PRIVATE" : channel.Name + " [" + channel.Id + "]"), // {2} (channel == null ? "PRIVATE" : channel.Name + " [" + channel.Id + "]"), // {2}
usrMsg.Content,// {3} usrMsg.Content,// {3}
exec.Result.ErrorReason, // {4} exec.Result.ErrorReason, // {4}
exec1 * oneThousandth, // {5} exec1 * _oneThousandth, // {5}
exec2 * oneThousandth, // {6} exec2 * _oneThousandth, // {6}
exec3 * oneThousandth, // {7} exec3 * _oneThousandth, // {7}
total * oneThousandth // {8} total * _oneThousandth // {8}
); );
} }
@ -429,10 +427,10 @@ namespace NadekoBot.Services
// Bot will ignore commands which are ran more often than what specified by // Bot will ignore commands which are ran more often than what specified by
// GlobalCommandsCooldown constant (miliseconds) // GlobalCommandsCooldown constant (miliseconds)
if (!UsersOnShortCooldown.Add(context.Message.Author.Id)) if (!UsersOnShortCooldown.Add(context.Message.Author.Id))
return new ExecuteCommandResult(cmd, null, SearchResult.FromError(CommandError.Exception, $"You are on a global cooldown.")); return new ExecuteCommandResult(cmd, null, SearchResult.FromError(CommandError.Exception, "You are on a global cooldown."));
if (CmdCdsCommands.HasCooldown(cmd, context.Guild, context.User)) if (CmdCdsCommands.HasCooldown(cmd, context.Guild, context.User))
return new ExecuteCommandResult(cmd, null, SearchResult.FromError(CommandError.Exception, $"That command is on a cooldown for you.")); return new ExecuteCommandResult(cmd, null, SearchResult.FromError(CommandError.Exception, "That command is on a cooldown for you."));
return new ExecuteCommandResult(cmd, null, await commands[i].ExecuteAsync(context, parseResult, dependencyMap)); return new ExecuteCommandResult(cmd, null, await commands[i].ExecuteAsync(context, parseResult, dependencyMap));
} }

View File

@ -16,7 +16,7 @@ namespace NadekoBot.Services.Impl
private readonly DiscordShardedClient _client; private readonly DiscordShardedClient _client;
private readonly DateTime _started; private readonly DateTime _started;
public const string BotVersion = "1.2-beta"; public const string BotVersion = "1.2";
public string Author => "Kwoth#2560"; public string Author => "Kwoth#2560";
public string Library => "Discord.Net"; public string Library => "Discord.Net";

View File

@ -23,12 +23,12 @@
"Google.Apis.Urlshortener.v1": "1.19.0.138", "Google.Apis.Urlshortener.v1": "1.19.0.138",
"Google.Apis.YouTube.v3": "1.20.0.701", "Google.Apis.YouTube.v3": "1.20.0.701",
"Google.Apis.Customsearch.v1": "1.20.0.466", "Google.Apis.Customsearch.v1": "1.20.0.466",
"ImageSharp": "1.0.0-alpha2-00090", "ImageSharp": "1.0.0-alpha2-*",
"ImageSharp.Processing": "1.0.0-alpha2-00078", "ImageSharp.Processing": "1.0.0-alpha2-*",
"ImageSharp.Formats.Png": "1.0.0-alpha2-00086", "ImageSharp.Formats.Png": "1.0.0-alpha2-*",
"ImageSharp.Drawing": "1.0.0-alpha2-00090", "ImageSharp.Formats.Jpeg": "1.0.0-alpha2-*",
"ImageSharp.Drawing.Paths": "1.0.0-alpha2-00040", "ImageSharp.Drawing": "1.0.0-alpha2-*",
//"ImageSharp.Formats.Jpeg": "1.0.0-alpha2-00090", "ImageSharp.Drawing.Paths": "1.0.0-alpha2-*",
"Microsoft.EntityFrameworkCore": "1.1.0", "Microsoft.EntityFrameworkCore": "1.1.0",
"Microsoft.EntityFrameworkCore.Design": "1.1.0", "Microsoft.EntityFrameworkCore.Design": "1.1.0",
"Microsoft.EntityFrameworkCore.Sqlite": "1.1.0", "Microsoft.EntityFrameworkCore.Sqlite": "1.1.0",
@ -44,7 +44,6 @@
}, },
"Newtonsoft.Json": "9.0.2-beta1", "Newtonsoft.Json": "9.0.2-beta1",
"NLog": "5.0.0-beta03", "NLog": "5.0.0-beta03",
"System.Diagnostics.Contracts": "4.3.0",
"System.Xml.XPath": "4.3.0", "System.Xml.XPath": "4.3.0",
"Discord.Net.Commands": { "Discord.Net.Commands": {
"target": "project", "target": "project",