mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 03:55:18 -04:00
Now more chat commands will auto-mute for them being used to spam.
This commit is contained in:
parent
4d37af2c34
commit
6170b46491
@ -39,9 +39,7 @@ namespace MCGalaxy.Commands {
|
||||
Player.Message(p, "You need to have at least 1 &3" + Server.moneys +
|
||||
" %Sto purchase a snack."); return;
|
||||
}
|
||||
if (p.muted) {
|
||||
Player.Message(p, "You cannot use this command while muted."); return;
|
||||
}
|
||||
if (p.muted) { Player.Message(p, "You cannot use this command while muted."); return; }
|
||||
|
||||
p.NextEat = DateTime.UtcNow.AddSeconds(10);
|
||||
if (Economy.Enabled) {
|
||||
@ -60,7 +58,8 @@ namespace MCGalaxy.Commands {
|
||||
Chat.GlobalChatLevel(p, "<Level>" + p.ColoredName + " %S" + action, false);
|
||||
} else {
|
||||
Player.SendChatFrom(p, p.ColoredName + " %S" + action, false);
|
||||
}
|
||||
}
|
||||
p.CheckForMessageSpam();
|
||||
}
|
||||
|
||||
static string[] defMessages = { "guzzled a grape", "chewed a cherry", "ate an avocado" };
|
||||
|
@ -35,6 +35,7 @@ namespace MCGalaxy.Commands {
|
||||
string giver = (p == null) ? "(console)" : p.ColoredName;
|
||||
Player.Message(who, giver + " just highfived you");
|
||||
Player.GlobalMessage(p, giver + " %Sjust highfived " + who.ColoredName);
|
||||
p.CheckForMessageSpam();
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
|
@ -43,7 +43,8 @@ namespace MCGalaxy.Commands {
|
||||
type = args[1];
|
||||
}
|
||||
if (type == null) {
|
||||
Player.GlobalMessage(p, giver + " %Shugged " + who.ColoredName + "."); return;
|
||||
Player.GlobalMessage(p, giver + " %Shugged " + who.ColoredName + ".");
|
||||
p.CheckForMessageSpam(); return;
|
||||
}
|
||||
|
||||
if (type == "deadly") {
|
||||
@ -56,6 +57,7 @@ namespace MCGalaxy.Commands {
|
||||
who.HandleDeath(Block.rock, " died from a %cdeadly hug.");
|
||||
}
|
||||
Player.GlobalMessage(p, giver + " %Sgave " + who.ColoredName + " %Sa " + type + " hug.");
|
||||
p.CheckForMessageSpam();
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
|
@ -16,30 +16,29 @@
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
using System;
|
||||
namespace MCGalaxy.Commands
|
||||
{
|
||||
public sealed class CmdMe : Command
|
||||
{
|
||||
namespace MCGalaxy.Commands {
|
||||
public sealed class CmdMe : Command {
|
||||
public override string name { get { return "me"; } }
|
||||
public override string shortcut { get { return ""; } }
|
||||
public override string type { get { return CommandTypes.Chat; } }
|
||||
public override bool museumUsable { get { return true; } }
|
||||
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
|
||||
public CmdMe() { }
|
||||
public override void Use(Player p, string message)
|
||||
{
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
if (message == "") { Player.Message(p, "You"); return; }
|
||||
if (p == null) { MessageInGameOnly(p); return; }
|
||||
|
||||
if (p.joker || p.muted) { Player.Message(p, "Cannot use /me while muted or jokered."); return; }
|
||||
if (Server.chatmod && !p.voice) { Player.Message(p, "Chat moderation is on, you cannot emote."); return; }
|
||||
|
||||
|
||||
if (!p.level.worldChat) {
|
||||
Chat.GlobalChatLevel(p, "<Level>" + p.color + "*" + Colors.StripColors(p.DisplayName) + " " + message, false);
|
||||
} else {
|
||||
Player.SendChatFrom(p, p.color + "*" + Colors.StripColors(p.DisplayName) + " " + message, false);
|
||||
Player.RaisePlayerAction(p, PlayerAction.Me, message);
|
||||
}
|
||||
p.CheckForMessageSpam();
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
|
@ -37,6 +37,7 @@ namespace MCGalaxy.Commands {
|
||||
if (min > max) { int a = min; min = max; max = a; }
|
||||
|
||||
Player.GlobalMessage(p, p.ColoredName + " %Srolled a &a" + rand.Next(min, max + 1) + " %S(" + min + "|" + max + ")");
|
||||
p.CheckForMessageSpam();
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
|
@ -46,7 +46,7 @@ namespace MCGalaxy.Commands {
|
||||
p.afkMessage = p.IsAfk ? message : null;
|
||||
TabList.Update(p, true);
|
||||
p.LastAction = DateTime.UtcNow;
|
||||
|
||||
|
||||
bool send = !Server.chatmod && !p.muted;
|
||||
if (p.IsAfk) {
|
||||
if (send) {
|
||||
@ -61,12 +61,13 @@ namespace MCGalaxy.Commands {
|
||||
OnPlayerAFKEvent.Call(p);
|
||||
} else {
|
||||
if (send) {
|
||||
Player.GlobalMessage("-" + p.ColoredName + "%S- is no longer AFK");
|
||||
Player.RaisePlayerAction(p, PlayerAction.UnAFK, message);
|
||||
Player.GlobalMessage("-" + p.ColoredName + "%S- is no longer AFK");
|
||||
Player.RaisePlayerAction(p, PlayerAction.UnAFK, message);
|
||||
} else {
|
||||
Player.Message(p, "You are no longer marked as being AFK.");
|
||||
}
|
||||
}
|
||||
p.CheckForMessageSpam();
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
|
@ -186,11 +186,8 @@ namespace MCGalaxy {
|
||||
|
||||
try {
|
||||
PlayerBot.UnloadFromLevel(this);
|
||||
//physChecker.Stop();
|
||||
//physChecker.Dispose();
|
||||
physThread.Abort();
|
||||
physThread.Join();
|
||||
|
||||
} catch {
|
||||
} finally {
|
||||
Dispose();
|
||||
|
@ -558,7 +558,7 @@ try { SendBlockchange(pos1.x, pos1.y, pos1.z, Block.waterstill); } catch { }
|
||||
}
|
||||
hello:
|
||||
// People who are muted can't speak or vote
|
||||
if ( muted ) { this.SendMessage("You are muted."); return; } //Muted: Only allow commands
|
||||
if (muted) { SendMessage("You are muted."); return; } //Muted: Only allow commands
|
||||
|
||||
// Lava Survival map vote recorder
|
||||
if ( Server.lava.HasPlayer(this) && Server.lava.HasVote(text.ToLower()) ) {
|
||||
@ -578,28 +578,10 @@ try { SendBlockchange(pos1.x, pos1.y, pos1.z, Block.waterstill); } catch { }
|
||||
if (IsHandledMessage(text)) return;
|
||||
|
||||
// Put this after vote collection so that people can vote even when chat is moderated
|
||||
if ( Server.chatmod && !voice ) { this.SendMessage("Chat moderation is on, you cannot speak."); return; }
|
||||
if (Server.chatmod && !voice) { SendMessage("Chat moderation is on, you cannot speak."); return; }
|
||||
CheckForMessageSpam();
|
||||
|
||||
if (Server.checkspam) {
|
||||
if (Player.lastMSG == name) {
|
||||
consecutivemessages++;
|
||||
} else {
|
||||
consecutivemessages--;
|
||||
}
|
||||
|
||||
if (consecutivemessages >= Server.spamcounter) {
|
||||
muteCooldown = Server.mutespamtime;
|
||||
Command.all.Find("mute").Use(null, name);
|
||||
Player.GlobalMessage(color + DisplayName + " %Shas been &0muted &efor spamming!");
|
||||
muteTimer.Elapsed += MuteTimerElapsed;
|
||||
muteTimer.Start();
|
||||
return;
|
||||
}
|
||||
}
|
||||
Player.lastMSG = this.name;
|
||||
|
||||
if( Chat.HandleModes(this, text) )
|
||||
return;
|
||||
if (Chat.HandleModes(this, text)) return;
|
||||
|
||||
if ( text[0] == ':' ) {
|
||||
if ( PlayingTntWars ) {
|
||||
@ -678,6 +660,26 @@ return;
|
||||
catch ( Exception e ) { Server.ErrorLog(e); Player.GlobalMessage("An error occurred: " + e.Message); }
|
||||
}
|
||||
|
||||
public void CheckForMessageSpam() {
|
||||
if (!Server.checkspam || ircNick != null) { Player.lastMSG = name; return; }
|
||||
|
||||
if (Player.lastMSG == name) {
|
||||
consecutivemessages++;
|
||||
} else {
|
||||
consecutivemessages--;
|
||||
}
|
||||
|
||||
if (consecutivemessages >= Server.spamcounter) {
|
||||
muteCooldown = Server.mutespamtime;
|
||||
Command.all.Find("mute").Use(null, name);
|
||||
Player.GlobalMessage(color + DisplayName + " %Shas been &0muted &efor spamming!");
|
||||
muteTimer.Elapsed += MuteTimerElapsed;
|
||||
muteTimer.Start();
|
||||
return;
|
||||
}
|
||||
Player.lastMSG = name;
|
||||
}
|
||||
|
||||
string HandleJoker(string text) {
|
||||
if (!joker) return text;
|
||||
if (!File.Exists("text/joker.txt")) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user