Merge pull request #128 from 13xforever/vnext

Update dependencies and some fun stuff
This commit is contained in:
Ilya 2018-11-13 04:39:44 +05:00 committed by GitHub
commit 31c74d9793
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 86 additions and 3 deletions

View File

@ -15,7 +15,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.6" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="NLog" Version="4.5.10" />
<PackageReference Include="NLog" Version="4.5.11" />
</ItemGroup>
</Project>

View File

@ -128,7 +128,7 @@ Example usage:
{
var info = await client.GetUpdateAsync(Config.Cts.Token).ConfigureAwait(false);
var embed = await info.AsEmbedAsync().ConfigureAwait(false);
if (embed.Color == Config.Colors.Maintenance)
if (info == null || embed.Color == Config.Colors.Maintenance)
embed = await CachedUpdateInfo.AsEmbedAsync().ConfigureAwait(false);
else
CachedUpdateInfo = info;
@ -212,6 +212,14 @@ Example usage:
result.AppendLine($"{authorMention} searched for: ***{request.search.Sanitize()}***");
if (request.search.Contains("persona", StringComparison.InvariantCultureIgnoreCase))
result.AppendLine("Did you try searching for ***Unnamed*** instead?");
else if (ctx.Message.Author.Id == 197163728867688448 &&
(request.search.Contains("afrika", StringComparison.InvariantCultureIgnoreCase) ||
request.search.Contains("africa", StringComparison.InvariantCultureIgnoreCase) ||
request.search.Contains("BLUS30399", StringComparison.InvariantCultureIgnoreCase)))
{
var sqvat = DiscordEmoji.FromName(ctx.Client, ":sqvat:");
result.AppendLine($"One day this meme will die {sqvat}");
}
}
else
{

View File

@ -18,13 +18,14 @@
<ItemGroup>
<PackageReference Include="DSharpPlus" Version="4.0.0-nightly-00553" />
<PackageReference Include="DSharpPlus.CommandsNext" Version="4.0.0-nightly-00553" />
<PackageReference Include="DSharpPlus.Interactivity" Version="4.0.0-nightly-00553" />
<PackageReference Include="MathParser.org-mXparser" Version="4.2.2" />
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.1.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.1.2" />
<PackageReference Include="NLog" Version="4.5.10" />
<PackageReference Include="NLog" Version="4.5.11" />
<PackageReference Include="NReco.Text.AhoCorasickDoubleArrayTrie" Version="1.0.1" />
<PackageReference Include="SharpCompress" Version="0.22.0" />
<PackageReference Include="System.IO.Pipelines" Version="4.5.2" />

View File

@ -57,6 +57,13 @@ namespace CompatBot.EventHandlers
if (codesToLookup.Count == 0)
return;
if (args.Message.Author.Id == 197163728867688448 && codesToLookup.Any(c => c == "BLUS30399"))
{
var sqvat = DiscordEmoji.FromName(args.Client, ":sqvat:");
await args.Message.ReactWithAsync(args.Client, sqvat, "How about no (๑•ิཬ•ั๑)").ConfigureAwait(false);
return;
}
await args.Channel.TriggerTypingAsync().ConfigureAwait(false);
var results = new List<(string code, Task<DiscordEmbed> task)>(codesToLookup.Count);
foreach (var code in codesToLookup)

View File

@ -0,0 +1,66 @@
using System;
using System.Threading.Tasks;
using DSharpPlus.EventArgs;
namespace CompatBot.EventHandlers
{
internal static class TableFlipMonitor
{
private static readonly char[] OpenParen = {'(', '', 'ʕ'};
public static async Task OnMessageCreated(MessageCreateEventArgs args)
{
if (args.Author.IsBot)
return;
var content = args.Message.Content;
if (string.IsNullOrEmpty(content) || content.StartsWith(Config.CommandPrefix))
return;
/*
* (°°
* ( Д)
* ()
* (
* (Д)/
* (^_^)
* (/¯ )/¯ ~
*
*
*
*/
try
{
var response = "";
if (!(content.Contains("┻━┻") ||
content.Contains("┻━┻")))
return;
var tableIdx = content.IndexOf("┻━┻");
if (tableIdx < 0)
tableIdx = content.IndexOf("┻━┻");
var faceIdx = content.Substring(0, tableIdx).LastIndexOfAny(OpenParen);
var face = content.Substring(faceIdx, tableIdx - faceIdx);
var reverseFace = face
.Replace("(╯", "╯(").Replace("(ノ", "ノ(").Replace("(", "(").Replace("(/¯", @"\_/(")
.Replace(")╯", "╯)").Replace(")ノ", "ノ)").Replace(")", ")").Replace(")/¯", @"\_/)")
.Replace("(╯", "╯(").Replace("(ノ", "ノ(").Replace("", "").Replace("/¯", @"\_/")
.Replace(")╯", "╯)").Replace(")ノ", "ノ)").Replace("", "").Replace("/¯", @"\_/")
.Replace("ʕ╯", "╯ʕ").Replace("ʕノ", "ノʕ").Replace("ʕノ", "ノʕ").Replace("ʕ/¯", @"\_/ʕ")
.Replace("ʔ╯", "╯ʔ").Replace("ʔノ", "ノʔ").Replace("ʔ", "ʔ").Replace("ʔ/¯", @"\_/ʔ")
.TrimEnd('︵', '彡', ' ', ' ', '~', '');
if (reverseFace == face)
return;
await args.Channel.SendMessageAsync("┬─┬ " + reverseFace).ConfigureAwait(false);
}
catch (Exception e)
{
Config.Log.Warn(e);
}
}
}
}

View File

@ -171,6 +171,7 @@ namespace CompatBot
client.MessageCreated += DiscordInviteFilter.OnMessageCreated;
client.MessageCreated += BotShutupHandler.OnMessageCreated;
client.MessageCreated += NewBuildsMonitor.OnMessageCreated;
client.MessageCreated += TableFlipMonitor.OnMessageCreated;
client.MessageUpdated += AntipiracyMonitor.OnMessageUpdated;
client.MessageUpdated += DiscordInviteFilter.OnMessageUpdated;