Пример #1
0
def onUserPrivCmd(cn, args):
	'''@description Set privileges for server account
	   @usage <cn> <action> <level>
	   @admin'''
	sp = args.split(' ')
	try:
		if sp[0] == 'set':
			subcmd = sp[0]
			tcn = int(sp[2])
			args = sp[1]
		elif sp[0] == 'wipe':
			subcmd = sp[0]
			tcn = int(sp[1])
			args = 'user'
		else:
			subcmd = sp[1]
			tcn = int(sp[0])
			args = sp[2]
	except ValueError:
		raise UsageError()

	if subcmd == 'add':
		userPrivSetCmd(cn, tcn, args)
	elif subcmd == 'del':
		userPrivSetCmd(cn, tcn, 'user')
	elif subcmd == 'set':
		userPrivSetCmd(cn, tcn, args)
	elif subcmd == 'wipe':
		userPrivSetCmd(cn, tcn, args)
	else:
		raise UsageError()
Пример #2
0
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)
Пример #3
0
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()))
Пример #4
0
def onMinsLeft(cn, args):
	'''@description Set minutes left in current match
	   @usage minutes
	   @master'''
	if args == '':
		raise UsageError()
	else:
		sbserver.setMinsRemaining(int(args))
Пример #5
0
def onResize(cn, args):
	'''@description Change maximum clients allowed in server
	   @usage maxclients
	   @admin'''
	if args == '':
		raise UsageError()
	else:
		size = int(args)
		sbserver.setMaxClients(int(args))
Пример #6
0
def serverMessage(cn, args):
	'''@description Broadcast message to all clients in server
	   @usage message
	   @master'''
	if args == '':
		raise UsageError()
	else:
		msg = servermsg_template.substitute(colordict, sender=sbserver.playerName(cn), message=args)
		sbserver.message(msg)
Пример #7
0
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))
Пример #8
0
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()
Пример #9
0
def pingLimiterCmd(cn, args):
    '''@description Enable or disable kicking high ping users
	   @usage enable/disable'''
    if args == 'enable':
        limiter.enabled = True
        sbserver.playerMessage(cn, notice('Ping limiter enabled'))
    elif args == 'disable':
        limiter.enabled = False
        sbserver.playerMessage(cn, notice('Ping limiter disabled'))
    else:
        raise UsageError('enable/disable')
Пример #10
0
def onPmCommand(cn, args):
	'''@description Send a private message
	   @usage <cn> <message>
	   @public'''
	args = args.split()
	if len(args) < 2:
		raise UsageError()
	i = 0
	for key in args:
		if i > 1:
			args[1] += (" " + str(key))
		i += 1
	player(int(args[0])).message(pm_template.substitute(colordict, sender=player(cn).name(), message=args[1]))
Пример #11
0
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)')
Пример #12
0
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)))
Пример #13
0
def clanWar(cn, args):
    '''@description Start a clan war with current teams
	   @usage map (mode)'''
    sender = player(cn)
    if args == '':
        raise UsageError()
    else:
        args = args.split(' ')
        if len(args) == 1:
            map = args
            mode = currentMode()
        elif len(args) == 2:
            map = args[0]
            try:
                mode = modeNumber(args[1])
            except ValueError:
                raise ArgumentValueError('Invalid game mode')
        persistentTeams(True)
        setMap(map, mode)
        setMasterMode(2)
        setPaused(True, cn)
        setFrozen(True)
        clanWarTimer(10, cn)