def parseChatMessage(sig): global worms wormID = int(sig[1]) message = sig[2] #io.msg("Chat msg from worm %i: %s" % (wormID, message)) if worms[wormID].isAdmin: if not cmds.parseAdminCommand(wormID, message): cmds.parseUserCommand(wormID, message) else: cmds.parseUserCommand(wormID, message)
def parseChatMessage(sig): global worms wormID = int(sig[1]) message = sig[2] #io.msg("Chat msg from worm %i: %s" % (wormID, message)) if worms[wormID].isAdmin: if not cmds.parseAdminCommand(wormID,message): cmds.parseUserCommand(wormID,message) else: cmds.parseUserCommand(wormID,message)
def parseCustom(sig): if not cmds.parseAdminCommand(-1, "%s%s" % (cfg.ADMIN_PREFIX, str(sig[1:]))): cmds.parseUserCommand(-1, "%s%s" % (cfg.USER_PREFIX, str(sig[1:])))
def parseChatMessage(sig): global worms wormID = int(sig[1]) message = sig[2] #Length-based anti-spam - see dedicated_config for details if cfg.ANTISPAM != 0: if len(message) > cfg.ANTISPAM_KICKLIMIT: if cfg.ANTISPAM > 1 and len(message) > cfg.ANTISPAM_BANLIMIT: if cfg.ANTISPAM == 2: kickWithTime(wormID, "excessive spamming") return elif cfg.ANTISPAM == 3: io.banWorm(wormID, "excessive spamming") io.messageLog( "Player " + worms[wormID].Name + " from IP " + worms[wormID].Ip + " was banned for spamming", io.LOG_INFO) return else: io.kickWorm(wormID, "spamming") return #NEW: Impersonation protection - check if the player tries to impersonate another player using the newline tags. #NOTE: The "GOGO" spamfest taunt is whitelisted here! if cfg.ANTI_IMPERSONATION: if message not in cfg.ANTI_IMPERSONATION_WHITELIST and detectFormattingTags( message): #Warn the player and count the attempt io.privateMsg(wormID, cfg.ANTI_IMPERSONATION_CLIENT_WARNING) worms[wormID].tags_detected += 1 #TODO HACK EXPERIMENTAL TEST: Check whether the message contains other players' nicknames - if yes, warn the other players for w in worms.keys(): if w != wormID and (worms[w].real_name.strip() in message or worms[w].getCleanName().strip() in message): if cfg.ANTI_IMPERSONATION_SERVER_WARNING: #Do not broadcast warning if it doesn't exist io.chatMsg( cfg.ANTI_IMPERSONATION_SERVER_WARNING.replace( "<player>", worms[wormID].getCleanName()).replace( "<another>", worms[w].getCleanName())) #Apply sanctions if worms[wormID].tags_detected > cfg.ANTI_IMPERSONATION_LIMIT: if cfg.ANTI_IMPERSONATION_ACTION == 1: io.kickWorm(wormID, "used non-allowed formatting tags in chat") return elif cfg.ANTI_IMPERSONATION_ACTION == 2: kickWithTime(wormID, "used non-allowed formatting tags in chat") return #Taunt antispam - see dedicated_config for details if cfg.TAUNT_ANTISPAM: for kw in cfg.TAUNT_KEYWORDS: if kw in message.lower(): worms[wormID].spammed += 1 io.privateMsg(wormID, cfg.TAUNT_ANTISPAM_WARNING) if worms[wormID].spammed > cfg.TAUNT_ANTISPAM_LIMIT: if cfg.TAUNT_ANTISPAM == 1: io.kickWorm(wormID, "spamming") elif cfg.TAUNT_ANTISPAM == 2: kickWithTime(wormID, "spamming") return #Commands ret = None aret = None if worms[wormID].isAdmin and message.startswith(cfg.ADMIN_PREFIX): aret = cmds.parseAdminCommand(wormID, message) if message.startswith(cfg.USER_PREFIX): ret = cmds.parseUserCommand(wormID, message) if ret == "map": updateVotes(send_msg=("map", )) elif ret == "mod": updateVotes(send_msg=("mod", )) elif ret == "teams": updateVotes(send_msg=("teams", )) elif ret == "kick": #Don't broadcast voting status if voted for kick updateVotes(send_msg=())