Beispiel #1
0
def cmdTeams(obj, t):
	msg = obj.data["msg"].split(" ")
	sender = obj.data["sender"]

	redPlayers = A.retrieveTeam('red')
	bluePlayers = A.retrieveTeam('blue')
	toTeam = 0
	fromTeam = None
	
	difference = abs(len(redPlayers) - len(bluePlayers))
	if difference <= 1:
		A.tell(sender, "Teams are already balanced.")
		return

	A.rcon('bigtext "AUTO-BALANCING TEAMS')

	if len(bluePlayers) > len(redPlayers):
		fromTeam = bluePlayers
		toTeam = 1
	elif len(redPlayers) > len(bluePlayers):
		fromTeam = redPlayers
		toTeam = 2
	
	while difference > 1:
		# pick a cid from fromTeam
		cid = random.choice(fromTeam)
		fromTeam.remove(cid)
		A.rcon("forceteam %s %s" % (cid, toTeam))
		difference -= 1
	
	A.say("Balanced teams.") #<<< should be told to the user?
Beispiel #2
0
def cmdHelp(obj, t): #@CREDIT Neek
	#format should be !command : Info \n
	msg = obj.data["msg"].split(" ")
	sender = obj.data["sender"]
	# No argument, list all commands
	if len(msg) == 1:
		reply = ''
		cmds = A.getCommands()
		keys = cmds.keys()
		keys.sort()
		A.tell(sender, "==Commands==")
		for k in keys:
			if len(reply) + len(A.B.prefix) > 50:
				A.tell(sender, reply)
				reply = ''
			if cmds[k][2] <= A.getClient(sender).group:
				if len(reply) > 0: reply += ", "
				reply += k + "(%d)" % cmds[k][2]
		A.tell(sender, reply)
	# Argument, provide description of command
	elif len(msg) == 2:
		cmd = msg[1].rstrip().lstrip('!')
		cmdobj = A.getCmd('!' + cmd)
		if cmdobj == None:
			A.tell(sender, "Unknown command: %s" % cmd)
		else:
			A.tell(sender, "%s: %s" % (cmd, cmdobj[1]))
Beispiel #3
0
def cmdKick(obj, t):
	msg = obj.data["msg"].split(" ")
	sender = obj.data["sender"]
	if len(msg) == 1: A.tell(sender, "Usage: !kick <user>")
	elif len(msg) == 2:
		if msg[1].isdigit():
			kick = int(msg[1]) #@DEV This needs a check to see if players name is 0 or something annoying like that
		else:
			cli = A.findClient(msg[1])
			if cli != None:
				kick = cli.uid
		A.rcon('clientkick %d' % kick)
Beispiel #4
0
def cmdTempBan(obj, t): 
	#!tempban Joey length reason
	db = database.DB()
	db.tableSelect('clients')
	msg = obj.data["msg"].split(" ", 3)
	sender = obj.data['sender']
	senderobj = A.findClient(sender)

	if len(msg) == 3: #!ban joey
		reason = 'No Reason Given'
	elif len(msg) == 4: #!ban joey my special reason
		reason = msg[3].strip()
	else: A.tell(sender, 'Usage: !tempban <player> <duration> [reason]')

	if 1 < len(msg) < 5:
		ctime = datetime.now()
		etime = datetime(ctime.year, ctime.month, ctime.day, ctime.hour, ctime.minute, ctime.second) + timedelta(minutes=const.timeparse(msg[2]))
		exptime = time.mktime(etime.timetuple())
		banr = A.findClient(msg[1])
		if banr != None:
			banrdb = db.rowFind(banr.cid)
			db.tableSelect('penalties')
			db.rowCreate({'userid':banr.cid, 'adminid':senderobj.cid, 'type':'tempban', 'reason':reason, 'time':ctime, 'expiration':exptime, 'status':1})
			db.commit()
			A.tell(banr.uid, 'Temp Banned tell %s' % etime.__str__())
			A.kick(banr.uid)
			A.tell(sender, 'Temp Banned %s tell %s!' % (banr.name, etime.__str__()))
	else: A.tell(sender, 'Usage: !tempban <player> <duration> [reason]')
Beispiel #5
0
def cmdNuke(obj, t):
	msg = obj.data["msg"].split(" ")
	sender = obj.data["sender"]
	if len(msg) == 1: A.tell(sender, "Usage: !nuke <user> <count>")
	else:
		if msg[1].isdigit():
			nuke = int(msg[1])
		else:
			cli = A.findClient(msg[1])
			if cli != None:
				nuke = cli.uid
		count = 1
		if len(msg) == 3:
			if canInt(msg[2]): count = int(msg[2])
		for i in range(count):
			A.rcon('nuke %d' % nuke)
			time.sleep(.8)
Beispiel #6
0
def cmdSlap(obj, t):
	msg = obj.data["msg"].split(" ")
	sender = obj.data["sender"]
	if len(msg) == 1: A.tell(sender, "Usage: !slap <user> <count>")
	else:
		if msg[1].isdigit():
			slap = int(msg[1])
		else:
			cli = A.findClient(msg[1])
			if cli != None:
				slap = cli.uid
			else: return None
		count = 1
		if len(msg) == 3:
			if canInt(msg[2]): count = int(msg[2])
		for i in range(count):
			A.rcon('slap %d' % slap)
			time.sleep(.8)
Beispiel #7
0
def cmdBan(obj, t):
	#!ban Joey He's an idiot
	db = database.DB()
	db.tableSelect('clients')
	msg = obj.data["msg"].split(" ", 2)
	sender = obj.data['sender']
	senderobj = A.findClient(sender)
	ctime = datetime.now()

	if len(msg) == 2: #!ban joey
		reason = 'No Reason Given'
	elif len(msg) == 3: #!ban joey my special reason
		reason = msg[2].strip()
	else: A.tell(sender, 'Usage: !ban <player> [reason]')

	if 1 < len(msg) < 4:
		banr = A.findClient(msg[1])
		if banr != None:
			banrdb = db.rowFind(banr.cid)
			db.tableSelect('penalties')
			db.rowCreate({'userid':banr.cid, 'adminid':senderobj.cid, 'type':'ban', 'reason':reason, 'time':ctime, 'expiration':-1, 'status':1})
			db.commit()
			A.kick(banr.uid)
			A.tell(sender, 'Banned %s!' % banr.name)
		else:
			A.tell(sender, 'No users matching %s' % msg[1])
Beispiel #8
0
def cmdLoadout(obj, t):
	msg = obj.msg.split(' ', 1)
	m = []
	if len(msg) == 2:
		usr = A.findClient(msg[1])
		if usr != None:
			#A.B.Clients[usr.uid].updateData(A.B.dumpUser(usr.uid)) This should refresh automatically w/ ClientUserInfo[Change]
			A.tell(obj.sender, 'Loadout for %s:' % A.B.Clients[usr.uid].name)
			for i in A.B.Clients[usr.uid].gear:
				if const.gearInfo[i] != None:
					m.append(const.gearInfo[i]['name'])
			A.tell(obj.sender, '%s' % ', '.join(m))
		else:
			A.tell(obj.sender, 'Unknown user %s' % msg[1])
	else:
		A.tell(obj.sender, 'Usage: !loadout <player>')
Beispiel #9
0
def cmdMap(obj, t):
	msg = obj.data["msg"].split(" ")
	sender = obj.data["sender"]
	if len(msg) == 1: A.tell(sender, "Usage: !map <map>")
	elif len(msg) == 2:
		maps = A.findMap(msg[1])
		if len(maps) == 0:
			A.tell(sender, "No map found matching that name")
		elif len(maps) > 1:
			A.tell(sender, "Found %d maps: %s" % (len(maps), maps))
		else:
			A.rcon('set thismap "map %s"' % maps[0])
			A.rcon('vstr thismap')
Beispiel #10
0
def cmdTime(obj, t):
	global TIMERZ
	sender = obj.data['sender']
	if sender in TIMERZ:
		if TIMERZ[sender].status == 0:
			TIMERZ[sender].start()
			A.tell(sender, 'Timer Started!')
		elif TIMERZ[sender].status == 1:
			TIMERZ[sender].stop()
			A.tell(sender, 'Timer Stopped: %s%s' % (A.GREEN, TIMERZ[sender].value()))
			TIMERZ[sender].reset()
	else:
		TIMERZ[sender] = Timer()
		TIMERZ[sender].start()
		A.tell(sender, 'Timer Started!')
Beispiel #11
0
def cmdLock(obj, t):
	#![un]lock user

	if len(obj.msgsplit) != 2: return A.tell(obj.sender, "Usage: %s <client>" % obj.cmd) #Sneaky bastard that I am

	playobj = A.findClient(obj.msgsplit[1])

	if 'fairplay_locked' not in playobj.__dict__.keys(): playobj.fairplay_locked = False

	if obj.cmd == '!lock':
		if playobj.fairplay_locked is True: return A.tell(obj.sender, "%s is already locked! Unlock with !unlock %s" % (playobj.name, playobj.uid))
		else: 
			playobj.fairplay_locked = True
			playobj.fairplay_lockedteam = playobj.team
		A.tell(obj.sender, 'Success! %s was locked to %s' % (playobj.name, playobj.team))

	elif obj.cmd == '!unlock':
		if playobj.fairplay_locked is True: 
			playobj.fairplay_locked = False
			playobj.fairplay_lockedteam = None #Will this cause an error? Cuz i'm thinking yeah it will...
		else: return A.tell(obj.sender, '%s is already unlocked!' % playobj.name)
		A.tell(obj.sender, 'Success! %s was unlocked!' % (playobj.name))
Beispiel #12
0
def cmdForce(obj, t):
	msg = obj.data['msgsplit']
	sender = obj.data['sender'] #The sender id
	team = msg[2] #Team to switch player to

	playobj = A.findClient(msg[1]) #Player obj

	if A.canInt(team): team = const.teams[int(team)] #Is the team an integer representation of a team? if so use the team name
	if team not in const.teams.values() and team != 'spectator': #we are a bad team! 
		return A.tell(sender, 'Unknown team %s (spec/spectator/red/blue)' % team)
	if team == 'spec': team == 'spectator' #urt likes spectator

	if len(msg) == 3 and playobj.team != team: #!force player team
		A.rcon('forceteam %s %s' % (playobj.uid, team))
		A.tell(sender, '%s was forced to %s.' % (playobj.name, team))

	elif len(msg) == 4 and msg[3] == 'lock': #!force player team lock
		A.rcon('forceteam %s %s' % (playobj.uid, team))
		playobj.fairplay_locked = True
		playobj.fairplay_lockedteam = team
		A.tell(sender, '%s was forced and locked to %s. Type !unlock %s to unlock player.' % (playobj.name, team, playobj.name))
	else:
		A.tell(sender, "Usage: !force <client> <team> [lock]")
Beispiel #13
0
def cmdList(obj, t):
	sender = obj.data["sender"]
	A.tell(sender, "==Player List==")
	for c in A.getClients().values():
		A.tell(sender, "[%s] %s (%s)" % (c.uid, c.name, c.ip))
Beispiel #14
0
def cmdAbout(obj, t):
	sender = obj.data["sender"]
	A.tell(sender, "UrTBot: V%s by Neek and B1naryth1ef" % __Version__)
Beispiel #15
0
def cmdUnBan(obj, t):
	#!unban blah
	db = database.DB()
	db2 = database.DB()
	db.tableSelect('clients')
	sender = obj.data['sender']
	senderobj = A.findClient(sender)
	msg = obj.data["msg"].split(" ", 1)
	rid = None

	if len(msg) == 2:
		if msg[0].isdigit():
			rid = int(msg[0])
		else:
			print msg[1]
			entr = db.rowFindAll(msg[1].strip(), 'nick')
			print db.rowsGetAll()
			if entr == None:
				A.tell(sender, 'Couldnt find a ban for user with nickname %s' % msg[1])
			elif len(entr) > 1:
				A.tell(sender, 'Multiple users found... listing...')
				if len(entr) <= 15:
					for i in entr:
						objz = A.findClient(i)
						A.tell(sender, '[%s] %s' % (objz.cid, objz.name))
				else:
					A.tell(sender, 'Too many (<15) users to list...')
			elif len(entr) == 1:
				rid = entr[0]['id']
		
		if rid != None:
			objz = A.findClient(rid)
			db2.tableSelect('penalties')
			print db2.rowsGetAll()
			entr = db2.rowFindAll(rid, 'userid')
			if entr is None:
				return A.tell(sender, 'No bans found for %s' % msg[1])
			elif len(entr) == 1:
				entr[0]['status'] = 0
				db2.rowUpdate(entr[0])
			elif len(entr) > 1:
				for i in entr:
					if i['type'] in ('ban', 'tempban'):
						r = db2.rowFind(i['id'])
						r['status'] = 0
						db2.rowUpdate(r)
			db2.commit()
			A.tell(sender, 'Unbanned %s' % msg[1])
	else:
		return A.tell(sender, 'Usage: !unban <player>')
Beispiel #16
0
def cmdSet(obj, t): 
	msg = obj.data["msg"].split(" ")
	sender = obj.data["sender"]
	if len(msg) == 1: A.tell(sender, "Usage: !set <cvar> <value>")
	elif len(msg) == 2:
		A.rcon('set %s %s' % (msg[1], msg[2]))