Fixes to custom reactions case insensitivty
This commit is contained in:
parent
384e83f07f
commit
1dd8f9b5ea
@ -415,7 +415,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
IsRegex = false,
|
IsRegex = false,
|
||||||
OwnerOnly = false,
|
OwnerOnly = false,
|
||||||
Response = res,
|
Response = res,
|
||||||
Trigger = cr.Key,
|
Trigger = cr.Key.ToLowerInvariant(),
|
||||||
});
|
});
|
||||||
}).ToArray());
|
}).ToArray());
|
||||||
|
|
||||||
|
@ -42,19 +42,19 @@ namespace NadekoBot.Modules.CustomReactions
|
|||||||
|
|
||||||
var t = Task.Run(async () =>
|
var t = Task.Run(async () =>
|
||||||
{
|
{
|
||||||
var content = umsg.Content.ToLowerInvariant();
|
var content = umsg.Content.Trim().ToLowerInvariant();
|
||||||
ConcurrentHashSet<CustomReaction> reactions;
|
ConcurrentHashSet<CustomReaction> reactions;
|
||||||
GuildReactions.TryGetValue(channel.Guild.Id, out reactions);
|
GuildReactions.TryGetValue(channel.Guild.Id, out reactions);
|
||||||
if (reactions != null && reactions.Any())
|
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)
|
if (reaction != null)
|
||||||
{
|
{
|
||||||
try { await channel.SendMessageAsync(reaction.ResponseWithContext(umsg)).ConfigureAwait(false); } catch { }
|
try { await channel.SendMessageAsync(reaction.ResponseWithContext(umsg)).ConfigureAwait(false); } catch { }
|
||||||
return;
|
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)
|
if (greaction != null)
|
||||||
{
|
{
|
||||||
try { await channel.SendMessageAsync(greaction.ResponseWithContext(umsg)).ConfigureAwait(false); } catch { }
|
try { await channel.SendMessageAsync(greaction.ResponseWithContext(umsg)).ConfigureAwait(false); } catch { }
|
||||||
|
Loading…
Reference in New Issue
Block a user