Пример #1
0
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))
Пример #2
0
def login(cn, user):
	if isLoggedIn(cn):
		raise StateError('You are already logged in')
	player(cn).user = user
	player(cn).logged_in = True
	triggerServerEvent('player_logged_in', (cn,))
	sauerbomber.message(info(green(sauerbomber.playerName(cn)) + ' is verified'))
Пример #3
0
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))
Пример #4
0
def ban(cn, seconds, reason, banner_cn):
	ip = sauerbomber.playerIpLong(cn)
	expiration = time.time() + seconds
	nick = sauerbomber.playerName(cn)
	if banner_cn != -1:
		banner_ip = sauerbomber.playerIpLong(banner_cn)
		banner_nick = sauerbomber.playerName(banner_cn)
	else:
		banner_ip = 0
		banner_nick = ''
	newban = Ban(ip, expiration, reason, nick, banner_ip, banner_nick, time.time())
	session.add(newban)
	session.commit()
	addTimer(200, sauerbomber.playerKick, (cn,))
	logging.info('Player %s (%s) banned for %s by %s (%s)',
		nick,
		ipLongToString(ip),
		reason,
		banner_nick,
		ipLongToString(banner_ip))
	sauerbomber.message(info(ban_message.substitute(colordict, name=nick, seconds=seconds, reason=reason)))
Пример #5
0
def onLinkName(cn, args):
	'''@description Link name to server account, and reserve name.
	   @usage
	   @public'''
	if args != '':
		raise UsageError()
	if not isLoggedIn(cn):
		raise StateError('You must be logged in to link a name to your account')
	if sauerbomber.playerName(cn) in blocked_names:
		raise StateError('You can not reserve this name')
	try:
		dbmanager.query(NickAccount).filter(NickAccount.nick==sauerbomber.playerName(cn)).one()
	except NoResultFound:
		user = loggedInAs(cn)
		nickacct = NickAccount(sauerbomber.playerName(cn), user.id)
		session.add(nickacct)
		session.commit()
		sauerbomber.playerMessage(cn, info('Your name is now linked to your account.'))
		sauerbomber.playerMessage(cn, info('You may now login with /setmaster password'))
		return
	except MultipleResultsFound:
		pass
	raise StateError('Your name is already linked to an account')
Пример #6
0
 def name(self):
     """Name of client"""
     return sauerbomber.playerName(self.cn)
Пример #7
0
def onRelAdmin(cn):
	sauerbomber.message(info(ratemp.substitute(colordict, name=sauerbomber.playerName(cn))))
Пример #8
0
def onRelMaster(cn):
	sauerbomber.message(info(rmtemp.substitute(colordict, name=sauerbomber.playerName(cn))))
Пример #9
0
def onAuthSuccess(cn, name):
	sauerbomber.message(info(authtemp.substitute(colordict, name=sauerbomber.playerName(cn), authname=name)))