Example #1
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'))
Example #2
0
def listMasterCommands(cn, args):
	str = 'Master commands: '
	for cmd in command_info.items():
		if cmd[1].public:
			str += cmd[1].command + ' '
		elif cmd[1].master:
			str += cmd[1].command + ' '
	sauerbomber.playerMessage(cn, info(str))
Example #3
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')
Example #4
0
def msgHelpText(cn, cmd):
	try:
		helpinfo = command_info[cmd]
	except KeyError:
		sauerbomber.playerMessage(cn, error('Command not found'))
	else:
		msgs = []
		try:
			msgs.append(helpinfo.description)
		except AttributeError:
			pass
		for usage in helpinfo.usages:
			msgs.append(usage)
		for msg in msgs:
			sauerbomber.playerMessage(cn, info(msg))
Example #5
0
	def trigger(self, cn, command, text):
		p = player(cn)
		if self.command_handlers.has_key(command):
			for func in self.command_handlers[command]:
				try:
					func(cn, text)
				except UsageError, e:
					try:
						usages = command_info[command].usages
					except KeyError:
						usages = []
					p.message(error('Invalid Usage of #' + command + ' command. ' + str(e)))
					for usage in usages:
						p.message(info('Usage: ' + command + ' ' + usage))
				except StateError, e:
					p.message(error(str(e)))
				except ArgumentValueError, e:
					p.message(error('Invalid argument. ' + str(e)))
Example #6
0
def onRegisterCommand(cn, args):
	'''@description Register account with server
	   @usage email password
	   @public'''
	args = args.split(' ')
	if len(args) != 2:
		raise UsageError()
	try:
		dbmanager.query(User).filter(User.email==args[0]).one()
	except NoResultFound:
		if not isValidEmail(args[0]):
			raise ArgumentValueError('Invalid email address')
		user = User(args[0], args[1])
		session.add(user)
		session.commit()
		sauerbomber.playerMessage(cn, info('Account created'))
		return
	except MultipleResultsFound:
		pass
	raise StateError('An account with that email already exists')
Example #7
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)))
Example #8
0
def listAdminCommands(cn, args):
	str = 'Admin commands: '
	for cmd in command_info.items():
		str += cmd[1].command + ' '
	sauerbomber.playerMessage(cn, info(str))
Example #9
0
def listPublicCommands(cn, args):
	str = 'Public commands: '
	for cmd in command_info.items():
		if cmd[1].public:
			str += cmd[1].command + ' '
	sauerbomber.playerMessage(cn, info(str))
Example #10
0
def onRelAdmin(cn):
	sauerbomber.message(info(ratemp.substitute(colordict, name=sauerbomber.playerName(cn))))
Example #11
0
def onRelMaster(cn):
	sauerbomber.message(info(rmtemp.substitute(colordict, name=sauerbomber.playerName(cn))))
Example #12
0
def onAuthSuccess(cn, name):
	sauerbomber.message(info(authtemp.substitute(colordict, name=sauerbomber.playerName(cn), authname=name)))