예제 #1
0
파일: __init__.py 프로젝트: pguenth/xsbs
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))
예제 #2
0
 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)
예제 #3
0
def onLogin(cn):
	try:
		p = player(cn)
		u = p.user
	except AttributeError:
		logging.error('Got login event but no user object for player.')
		return
	try:
		for tag in p.registered_tags:
			t = p.registered_tags.pop(0)
			if userBelongsTo(u, t):
				return
			else:
				ban(cn, 0, 'Use of reserved clan tag', -1)
	except AttributeError:
		return
예제 #4
0
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))
예제 #5
0
파일: bans.py 프로젝트: GunioRobot/xsbs
def onBanCmd(cn, text):
	'''@description Ban user from server
	   @usage <seconds> (reason)'''
	sp = text.split(' ')
	p = player(cn)
	try:
		tcn = int(sp[0])
		ip = p.ipLong()
		reason = ''
		length = 0
		if len(sp) >= 3:
			reason = sp[2]
		else:
			reason = default_reason
		if len(sp) >= 2:
			length = int(sp[1])
		else:
			length = int(default_ban_length)
		ban(tcn, length, reason, cn)
	except (ValueError, KeyError):
		raise UsageError('cn (duration) (reason)')
예제 #6
0
파일: bans.py 프로젝트: pguenth/xsbs
def onBanCmd(cn, text):
    '''@description Ban user from server
	   @usage <seconds> (reason)'''
    sp = text.split(' ')
    p = player(cn)
    try:
        tcn = int(sp[0])
        ip = p.ipLong()
        reason = ''
        length = 0
        if len(sp) >= 3:
            reason = sp[2]
        else:
            reason = default_reason
        if len(sp) >= 2:
            length = int(sp[1])
        else:
            length = int(default_ban_length)
        ban(tcn, length, reason, cn)
    except (ValueError, KeyError):
        raise UsageError('cn (duration) (reason)')
예제 #7
0
	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)
예제 #8
0
파일: bans.py 프로젝트: GunioRobot/xsbs
def onKick(cn, tcn):
	ban(tcn, 14500, 'Unspecified reason', cn)
예제 #9
0
파일: bans.py 프로젝트: pguenth/xsbs
def onKick(cn, tcn):
    ban(tcn, 14500, 'Unspecified reason', cn)