Now more chat commands will auto-mute for them being used to spam.

This commit is contained in:
UnknownShadow200 2016-08-07 15:07:20 +10:00
parent 4d37af2c34
commit 6170b46491
8 changed files with 42 additions and 40 deletions

View File

@ -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) {
@ -61,6 +59,7 @@ namespace MCGalaxy.Commands {
} else {
Player.SendChatFrom(p, p.ColoredName + " %S" + action, false);
}
p.CheckForMessageSpam();
}
static string[] defMessages = { "guzzled a grape", "chewed a cherry", "ate an avocado" };

View File

@ -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) {

View File

@ -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) {

View File

@ -16,18 +16,16 @@
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; }
@ -40,6 +38,7 @@ namespace MCGalaxy.Commands
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) {

View File

@ -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) {

View File

@ -67,6 +67,7 @@ namespace MCGalaxy.Commands {
Player.Message(p, "You are no longer marked as being AFK.");
}
}
p.CheckForMessageSpam();
}
public override void Help(Player p) {

View File

@ -186,11 +186,8 @@ namespace MCGalaxy {
try {
PlayerBot.UnloadFromLevel(this);
//physChecker.Stop();
//physChecker.Dispose();
physThread.Abort();
physThread.Join();
} catch {
} finally {
Dispose();

View File

@ -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")) {