def warnNickReserved(cn, count, sessid): try: p = player(cn) except ValueError: return try: nickacct = p.warn_nickacct if nickacct.nick != sauerbomber.playerName(cn) or sessid != sauerbomber.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) pass 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) sauerbomber.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 onPlayerActive(cn): nick = sauerbomber.playerName(cn) p = player(cn) try: nickacct = nickReserver(sauerbomber.playerName(cn)) except NoResultFound: p.warning_for_login = False return p = player(cn) p.warning_for_login = True p.warn_nickacct = nickacct warnNickReserved(cn, 0, sauerbomber.playerSessionId(cn))
def sessionId(self): """Session ID of client""" return sauerbomber.playerSessionId(self.cn)