Fixes to custom reactions case insensitivty

This commit is contained in:
Kwoth 2016-10-15 14:59:51 +02:00
parent 384e83f07f
commit 1dd8f9b5ea
2 changed files with 4 additions and 4 deletions

View File

@ -415,7 +415,7 @@ namespace NadekoBot.Modules.Administration
IsRegex = false,
OwnerOnly = false,
Response = res,
Trigger = cr.Key,
Trigger = cr.Key.ToLowerInvariant(),
});
}).ToArray());

View File

@ -42,19 +42,19 @@ namespace NadekoBot.Modules.CustomReactions
var t = Task.Run(async () =>
{
var content = umsg.Content.ToLowerInvariant();
var content = umsg.Content.Trim().ToLowerInvariant();
ConcurrentHashSet<CustomReaction> reactions;
GuildReactions.TryGetValue(channel.Guild.Id, out reactions);
if (reactions != null && reactions.Any())
{
var reaction = reactions.Where(cr => cr.TriggerWithContext(umsg) == content).Shuffle().FirstOrDefault();
var reaction = reactions.Where(cr => cr.TriggerWithContext(umsg).Trim().ToLowerInvariant() == content).Shuffle().FirstOrDefault();
if (reaction != null)
{
try { await channel.SendMessageAsync(reaction.ResponseWithContext(umsg)).ConfigureAwait(false); } catch { }
return;
}
}
var greaction = GlobalReactions.Where(cr => cr.TriggerWithContext(umsg) == content).Shuffle().FirstOrDefault();
var greaction = GlobalReactions.Where(cr => cr.TriggerWithContext(umsg).Trim().ToLowerInvariant() == content).Shuffle().FirstOrDefault();
if (greaction != null)
{
try { await channel.SendMessageAsync(greaction.ResponseWithContext(umsg)).ConfigureAwait(false); } catch { }