mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Fix pinging system in DiscordWebhook.cs (#1610)
* Check if ping already exists to avoid crashes. * Remove bug where multiple words are not pinged
This commit is contained in:
parent
f16e9e87dd
commit
5281bc140c
1 changed files with 21 additions and 9 deletions
|
|
@ -406,11 +406,11 @@ class DiscordWebhook : ChatBot
|
||||||
string pings = "";
|
string pings = "";
|
||||||
if (settings.GetMessageContains().Count > 0)
|
if (settings.GetMessageContains().Count > 0)
|
||||||
{
|
{
|
||||||
msg = new string(msg.Where(c => !char.IsPunctuation(c)).ToArray());
|
msg = new string(msg.Where(c => !char.IsPunctuation(c)).ToArray()).ToLower();
|
||||||
|
|
||||||
foreach (string word in msg.Split(' '))
|
foreach (KeyValuePair<string, string> keyPhrase in settings.GetMessageContains())
|
||||||
{
|
{
|
||||||
if (settings.GetMessageContains().ContainsKey(word.ToLower())) { pings += string.Join(" ", settings.GetMessageContains()[word.ToLower()]); }
|
if (msg.Contains(keyPhrase.Key)) { pings += string.Join(" ", keyPhrase.Value); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (settings.GetMessageFrom().ContainsKey(username.ToLower()))
|
if (settings.GetMessageFrom().ContainsKey(username.ToLower()))
|
||||||
|
|
@ -603,15 +603,21 @@ class DiscordWebhook : ChatBot
|
||||||
{
|
{
|
||||||
List<string> tempList = GetStringsInQuotes(string.Join(" ", args));
|
List<string> tempList = GetStringsInQuotes(string.Join(" ", args));
|
||||||
if (tempList.Count >= 2)
|
if (tempList.Count >= 2)
|
||||||
|
{
|
||||||
|
if (!settings.GetMessageContains().ContainsKey(tempList[0].ToLower()))
|
||||||
{
|
{
|
||||||
settings.GetMessageContains().Add(tempList[0].ToLower(), string.Join(" ", tempList[1]));
|
settings.GetMessageContains().Add(tempList[0].ToLower(), string.Join(" ", tempList[1]));
|
||||||
return "Added " + tempList[0].ToLower() + " " + string.Join(" ", tempList[1]);
|
return "Added " + tempList[0].ToLower() + " " + string.Join(" ", tempList[1]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
return "This ping already exists";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
return "Too many arguments";
|
return "Too many arguments";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -633,15 +639,21 @@ class DiscordWebhook : ChatBot
|
||||||
{
|
{
|
||||||
List<string> tempList = GetStringsInQuotes(string.Join(" ", args));
|
List<string> tempList = GetStringsInQuotes(string.Join(" ", args));
|
||||||
if (tempList.Count >= 2)
|
if (tempList.Count >= 2)
|
||||||
|
{
|
||||||
|
if (!settings.GetMessageFrom().ContainsKey(tempList[0].ToLower()))
|
||||||
{
|
{
|
||||||
settings.GetMessageFrom().Add(tempList[0].ToLower(), string.Join(" ", tempList[1]));
|
settings.GetMessageFrom().Add(tempList[0].ToLower(), string.Join(" ", tempList[1]));
|
||||||
return "Added " + tempList[0].ToLower() + " " + string.Join(" ", tempList[1]);
|
return "Added " + tempList[0].ToLower() + " " + string.Join(" ", tempList[1]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
return "This ping already exists";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
return "Too many arguments";
|
return "Too many arguments";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue