mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 12:42:22 -04:00
Limit .who in public chat to at most once per second.
This commit is contained in:
parent
41a6c2ca0a
commit
549058756f
@ -38,7 +38,7 @@ namespace MCGalaxy {
|
|||||||
Dictionary<string, List<string>> users = new Dictionary<string, List<string>>();
|
Dictionary<string, List<string>> users = new Dictionary<string, List<string>>();
|
||||||
static char[] trimChars = { ' ' };
|
static char[] trimChars = { ' ' };
|
||||||
ConnectionArgs args;
|
ConnectionArgs args;
|
||||||
DateTime lastWho;
|
DateTime lastWho, lastOpWho;
|
||||||
|
|
||||||
public IRCBot() {
|
public IRCBot() {
|
||||||
UpdateState();
|
UpdateState();
|
||||||
@ -282,12 +282,18 @@ namespace MCGalaxy {
|
|||||||
message = CP437Reader.ConvertToRaw(message);
|
message = CP437Reader.ConvertToRaw(message);
|
||||||
string[] parts = message.SplitSpaces(3);
|
string[] parts = message.SplitSpaces(3);
|
||||||
string ircCmd = parts[0].ToLower();
|
string ircCmd = parts[0].ToLower();
|
||||||
if (ircCmd == ".who" || ircCmd == ".players") {
|
|
||||||
|
bool whoCmd = ircCmd == ".who" || ircCmd == ".players" || ircCmd == "!players";
|
||||||
|
DateTime last = opchat ? lastOpWho : lastWho;
|
||||||
|
if (whoCmd && (DateTime.UtcNow - last).TotalSeconds > 1) {
|
||||||
try {
|
try {
|
||||||
CmdPlayers.DisplayPlayers(null, "", text => Say(text, opchat, true), false, false);
|
CmdPlayers.DisplayPlayers(null, "", text => Say(text, opchat, true), false, false);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Server.ErrorLog(e);
|
Server.ErrorLog(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opchat) lastOpWho = DateTime.UtcNow;
|
||||||
|
else lastWho = DateTime.UtcNow;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ircCmd == ".x" && !HandlePublicCommand(user, channel, message, parts, opchat)) return;
|
if (ircCmd == ".x" && !HandlePublicCommand(user, channel, message, parts, opchat)) return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user