def add_spamming_case(self, ip): if ip in self.spammerlist.keys(): self.spammerlist[ip] += 1 if self.spammerlist[ip] > warnings: self.dealwithspammer(ip) del self.spammerlist[ip] else: playerByIpString(ip).message(warning(warn_spam_message.substitute(colordict))) else: self.spammerlist[ip] = 1 playerByIpString(ip).message(warning(warn_spam_message.substitute(colordict)))
def add_spamming_case(self, ip): if ip in self.spammerlist.keys(): self.spammerlist[ip] += 1 if self.spammerlist[ip] > warnings: self.dealwithspammer(ip) del self.spammerlist[ip] else: playerByIpString(ip).message( warning(warn_spam_message.substitute(colordict))) else: self.spammerlist[ip] = 1 playerByIpString(ip).message( warning(warn_spam_message.substitute(colordict)))
def warnNickReserved(cn, count, sessid): try: p = player(cn) except ValueError: return try: nickacct = p.warn_nickacct if nickacct.nick != sbserver.playerName(cn) or sessid != sbserver.playerSessionId(cn): p.warning_for_login = False return except (AttributeError, ValueError): p.warning_for_login = False return if isLoggedIn(cn): user = loggedInAs(cn) if nickacct.user_id != user.id: ban(cn, 0, 'Use of reserved name', -1) p.warning_for_login = False return if count > 4: ban(cn, 0, 'Use of reserved name', -1) p.warning_for_login = False return remaining = 25-(count*5) sbserver.playerMessage(cn, warning('Your name is reserved. You have ' + red('%i') + ' seconds to login or be kicked.') % remaining) addTimer(5000, warnNickReserved, (cn, count+1, sessid))
def checkPlayers(self): addTimer(5000, self.checkPlayers, ()) if not self.enabled: return self.update_averages() if self.counter == 0: laggers = [] for player in players.all(): try: if not player.isSpectator( ) and player.avg_ping > self.max_ping: laggers.append(player.cn) except AttributeError: player.avg_ping = 0 remove_cns = [] for lagger in laggers: if lagger in self.warned_cns: ban(lagger, 0, 'lagging', -1) remove_cns.append(lagger) else: sbserver.playerMessage( lagger, warning( 'Your ping is too high. You will be kicked if it is not lowered.' )) self.warned_cns.append(lagger) for r_cns in remove_cns: self.warned_cns.remove(r_cns)
def onTeamkill(cn, tcn): try: if player(cn).teamkills() >= limit: ban(cn, duration, 'killing teammates', -1) elif warn_tk_limit and player(cn).teamkills() == 1: player(cn).message(warning(warn_tk_message.substitute(colordict, limit=limit))) except KeyError: pass
def onTeamkill(cn, tcn): try: if player(cn).teamkills() >= limit: ban(cn, duration, 'killing teammates', -1) elif warn_tk_limit and player(cn).teamkills() == 1: player(cn).message( warning(warn_tk_message.substitute(colordict, limit=limit))) except KeyError: pass
def checkModified(cn): try: p = player(cn) if p.gamevars['modified_map'] and spectate_map_modified: p.message(warning('You cannot play with a modified map.')) p.spectate() except KeyError: pass except ValueError: pass
def warnTagReserved(cn, count, sessid, nick): try: p = player(cn) except ValueError: return if p.name() != nick or sessid != p.sessionId(): return if len(p.registered_tags) == 0: return if count > 4: ban(cn, 0, 'Use of reserved clan tag', -1) p.warning_for_login = False return remaining = 25-(count*5) p.message(warning('Your are using a reserved clan tag. You have ' + red('%i') + ' seconds to login or be kicked.') % remaining) addTimer(5000, warnTagReserved, (cn, count+1, sessid, nick))
def checkPlayers(self): addTimer(5000, self.checkPlayers, ()) if not self.enabled: return self.update_averages() if self.counter == 0: laggers = [] for player in players.all(): try: if not player.isSpectator() and player.avg_ping > self.max_ping: laggers.append(player.cn) except AttributeError: player.avg_ping = 0 remove_cns = [] for lagger in laggers: if lagger in self.warned_cns: ban(lagger, 0, 'lagging', -1) remove_cns.append(lagger) else: sbserver.playerMessage(lagger, warning('Your ping is too high. You will be kicked if it is not lowered.')) self.warned_cns.append(lagger) for r_cns in remove_cns: self.warned_cns.remove(r_cns)