示例#1
0
def namesCmd(cn, args):
    '''@description Display names used by client
	   @usage cn
	   @public'''
    if master_required and not isAtLeastMaster(cn):
        insufficientPermissions(cn)
        return
    if args == '':
        raise UsageError()
        return
    try:
        tcn = int(args)
        names = dbmanager.query(IpToNick).filter(
            IpToNick.ip == sbserver.playerIpLong(tcn)).all()
        if len(names) == 0:
            sbserver.playerMessage(cn, info('No names found'))
            return
    except NoResultFound:
        sbserver.playerMessage(cn, info('No names found'))
        return
    except ValueError:
        sbserver.playerMessage(cn, error('Invalid cn'))
        return
    namestr = 'Other known names: '
    for name in names:
        namestr += name.nick + ' '
    sbserver.playerMessage(cn, info(namestr))
示例#2
0
def namesCmd(cn, args):
	'''@description Display names used by client
	   @usage cn
	   @public'''
	if master_required and not isAtLeastMaster(cn):
		insufficientPermissions(cn)
		return
	if args == '':
		raise UsageError()
		return
	try:
		tcn = int(args)
		names = dbmanager.query(IpToNick).filter(IpToNick.ip==sbserver.playerIpLong(tcn)).all()
		if len(names) == 0:
			sbserver.playerMessage(cn, info('No names found'))
			return
	except NoResultFound:
		sbserver.playerMessage(cn, info('No names found'))
		return
	except ValueError:
		sbserver.playerMessage(cn, error('Invalid cn'))
		return
	namestr = 'Other known names: '
	for name in names:
		namestr += name.nick + ' '
	sbserver.playerMessage(cn, info(namestr))
示例#3
0
文件: ctl.py 项目: pguenth/xsbs
def userPrivSetCmd(cn, tcn, args):
	user_id = player(tcn).user.id
	if args == 'user':
		try:
			if isUser(player(tcn).user.id):
				sbserver.playerMessage(cn, error('%s already has user permissions.' % sbserver.playerName(tcn)))
				return
		except (ValueError, AttributeError):
			pass
		else:
			try:
				user = loggedInAs(tcn)
			except AttributeError:
				sbserver.playerMessage(cn, error('%s is not logged in.' % sbserver.playerName(tcn)))
			else:
				dbmanager.query(UserPrivilege).filter(UserPrivilege.user_id==user_id).update({ 'privilege': None })
				session.add(UserPrivilege(0, user.id))
				session.commit()
				sbserver.playerMessage(cn, info('User privilege has been given to %s (%s)' % (sbserver.playerName(tcn), user.email)))
	elif args == 'master':
		try:
			if isUserMaster(player(tcn).user.id):
				sbserver.playerMessage(cn, error('%s already has master permissions.' % sbserver.playerName(tcn)))
				return
		except (ValueError, AttributeError):
			pass
		else:
			try:
				user = loggedInAs(tcn)
			except AttributeError:
				sbserver.playerMessage(cn, error('%s is not logged in.' % sbserver.playerName(tcn)))
			else:
				dbmanager.query(UserPrivilege).filter(UserPrivilege.user_id==user_id).update({ 'privilege': None })
				session.add(UserPrivilege(1, user.id))
				session.commit()
				sbserver.playerMessage(cn, info('Master privilege has been given to %s (%s)' % (sbserver.playerName(tcn), user.email)))
	elif args == 'admin':
		try:
			if isUserAdmin(player(tcn).user.id):
				sbserver.playerMessage(cn, error('%s already has admin permissions.' % sbserver.playerName(tcn)))
				return
		except (ValueError, AttributeError):
			pass
		else:
			try:
				user = loggedInAs(tcn)
			except AttributeError:
				sbserver.playerMessage(cn, error('%s is not logged in.' % sbserver.playerName(tcn)))
			else:
				dbmanager.query(UserPrivilege).filter(UserPrivilege.user_id==user_id).update({ 'privilege': None })
				session.add(UserPrivilege(2, user.id))
				session.commit()
				sbserver.playerMessage(cn, info('Admin privilege has been given to %s (%s)' % (sbserver.playerName(tcn), user.email)))
	else:
		sbserver.playerMessage(cn, error('Privilege level must be \'master\' to set master permissions and \'admin\' to set master or admin permissions'))
示例#4
0
文件: ctl.py 项目: GunioRobot/xsbs
def userPrivSetCmd(cn, tcn, args):
	user_id = player(tcn).user.id
	if args == 'user':
		try:
			if isUser(player(tcn).user.id):
				sbserver.playerMessage(cn, error('%s already has user permissions.' % sbserver.playerName(tcn)))
				return
		except (ValueError, AttributeError):
			pass
		else:
			try:
				user = loggedInAs(tcn)
			except AttributeError:
				sbserver.playerMessage(cn, error('%s is not logged in.' % sbserver.playerName(tcn)))
			else:
				dbmanager.query(UserPrivilege).filter(UserPrivilege.user_id==user_id).update({ 'privilege': None })
				session.add(UserPrivilege(0, user.id))
				session.commit()
				sbserver.playerMessage(cn, info('User privilege has been given to %s (%s)' % (sbserver.playerName(tcn), user.email)))
	elif args == 'master':
		try:
			if isUserMaster(player(tcn).user.id):
				sbserver.playerMessage(cn, error('%s already has master permissions.' % sbserver.playerName(tcn)))
				return
		except (ValueError, AttributeError):
			pass
		else:
			try:
				user = loggedInAs(tcn)
			except AttributeError:
				sbserver.playerMessage(cn, error('%s is not logged in.' % sbserver.playerName(tcn)))
			else:
				dbmanager.query(UserPrivilege).filter(UserPrivilege.user_id==user_id).update({ 'privilege': None })
				session.add(UserPrivilege(1, user.id))
				session.commit()
				sbserver.playerMessage(cn, info('Master privilege has been given to %s (%s)' % (sbserver.playerName(tcn), user.email)))
	elif args == 'admin':
		try:
			if isUserAdmin(player(tcn).user.id):
				sbserver.playerMessage(cn, error('%s already has admin permissions.' % sbserver.playerName(tcn)))
				return
		except (ValueError, AttributeError):
			pass
		else:
			try:
				user = loggedInAs(tcn)
			except AttributeError:
				sbserver.playerMessage(cn, error('%s is not logged in.' % sbserver.playerName(tcn)))
			else:
				dbmanager.query(UserPrivilege).filter(UserPrivilege.user_id==user_id).update({ 'privilege': None })
				session.add(UserPrivilege(2, user.id))
				session.commit()
				sbserver.playerMessage(cn, info('Admin privilege has been given to %s (%s)' % (sbserver.playerName(tcn), user.email)))
	else:
		sbserver.playerMessage(cn, error('Privilege level must be \'master\' to set master permissions and \'admin\' to set master or admin permissions'))
示例#5
0
def mapModifiedSpecCmd(cn, args):
    '''@description Enable or disable spectate clients with modified map
	   @usage enable/disable'''
    p = player(cn)
    if args == 'disable':
        spectate_map_modified = False
        p.message(info('Spectate modified mapes disabled'))
    elif args == 'enable':
        spectate_map_modified = True
        p.message(info('Spectate modified mapes enabled'))
    else:
        p.message(error('Usage: #mapmodifiedspec (enable/disable)'))
示例#6
0
def mapModifiedSpecCmd(cn, args):
	'''@description Enable or disable spectate clients with modified map
	   @usage enable/disable'''
	p = player(cn)
	if args == 'disable':
		spectate_map_modified = False
		p.message(info('Spectate modified mapes disabled'))
	elif args == 'enable':
		spectate_map_modified = True
		p.message(info('Spectate modified mapes enabled'))
	else:
		p.message(error('Usage: #mapmodifiedspec (enable/disable)'))
示例#7
0
文件: demo.py 项目: pguenth/xsbs
def setPersistantDemoRecord(cn, args):
	'''@description Enable/disable persistant demo recording
	   @usage enable/disable'''
	if args == 'enable':
		player(cn).message(info('Enabling persistant demo recording'))
		persistent_recording = True
		sbserver.setRecordNextMatch(persistent_recording)

	elif args == 'disable':
		player(cn).message(info('Disabling persistant demo recording'))
		persistent_recording = False
		sbserver.setRecordNextMatch(persistent_recording)
	else:
		raise UsageError()
示例#8
0
文件: bans.py 项目: GunioRobot/xsbs
def onKickCommand(cn, args):
	'''@description Kick player from the server without ban time
	   @usage <cn>'''
	tcn = int(args)
	t = player(tcn)
	serverMessage(info(kick_message.substitute(colordict, name=p.name())))
	t.kick()
示例#9
0
文件: bans.py 项目: pguenth/xsbs
def onKickCommand(cn, args):
    '''@description Kick player from the server without ban time
	   @usage <cn>'''
    tcn = int(args)
    t = player(tcn)
    serverMessage(info(kick_message.substitute(colordict, name=p.name())))
    t.kick()
示例#10
0
文件: mapvote.py 项目: pguenth/xsbs
def onMapVote(cn, mapname, mapmode):
    p = player(cn)
    if sbserver.mapName() == '':
        setMap(mapname, mapmode)
    elif isAtLeastMaster(cn) and sbserver.masterMode() > 0:
        setMap(mapname, mapmode)
    elif mapmode != sbserver.gameMode() and (lock_mode or not allow_modevote):
        p.message(error('You cannot vote for a new game mode'))
    else:
        try:
            vote = player(cn).gamevars['mapvote']
            allow_vote = vote[0] != mapname and vote[1] != mapmode
        except KeyError:
            allow_vote = True
        if allow_vote:
            sbserver.message(
                info(
                    request_temp.substitute(
                        colordict,
                        user=p.name(),
                        modename=sbserver.modeName(mapmode),
                        mapname=mapname)))
            p.gamevars['mapvote'] = (mapname, mapmode)
        else:
            sbserver.playerMessage(
                cn, error('You have already requested this map.'))
    countVotes()
示例#11
0
文件: mute.py 项目: pguenth/xsbs
def onUnmuteCommand(cn, args):
    '''@description Unmute a player
	   @usage cn'''
    try:
        args = args.split(' ')
        tcn = int(args[0])
        if len(args) > 1:
            raise KeyError
        try:
            p = player(tcn)
            if p.is_muted:
                p.is_muted = False
                muter = player(cn).name()
                sbserver.message(
                    info(
                        unmuted_temp.substitute(colordict,
                                                muted_name=p.name(),
                                                muter=muter)))
            else:
                raise StateError('Specified player is not crrently muted')
        except AttributeError:
            raise StateError('Specified player is not currently muted.')
    except KeyError:
        raise UsageError('No cn specified')
    except ValueError:
        raise ArgumentValueError('Invalid player cn')
示例#12
0
文件: mute.py 项目: pguenth/xsbs
def onMuteCommand(cn, args):
    '''@description Mute a player
	   @usage cn'''
    try:
        args = args.split(' ')
        tcn = int(args[0])
        if len(args) > 1:
            raise KeyError
        try:
            p = player(tcn)
        except ValueError:
            raise StateError('Invalid player cn')
        else:
            try:
                muted = p.is_muted
            except AttributeError:
                muted = False
            if muted:
                raise StateError('Player is already muted.')
            else:
                p.is_muted = True
                name = p.name()
                muter = player(cn).name()
                sbserver.message(
                    info(
                        muted_temp.substitute(colordict,
                                              muted_name=name,
                                              muter=muter)))
    except KeyError:
        raise UsageError()
示例#13
0
	def check_domination(self):
		if self.last_victim == self.current_victim:
			self.domination_count += 1
		else:
			self.domination_count = 0
		if self.domination_count in dommessages.keys():
			sbserver.message(info(dommessages[self.domination_count].substitute(killername=player(self.playercn).name(), victimname=player(self.last_victim).name())))
示例#14
0
文件: mute.py 项目: GunioRobot/xsbs
def onMuteCommand(cn, args):
	'''@description Mute a player
	   @usage cn'''
	try:
		args = args.split(' ')
		tcn = int(args[0])
		if len(args) > 1:
			raise KeyError
		try:	
			p = player(tcn)
		except ValueError:
			raise StateError('Invalid player cn')
		else:
			try:
				muted = p.is_muted
			except AttributeError:
			 	muted = False
			if muted:
				raise StateError('Player is already muted.')
			else:
				p.is_muted = True
				name = p.name()
				muter = player(cn).name()
				sbserver.message(info(muted_temp.substitute(colordict, muted_name=name, muter=muter)))
	except KeyError:
		raise UsageError()
示例#15
0
文件: __init__.py 项目: pguenth/xsbs
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,))
	sbserver.message(info(green(sbserver.playerName(cn)) + ' is verified'))
示例#16
0
文件: ctl.py 项目: GunioRobot/xsbs
def playerIp(cn, args):
	'''@description Get string representation of client ip
	   @usage cn
	   @master'''
	if args == '':
		raise UsageError()
	else:
		sbserver.message(info(player(int(args)).ipString()))
示例#17
0
文件: ctl.py 项目: pguenth/xsbs
def playerIp(cn, args):
	'''@description Get string representation of client ip
	   @usage cn
	   @master'''
	if args == '':
		raise UsageError()
	else:
		sbserver.message(info(player(int(args)).ipString()))
示例#18
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 + ' '
	sbserver.playerMessage(cn, info(str))
示例#19
0
文件: ctl.py 项目: GunioRobot/xsbs
def onSmiteCommand(cn, args):
	'''@description Strike a player down
	   @usage <cn>
	   @master'''
	if args == '':
		raise UsageError()
	p = player(cn)
	t = player(int(args))
	sendServerMessage(info(smite_template.substitute(colordict, smiter=p.name(), smited=t.name())))
	t.suicide()
示例#20
0
文件: bans.py 项目: GunioRobot/xsbs
def onRecentBans(cn, args):
	'''@description Recently added bans
	   @usage'''
	p = player(cn)
	if args != '':
		raise UsageError()
	else:
		recent = dbmanager.query(Ban).order_by(Ban.time.desc())[:5]
		for ban in recent:
			p.message(info('Nick: %s' % ban.nick))
示例#21
0
文件: bans.py 项目: pguenth/xsbs
def onRecentBans(cn, args):
    '''@description Recently added bans
	   @usage'''
    p = player(cn)
    if args != '':
        raise UsageError()
    else:
        recent = dbmanager.query(Ban).order_by(Ban.time.desc())[:5]
        for ban in recent:
            p.message(info('Nick: %s' % ban.nick))
示例#22
0
文件: ctl.py 项目: pguenth/xsbs
def onSmiteCommand(cn, args):
	'''@description Strike a player down
	   @usage <cn>
	   @master'''
	if args == '':
		raise UsageError()
	p = player(cn)
	t = player(int(args))
	sendServerMessage(info(smite_template.substitute(colordict, smiter=p.name(), smited=t.name())))
	t.suicide()
示例#23
0
def onNextMapCmd(cn, args):
	'''@description Display next map
	   @usage
	   @public'''
	if args != '':
		sbserver.playerMessage(cn, error('Usage: #nextmap'))
	else:
		try:
			sbserver.playerMessage(cn, info(nextmap_response.substitute(colordict, mapname=getSuccessor(sbserver.gameMode(), sbserver.mapName()))))
		except (KeyError, ValueError):
			sbserver.playerMessage(cn, error('Could not determine next map'))
示例#24
0
文件: ctl.py 项目: pguenth/xsbs
def onGiveMaster(cn, args):
	'''@description Give master to a client
	   @usage cn
	   @master'''
	if args == '':
		raise UsageError()
		return
	try:
		tcn = int(args)
	except TypeError:
		raise UsageError()
		return
	sbserver.playerMessage(cn, info('You have given master to %s') % sbserver.playerName(tcn))
	sbserver.setMaster(tcn)
示例#25
0
文件: ctl.py 项目: GunioRobot/xsbs
def onGiveMaster(cn, args):
	'''@description Give master to a client
	   @usage cn
	   @master'''
	if args == '':
		raise UsageError()
		return
	try:
		tcn = int(args)
	except TypeError:
		raise UsageError()
		return
	sbserver.playerMessage(cn, info('You have given master to %s') % sbserver.playerName(tcn))
	sbserver.setMaster(tcn)
示例#26
0
文件: __init__.py 项目: pguenth/xsbs
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 sbserver.playerName(cn) in blocked_names:
		raise StateError('You can not reserve this name')
	try:
		dbmanager.query(NickAccount).filter(NickAccount.nick==sbserver.playerName(cn)).one()
	except NoResultFound:
		user = loggedInAs(cn)
		nickacct = NickAccount(sbserver.playerName(cn), user.id)
		session.add(nickacct)
		session.commit()
		sbserver.playerMessage(cn, info('Your name is now linked to your account.'))
		sbserver.playerMessage(cn, info('You may now login with /setmaster password'))
		return
	except MultipleResultsFound:
		pass
	raise StateError('Your name is already linked to an account')
示例#27
0
文件: bans.py 项目: pguenth/xsbs
def onBanName(cn, args):
    '''@description Ban name from the server
	   @usage <name>'''
    p = player(cn)
    reason = args.split(' ')
    if len(reason) == 1:
        nick = reason[0]
        reason = 'Unspecified reason'
    else:
        nick = reason.pop(0)
        reason = args[len(nick) + 1:]
    b = BanNick(nick, reason)
    session.add(b)
    session.commit()
    p.message(info('Inserted nick ban of %s for %s' % (nick, reason)))
示例#28
0
def msgHelpText(cn, cmd):
	try:
		helpinfo = command_info[cmd]
	except KeyError:
		sbserver.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:
			sbserver.playerMessage(cn, info(msg))
示例#29
0
文件: bans.py 项目: GunioRobot/xsbs
def onBanName(cn, args):
	'''@description Ban name from the server
	   @usage <name>'''
	p = player(cn)
	reason = args.split(' ')
	if len(reason) == 1:
		nick = reason[0]
		reason = 'Unspecified reason'
	else:
		nick = reason.pop(0)
		reason = args[len(nick)+1:]
	b = BanNick(nick, reason)
	session.add(b)
	session.commit()
	p.message(info('Inserted nick ban of %s for %s' % (nick, reason)))
示例#30
0
	def check_ownage(self):
		if (self.current_kill_time - self.last_kill_time) < interval:
			self.ownage_count += 1

			#check whether this level of multikill warrants a message
			if self.ownage_count in neomessages.keys():
				try:
					player(self.playercn).message(info(neomessages[self.ownage_count].substitute()))
				except ValueError:
					pass
				self.last_ownage_count = self.ownage_count
		else:
			#that multikill session ended so the multikill counter should be incremented
			if self.last_ownage_count != 0:
				self.multikill_counts[self.last_ownage_count] += 1
			self.ownage_count = 1
示例#31
0
def onNextMapCmd(cn, args):
    '''@description Display next map
	   @usage
	   @public'''
    if args != '':
        sbserver.playerMessage(cn, error('Usage: #nextmap'))
    else:
        try:
            sbserver.playerMessage(
                cn,
                info(
                    nextmap_response.substitute(colordict,
                                                mapname=getSuccessor(
                                                    sbserver.gameMode(),
                                                    sbserver.mapName()))))
        except (KeyError, ValueError):
            sbserver.playerMessage(cn, error('Could not determine next map'))
示例#32
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)))
示例#33
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)))
示例#34
0
文件: bans.py 项目: GunioRobot/xsbs
def onInsertBan(cn, args):
	'''@description Intert ban for ip address
	   @usage <ip> <seconds> (reason)'''
	p = player(cn)
	args = args.split(' ')
	if len(args) < 2:
		raise UsageError('ip length (reason)')
	else:
		ip = ipStringToLong(args[0])
		length = int(args[1])
		try:
			reason = args[2]
		except IndexError:
		 	reason = 'Unspecified reason'
		expiration = time.time() + length
		newban = Ban(ip, expiration, reason, 'Unnamed', 0, 'Unnamed', time.time())
		session.add(newban)
		session.commit()
		p.message(info('Inserted ban for %s for %i seconds for %s.' % (ipLongToString(ip), length, reason)))
示例#35
0
def onVoteKick(cn, args):
	'''@description Vote to kick a player from server
	   @usage <cn>'''
	if args == '':
		sbserver.playerMessage(cn, error('Usage #votekick <cn>'))
	else:
		try:
			tcn = int(args)
			if player(cn).votekick == tcn:
				sbserver.playerMessage(cn, error('You have already voted to kick that player.'))
				allow_vote = False
			else:
				allow_vote = True
		except AttributeError:
			allow_vote = True
		if allow_vote:
			sbserver.message(info(vktemp.substitute(colordict, voter=sbserver.playerName(cn), victim=sbserver.playerName(tcn))))
			player(cn).votekick = int(args)
			checkVotes(int(args))
示例#36
0
文件: __init__.py 项目: pguenth/xsbs
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()
		sbserver.playerMessage(cn, info('Account created'))
		return
	except MultipleResultsFound:
		pass
	raise StateError('An account with that email already exists')
示例#37
0
def countVotes():
	players = allPlayers()
	votes_needed = (len(players) / 2)
	bestmap = ''
	bestmode = 0
	bestcount = 0
	candidates = []
	for p in allPlayers():
		try:
			pv = p.gamevars['mapvote']
			count = vote(candidates, pv)
			if count > bestcount:
				bestmap = pv[0]
				bestmode = pv[1]
				bestcount = count
		except (AttributeError, KeyError):
			pass
	if bestcount > votes_needed:
		serverMessage(info('Vote passed.'))
		setMap(bestmap, bestmode)
示例#38
0
文件: mapvote.py 项目: pguenth/xsbs
def countVotes():
    players = allPlayers()
    votes_needed = (len(players) / 2)
    bestmap = ''
    bestmode = 0
    bestcount = 0
    candidates = []
    for p in allPlayers():
        try:
            pv = p.gamevars['mapvote']
            count = vote(candidates, pv)
            if count > bestcount:
                bestmap = pv[0]
                bestmode = pv[1]
                bestcount = count
        except (AttributeError, KeyError):
            pass
    if bestcount > votes_needed:
        serverMessage(info('Vote passed.'))
        setMap(bestmap, bestmode)
示例#39
0
文件: ban.py 项目: greghaynes/xsbs
def ban(cn, seconds, reason, banner_cn):
	ip = sbserver.playerIpLong(cn)
	expiration = time.time() + seconds
	nick = sbserver.playerName(cn)
	if banner_cn != -1:
		banner_ip = sbserver.playerIpLong(banner_cn)
		banner_nick = sbserver.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, sbserver.playerKick, (cn,))
	logging.info('Player %s (%s) banned for %s by %s (%s)',
		nick,
		ipLongToString(ip),
		reason,
		banner_nick,
		ipLongToString(banner_ip))
	sbserver.message(info(ban_message.substitute(colordict, name=nick, seconds=seconds, reason=reason)))
示例#40
0
文件: mute.py 项目: GunioRobot/xsbs
def onUnmuteCommand(cn, args):
	'''@description Unmute a player
	   @usage cn'''
	try:
		args = args.split(' ')
		tcn = int(args[0])
		if len(args) > 1:
			raise KeyError
		try:
			p = player(tcn)
			if p.is_muted:
				p.is_muted = False
				muter = player(cn).name()
				sbserver.message(info(unmuted_temp.substitute(colordict, muted_name=p.name(), muter=muter)))
			else:
				raise StateError('Specified player is not crrently muted')
		except AttributeError:
			raise StateError('Specified player is not currently muted.')
	except KeyError:
		raise UsageError('No cn specified')
	except ValueError:
		raise ArgumentValueError('Invalid player cn')
示例#41
0
文件: bans.py 项目: pguenth/xsbs
def onInsertBan(cn, args):
    '''@description Intert ban for ip address
	   @usage <ip> <seconds> (reason)'''
    p = player(cn)
    args = args.split(' ')
    if len(args) < 2:
        raise UsageError('ip length (reason)')
    else:
        ip = ipStringToLong(args[0])
        length = int(args[1])
        try:
            reason = args[2]
        except IndexError:
            reason = 'Unspecified reason'
        expiration = time.time() + length
        newban = Ban(ip, expiration, reason, 'Unnamed', 0, 'Unnamed',
                     time.time())
        session.add(newban)
        session.commit()
        p.message(
            info('Inserted ban for %s for %i seconds for %s.' %
                 (ipLongToString(ip), length, reason)))
示例#42
0
def onMapVote(cn, mapname, mapmode):
	p = player(cn)
	if sbserver.mapName() == '':
		setMap(mapname, mapmode)
	elif isAtLeastMaster(cn) and sbserver.masterMode() > 0:
		setMap(mapname, mapmode)
	elif mapmode != sbserver.gameMode() and (lock_mode or not allow_modevote):
		p.message(error('You cannot vote for a new game mode'))
	else:
		try:
			vote = player(cn).gamevars['mapvote']
			allow_vote = vote[0] != mapname and vote[1] != mapmode
		except KeyError:
			allow_vote = True
		if allow_vote:
			sbserver.message(info(request_temp.substitute(colordict,
				user=p.name(),
				modename=sbserver.modeName(mapmode),
				mapname=mapname)))
			p.gamevars['mapvote'] = (mapname, mapmode)
		else:
			sbserver.playerMessage(cn, error('You have already requested this map.'))
	countVotes()
示例#43
0
文件: votekick.py 项目: pguenth/xsbs
def onVoteKick(cn, args):
    '''@description Vote to kick a player from server
	   @usage <cn>'''
    if args == '':
        sbserver.playerMessage(cn, error('Usage #votekick <cn>'))
    else:
        try:
            tcn = int(args)
            if player(cn).votekick == tcn:
                sbserver.playerMessage(
                    cn, error('You have already voted to kick that player.'))
                allow_vote = False
            else:
                allow_vote = True
        except AttributeError:
            allow_vote = True
        if allow_vote:
            sbserver.message(
                info(
                    vktemp.substitute(colordict,
                                      voter=sbserver.playerName(cn),
                                      victim=sbserver.playerName(tcn))))
            player(cn).votekick = int(args)
            checkVotes(int(args))
示例#44
0
文件: geoip.py 项目: greghaynes/xsbs
def announce(cn):
	p = player(cn)
	msg = string.Template(template).substitute(colordict, user=p.name(), country=getCountry(p.ipLong()))
	serverMessage(info(msg))
示例#45
0
文件: duel.py 项目: GunioRobot/xsbs
def cancelDuel():
	endDuel()
	sbserver.message(info('Duel cancelled.'))
示例#46
0
	def check_if_ending_spree(self, killercn):
		if self.kills_since_death >= 5:
			if killercn == -2:
				sbserver.message(info(suicideendmsg.substitute(victimname=player(self.playercn).name())))
			else:
				sbserver.message(info(endmsg.substitute(victimname=player(self.playercn).name(), killername=player(killercn).name())))
示例#47
0
def listAdminCommands(cn, args):
	str = 'Admin commands: '
	for cmd in command_info.items():
		str += cmd[1].command + ' '
	sbserver.playerMessage(cn, info(str))
示例#48
0
def listPublicCommands(cn, args):
	str = 'Public commands: '
	for cmd in command_info.items():
		if cmd[1].public:
			str += cmd[1].command + ' '
	sbserver.playerMessage(cn, info(str))
示例#49
0
def setMM(cn, mm):
    sbserver.message((info(green('%s') + ' set master mode to ' + blue('%s')) %
                      (sbserver.playerName(cn), MMNAMES[mm])))
    sbserver.setMasterMode(mm)
示例#50
0
文件: duel.py 项目: pguenth/xsbs
def cancelDuel():
    endDuel()
    sbserver.message(info('Duel cancelled.'))