Example #1
0
def init():
	db = database.DB()
	db.tableSelect("clients", "cgroup")
	uberadmin = db.rowFind(5)
	if uberadmin == None:
		A.addCmd('!iddqd', cmdIDDQD, "Set yourself as uberadmin. Usage: !iddqd", 0)
	db.disconnect()
Example #2
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?
Example #3
0
def eventListener(obj, f):
	"""
	The making of this plugin was hell. 
	F**k the iourt team for the stupid
	decisions in the way flag capping is
	handled. Die in a cold, dark, horrible
	place.
	-B1
	"""
	global A, redFlag, blueFlag
	if redFlag == None: redFlag = Timer()
	if blueFlag == None: blueFlag = Timer()

	elif obj.type == "GAME_FLAGPICKUP":
		print obj.data['flagid'], redFlag.status, blueFlag.status
		if obj.data['flagid'] == 1 and redFlag.status == 0: redFlag.start()
		elif obj.data['flagid'] == 2 and blueFlag.status == 0: blueFlag.start()

	elif obj.type == "GAME_FLAGRETURN":
		if obj.data['flagid'] == 1: redFlag.reset()
		elif obj.data['flagid'] == 2: blueFlag.reset()

	elif obj.type == "GAME_FLAGCAPTURE":
		if obj.data['flagid'] == 2:
			redFlag.stop()
			A.say('%sRed %sFlag captured in %s%s seconds' % (A.RED, A.YELLOW, A.CYAN, redFlag.value()))
			redFlag.reset()
		elif obj.data['flagid'] == 1:
			blueFlag.stop()
			A.say('%sBlue %sFlag captured in %s%s seconds' % (A.BLUE, A.YELLOW, A.CYAN, blueFlag.value()))
			blueFlag.reset()
	elif obj.type == "GAME_FLAGRESET":
		if obj.data['flagid'] == 1: redFlag.reset()
		elif obj.data['flagid'] == 2: blueFlag.reset()
Example #4
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])
Example #5
0
def init(x=0):
	A.debug('ads.init() was called... looping', _name)
	while True:
		time.sleep(leng)
		if len(A.B.Clients) > 1: #Only print ads
			A.say(msg[x])
			x+=1
			if x >= len(msg): x = 0
Example #6
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)
Example #7
0
def cmdIDDQD(obj, t):
	sender = obj.data['sender']
	client = A.getClient(sender)

	db = database.DB()
	db.tableSelect("clients")
	entry = db.rowFind(client.cl_guid, 'guid')
	entry["cgroup"] = 5
	db.rowUpdate(entry)
	db.commit()
	db.disconnect()

	A.rcon('bigtext "Congratuations! You have exquisite taste.')
	A.delCmd("!iddqd")
Example #8
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)
Example #9
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)
Example #10
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>')
Example #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))
Example #12
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!')
Example #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))
Example #14
0
def cmdAbout(obj, t):
	sender = obj.data["sender"]
	A.tell(sender, "UrTBot: V%s by Neek and B1naryth1ef" % __Version__)
Example #15
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]))
Example #16
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]")
Example #17
0
from init import A

def testr(obj, n0):
	A.say('TESTING 1... 2... 3...')
	print "Testing!"

A.addCmd('!t', testr, ':D', 0)

def init(): pass
Example #18
0
import time

_name = "Adverts"

default_messages = [
'Checkout the UrTBot, an open source project, on github!',
'Type ^1!help^3 in chat for more commands!',
'Type ^1!about^3 in chat for more information!',
'W^100^3t! This servers on ^1fire^3!']
default_length = 80

try:
	from config import adsconfig
	msg = adsconfig.messages
	leng = adsconfig.time_delay #@NOTE This should be a integer
	A.debug('Loaded config correctly...', _name)
except:
	A.debug('Was not able to load config... using default messages', _name)
	print "Cannot find 'adsconfig.py' in mods/config/... using default messages." #<<<< This is just for users not using debug
	msg = default_messages
	leng = default_length

def init(x=0):
	A.debug('ads.init() was called... looping', _name)
	while True:
		time.sleep(leng)
		if len(A.B.Clients) > 1: #Only print ads
			A.say(msg[x])
			x+=1
			if x >= len(msg): x = 0
		
Example #19
0
def welcomeEvent(obj, t):
	time.sleep(8)
	A.say('Everyone welcome ^1%s ^3to the server!' % A.B.Clients[obj.data['client']].nick)
Example #20
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')
Example #21
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]))
Example #22
0
def cmdKickAll(obj, t):
	msg = obj.data["msg"].split(" ")
	sender = obj.data["sender"]
	for i in A.B.Clients.values():
		if i.uid != int(sender):
			A.kick(i.uid)
Example #23
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>')
Example #24
0
def init(): A.addListeners(['GAME_FLAGPICKUP', 'GAME_FLAGDROP', 'GAME_FLAGRETURN', 'GAME_FLAGCAPTURE', 'GAME_FLAGRESET'], eventListener)
Example #25
0
def testr(obj, n0):
	A.say('TESTING 1... 2... 3...')
	print "Testing!"
Example #26
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]')
Example #27
0
def eveLock(obj, t):
	cobj = A.getClient(obj.client)
	if 'fairplay_locked' in cobj.__dict__.keys():
		if cobj.fairplay_locked is True:
			A.rcon('forceteam %s %s' % (cobj.uid, cobj.fairplay_lockedteam))