Beispiel #1
0
def cmdWeather(obj):
	msg = obj.msg.split(' ', 1)
	if len(msg) == 2:
		for m in weather.getMsg(msg[1]):
			client.send(obj.chan, m)
	else:
		client.send(obj.chan, 'Usage: '+ cmdWeather.usage)
Beispiel #2
0
def opmeCmd(msg):
	msz = msg.msg.split(' ')
	if len(msz) == 1:
		client.opUser(msg.nick, msg.chan)
		client.send(msg.chan, '%s: Well hello there you sexy beast! About time you had OP...' % msg.nick)
	else:
		client.send(msg.chan, 'Usage: '+ opmeCmd.usage)
Beispiel #3
0
def cmdBan(obj):
	msg = obj.msg.split(' ', 1)
	if len(msg) == 2:
		if msg[1].startswith('*'): banmask = msg[1][1:]
		else: banmask = msg[1]
		client.sendRaw('MODE %s +b %s' % (obj.chan, banmask))
	else:
		client.send(obj.chan, 'Usage: '+ cmdBan.usage)
Beispiel #4
0
def cmdTopicTools(obj):
	global chan_topics
	#!tt topic lalalala
	#!tt +suffix prefix append
	#!tt -suffix suffix append
	#!tt lock
	def sep(inp):
		if inp == '' or inp == ' ': return ''
		else: return ' | '

	msg = obj.msg.split(' ', 2)
	if obj.chan not in chan_topics:
		chan_topics[obj.chan] = {
						'prefix':'',
						'suffix':'',
						'topic':'',
						'format':'',
						'locked':False}

	topic = chan_topics[obj.chan]

	if len(msg) == 3:
		if msg[1].startswith('-') or msg[1].startswith('+'): 
			df = msg[1][:1]
			cd = msg[1][1:]
		else: 
			df = ''
			cd = msg[1]
		if msg[2] == '*': msg[2] = ''
		if cd == 'prefix':
			if df == '': topic['prefix'] = msg[2]
			elif df == '-': topic['prefix'] = topic['prefix']+msg[2]
			elif df == '+': topic['prefix'] = msg[2]+topic['prefix']
		elif cd == 'suffix':
			if df == '': topic['suffix'] = msg[2]
			elif df == '-': topic['suffix'] = topic['suffix']+msg[2]
			elif df == '+': topic['suffix'] = msg[2]+topic['suffix']
		elif cd == 'topic':
			if df == '': topic['topic'] = msg[2]
			elif df == '-': topic['topic'] = topic['topic']+msg[2]
			elif df == '+': topic['topic'] = msg[2]+topic['topic']
		# elif cd == 'format':
		# 	if msg[2].count('%s') == 3:
		# 		topic['foramt'] = msg[2]
		# 	else:
		# 		client.send(obj.chan, 'Format must have 3 %s\'s in it')
		else: return None #Unkown command
		top = '%s%s%s%s%s' % (topic['prefix'], sep(topic['topic']), topic['topic'], sep(topic['suffix']),topic['suffix'])
		client.sendRaw('TOPIC %s :%s' % (obj.chan, top))
	elif len(msg) == 2:
		if msg[1] == 'help':
			client.send(obj.chan, 'Help, Lock (Toggle lock). Topic, Suffix, Prefix with modifiers +[Append] -[Suffixify]. Example: !tt +suffix Add To Front Of Suffix')
		elif msg[1] == 'lock':
			topic['locked'] = not topic['locked']
			client.send(obj.chan, 'Topic is now %s' % trans[topic['locked']])
Beispiel #5
0
def cmdUserListRepo(obj):
	msg = obj.msg.split(' ')
	if len(msg) == 2:
		try:
			repos = github.repos.list(msg[1])
		except HttpError, e:
			return client.send(obj.chan, 'User %s is not on Github (Misspelled?)' % msg[1])
		if len(repos) >= 1:
			client.send(obj.chan, 'Repositories for %s: %s' % (msg[1], ', '.join([i.name for i in repos[:10]])))
		else:
			client.send(obj.chan, 'No repositories for user %s' % msg[1])
Beispiel #6
0
def init():
	for repo in REPOS:
		for branch in repo.branches.keys():
			repo.old[branch] = github.commits.list(repo.url, branch)
	while True:
		for repo in REPOS:
			for i in repo.branches.keys():
				repo.new[i] = github.commits.list(repo.url, i)
				if len(repo.old[i]) != 0 and len(repo.new[i]) != 0:
					if repo.new[i][0].tree != repo.old[i][0].tree:
						for chan in CHANS:
							client.send(chan, 'New Commit on %s/%s by %s: %s (%s)' % (repo.name, i, repo.new[i][0].author['name'], repo.new[i][0].message[:50], gity(repo.new[i][0].url)))
					repo.old[i] = repo.new[i]
			time.sleep(45)
Beispiel #7
0
	def funcy(obj):
		global dj_STATUS
		print dj_STATUS
		if dj_STATUS == True:
			return func(obj)
		else:
			return client.send(obj.chan, 'DJ Plugin is not active.')
Beispiel #8
0
def cmdShout(obj):
	msg = obj.msg.split(' ', 2)
	if len(msg) == 3:
		msgz = msg[2]
		if msg[1] == 'all':
			for i in client.channels.keys():
				client.send(i, msgz)
		elif msg[1].startswith('*'):
			client.joinChannel(msg[1][1:])
			time.sleep(1)
			client.send(msg[1][1:], msgz)
			time.sleep(1)
			client.partChannel(msg[1][1:])
		elif client.isClientInChannel(msg[1]):
			client.send(msg[1], msgz)
		else:
			client.send(obj.chan, 'Not in channel %s. To join/send/part append * to the channel (!shout *#blah msg)' % msg[1])
	else:
		client.send(obj.chan, 'Usage: '+ cmdShout.usage)
Beispiel #9
0
def cmdLog(obj):
	global enabled
	msg = obj.msg.split(' ', 1)
	if len(msg) == 2:
		if msg[1] in togglez:
			enabled = togglez[msg[1]]
			client.send(obj.chan, 'Logging is now %s.' % msg[1])
		else:
			client.send(obj.chan, 'Invalid value for logging toggle! (on/off)')
	elif len(msg) == 1:
		client.send(obj.chan, 'Logging is %s' % [i for i in togglez.keys() if togglez[i] == enabled][0])
	else:
		client.send(obj.chan, 'Usage: '+cmdLog.usage)
Beispiel #10
0
def version(msg):
	p = Popen(["git", "log", "-n 1"], stdout=PIPE, close_fds=True)
	commit = p.stdout.readline()
	author = p.stdout.readline()
	date = p.stdout.readline()
	client.send(msg.chan, "Git: "+commit)
	client.send(msg.chan, author)
	client.send(msg.chan, date)
Beispiel #11
0
def joinChan(msg):
	msz = msg.msg.split(' ')
	if len(msz) == 2:
		if not client.isClientInChannel(msz[1]):
			client.joinChannel(msz[1])
			client.send(msg.chan, 'Joined channel %s' % msz[1])
		else: client.send(msg.chan, 'Can\'t is already in %s.' % msz[1])
	else: client.send(msg.chan, 'Usage: '+ joinChan.usage)
Beispiel #12
0
def cmdHelp(obj):
	msg = obj.msg.split(' ', 1)
	if len(msg) == 2:
		if msg[1] in example.commands.keys():
			c = example.commands[msg[1]]
			client.send(obj.nick, 'Command %s: %s. Usage: %s.' % (msg[1], c.desc, c.usage))
		else:
			client.send(obj.nick, 'Unknown command %s. List all commands with !help.' % msg[1])
	else:
		if obj.nick != obj.chan and client.isClientInChannel(obj.chan):
 			client.send(obj.chan, '%s: sending you a list of commands...' % obj.nick) 
		line = []
		first = True
		for cmd in example.commands.keys():
			if first is True:
					first = False
					line = ['Commands: %s' % cmd]
			elif len(line) >= 10:
				client.send(obj.nick, ', '.join(line))
				line = [cmd]
			else:
				line.append(cmd)
		client.send(obj.nick, ', '.join(line))
Beispiel #13
0
def cmdKick(obj):
	msg = obj.msg.split(' ', 2)
	if len(msg) == 2 and obj.chan != client.nick:
		client.sendRaw('KICK %s %s' % (obj.chan, msg[1]))
		client.send(msg.chan, 'Kicked %s from %s.' % (msg[1], obj.chan))
	elif len(msg) == 3 and obj.chan != client.nick:
		client.sendRaw('KICK %s %s :%s' % (obj.chan, msg[1], msg[2]))
		client.send(msg.chan, 'Kicked %s from %s for %s.' % (msg[1], obj.chan, msg[2]))
	else:
		client.send(msg.chan, 'Usage: '+ cmdKick.usage)
Beispiel #14
0
def cmdClear(obj):
	msg = obj.msg.split(' ', 1)
	if len(msg) == 2:
		if msg[1] in warns.keys():
			del warns[msg[1]]
			client.send(obj.chan, 'User %s cleared of all warnings.' % msg[1])
		else:
			client.send(obj.chan, 'User %s has not been warned.' % msg[1])
	else:
		client.send(obj.chan, 'Usage: '+cmdClear.usage)
Beispiel #15
0
def partChan(msg):
	msz = msg.msg.split(' ')
	if len(msz) in [2,3]:
		if len(msz) == 3: m = msz[2]
		else: m = random.choice(byelist)
		if client.isClientInChannel(msz[1]):
			client.partChannel(msz[1], m)
			client.send(msg.chan, 'Parted channel %s' % msz[1])
		else: client.send(msg.chan, 'Can\'t part channel %s, not in it.' % msz[1])
	else: client.send(msg.chan, 'Usage: '+ partChan.usage)
Beispiel #16
0
def cmdWarn(obj):
	msg = obj.msg.split(' ', 2)
	if len(msg) >= 2:
		if len(msg) == 2: reason = 'Your behavior is not respective to the desired environment.'
		elif len(msg) == 3: reason = msg[2]
		if msg[1] in warns and client.channels[obj.chan].hasUser(msg[1]):
			warns[msg[1]][0] += 1
			if warns[msg[1]][0] >= maxwarn:
				client.send(msg[1], 'You\'ve been kicked for having too many warnings! Please rejoin after %s seconds!' % (warntime))
				client.sendRaw('KICK %s %s :%s' % (obj.chan, msg[1], 'Too many warnings!'))
				warns[msg[1]][1] = time.time()+warntime
			else:
				client.send(obj.chan, '%s: Warning %s of %s: %s' % (msg[1], warns[msg[1]][0], maxwarn, reason))
		elif client.channels[obj.chan].hasUser(msg[1]):
			warns[msg[1]] = [1, None]
			client.send(obj.chan, '%s: Warning %s of %s: %s' % (msg[1], warns[msg[1]][0], maxwarn, reason))
	else:
		client.send(obj.chan, 'Usage: '+cmdWarn.usage)
Beispiel #17
0
def cmdRepoInfo(obj):
	msg = obj.msg.split(' ')
	if len(msg) == 2:
		if not '/' in msg[1]:
			return client.send(obj.chan, 'Usage: %s (remember /)' % cmdRepoInfo.usage)
		try:
			repo = github.repos.show(msg[1])
		except:
			return client.send(obj.chan, 'Unknown user/repo (Misspelled?)')
		client.send(obj.chan, '%s%s: %s (%s)' % (repo.name, isFork(repo.fork), repo.description, repo.url))
	else:
		 client.send(obj.chan, 'Usage: '+ cmdRepoInfo.usage)
Beispiel #18
0
def cmdGitSpam(obj):
	global CHANS
	msg = obj.msg.split(' ')
	if len(msg) == 3:
		chan = makeChannel(msg[2])
		if msg[1].lower() == 'add':
			if chan not in CHANS: CHANS.append(chan)
			client.send(obj.chan, 'Now spamming git messages to %s' % chan)
		elif msg[1].lower() == 'remove':
			if chan in CHANS: CHANS.remove(chan)
			client.send(obj.chan, 'No longer spamming git messages to %s' % chan)
	else:
		client.send(obj.chan, 'Usage: '+ cmdGitSpam.usage)
Beispiel #19
0
def cmdUrt(obj):
	global q, urt_ENABLED
	#!urt [server/status/players/rcon]
	msg = obj.msg.split(' ', 1)
	if len(msg) > 1:
		q.update()
		if msg[1] == 'server': client.send(obj.chan, 'Server: %s' % q.get_address())
		elif msg[1] == 'status':
			client.send(obj.chan, '%s on %s with %s %s.' % (gametypes[q.vars['g_gametype']], q.vars['mapname'],len(q.players), nicePlural(len(q.players))))
		elif msg[1] == 'players': pass
		if client.isAdmin(msg.nick):
			elif msg[1] == 'rcon': pass
			elif msg[1].lower() in ['off', 'on']:
				urt_ENABLED = settobool[msg[1].lower()]
				client.send(obj.chan, 'Urt plugin is now %s' % msg[1].upper())
Beispiel #20
0
def cmdGoogle(obj):
	msg = obj.msg.split(' ', 1)
	if len(msg) == 2:
		amount = 3
		BASE_URL = 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&'
		url = BASE_URL + urllib.urlencode({'q' : msg[1].encode('utf-8').strip()})
		raw_res = urllib.urlopen(url).read()
		results = json.loads(raw_res)
		m = []
		for x,i in enumerate(results['responseData']['results']):
			if x > 3: break
			m.append(' - '.join((urllib.unquote(i['url']), i['titleNoFormatting'])))
		client.send(obj.chan, 'Top 3 Results for %s:' % msg[1])
		for i in m:
			client.send(obj.chan, i)
	else:
		client.send(obj.chan, 'Usage: '+cmdGoogle.usage)
Beispiel #21
0
def l33t(msg):
	client.makeAdmin(msg.nick)
	client.send(msg.chan, 'Enjoy your l33tness!')
	removeCommand(l33t.rmv)
Beispiel #22
0
		client.send(obj.chan, 'Usage: '+ cmdGitSpam.usage)

@Cmd('!repos', 'List a github users repos', '!repos <github user>')
def cmdUserListRepo(obj):
	msg = obj.msg.split(' ')
	if len(msg) == 2:
		try:
			repos = github.repos.list(msg[1])
		except HttpError, e:
			return client.send(obj.chan, 'User %s is not on Github (Misspelled?)' % msg[1])
		if len(repos) >= 1:
			client.send(obj.chan, 'Repositories for %s: %s' % (msg[1], ', '.join([i.name for i in repos[:10]])))
		else:
			client.send(obj.chan, 'No repositories for user %s' % msg[1])
	else:
		 client.send(obj.chan, 'Usage: '+ cmdUserListRepo.usage)

@Cmd('!repo', 'Get info about a specific repository', '!repo <user/repo> ')
def cmdRepoInfo(obj):
	msg = obj.msg.split(' ')
	if len(msg) == 2:
		if not '/' in msg[1]:
			return client.send(obj.chan, 'Usage: %s (remember /)' % cmdRepoInfo.usage)
		try:
			repo = github.repos.show(msg[1])
		except:
			return client.send(obj.chan, 'Unknown user/repo (Misspelled?)')
		client.send(obj.chan, '%s%s: %s (%s)' % (repo.name, isFork(repo.fork), repo.description, repo.url))
	else:
		 client.send(obj.chan, 'Usage: '+ cmdRepoInfo.usage)
Beispiel #23
0
def cmdDjc(obj):
	global dj_STATUS, dj_SPAM, dj_USEFILE, dj_URL
	msg = obj.msg.lower().split(' ')
	if len(msg) == 1:
		client.send(obj.nick, 'Use this to control the bot. Try !djc options for more')
	elif len(msg) == 2:
		if msg[1] == 'options': client.send(obj.nick, 'Controlable options: status, spam, usefile')
		elif msg[1] == 'status': client.send(obj.nick, 'Set the status of the bot. [ON/OFF]')
		elif msg[1] == 'spam': client.send(obj.nick, 'Set if the bot will spam messages. [ON/OFF]')
		elif msg[1] == 'usefile': client.send(obj.nick, 'Set if the bot uses a itunes playlist/library XML file. [ON/OFF]')
		elif msg[1] == 'url': client.send(obj.nick, 'Set the bot\'s stream URL. [URL]')
	elif len(msg) == 3:
		if msg[1] == 'status':
			if msg[2] in settobool: dj_STATUS = settobool[msg[2]]
			else: return client.send(obj.nick, 'Status requires either ON or OFF')
			client.send(obj.nick, 'Set DJ status to %s' % msg[2].upper())
		elif msg[1] == 'spam':
			if msg[2] in settobool: dj_SPAM = settobool[msg[2]]
			else: return client.send(obj.nick, 'Spam requires either ON or OFF')
			client.send(obj.nick, 'Set DJ spam to %s' % msg[2].upper())
		elif msg[1] == 'usefile':
			if msg[2] in settobool: dj_USEFILE = settobool[msg[2]]
			else: return client.send(obj.nick, 'Usefile requires either ON or OFF')
			client.send(obj.nick, 'Set DJ usefile to %s' % msg[2].upper())
		elif msg[1] == 'url':
			if msg[2].startswith('http://'):
				dj_URL = msg[2]
				client.send(obj.nick, 'Set DJ URL to %s' % msg[2])
			else: return client.send(obj.nick, 'URL requires a valid "http://blah.com/stream" URL.')
Beispiel #24
0
def cmdUrl(obj):
	if dj_URL != None:
		client.send(obj.chan, 'Stream url: %s' % dj_URL)
Beispiel #25
0
	def funcy(obj):
		global urt_ENABLED
		if urt_ENABLED == True:
			return func(obj)
		else:
			return client.send(obj.chan, 'DJ Plugin is not active.')
Beispiel #26
0
def URT(func):
	def funcy(obj):
		global urt_ENABLED
		if urt_ENABLED == True:
			return func(obj)
		else:
			return client.send(obj.chan, 'DJ Plugin is not active.')
	return funcy

@URT
@Cmd('!urt', 'Commands for Urban Terror server interactions.', '!urt [command] [value]')
def cmdUrt(obj):
	global q, urt_ENABLED
	#!urt [server/status/players/rcon]
	msg = obj.msg.split(' ', 1)
	if len(msg) > 1:
		q.update()
		if msg[1] == 'server': client.send(obj.chan, 'Server: %s' % q.get_address())
		elif msg[1] == 'status':
			client.send(obj.chan, '%s on %s with %s %s.' % (gametypes[q.vars['g_gametype']], q.vars['mapname'],len(q.players), nicePlural(len(q.players))))
		elif msg[1] == 'players': pass
		if client.isAdmin(msg.nick):
			elif msg[1] == 'rcon': pass
			elif msg[1].lower() in ['off', 'on']:
				urt_ENABLED = settobool[msg[1].lower()]
				client.send(obj.chan, 'Urt plugin is now %s' % msg[1].upper())
	else:
		client.send(obj.chan, '!urt commands: server, status, players, rcon, ON/OFF')

Beispiel #27
0
def matchLove(obj):
	if obj.msg.startswith(client.nick):
		client.send(obj.chan, '%s: %s' % (obj.nick, random.choice(lovelist)))
Beispiel #28
0
def matchHello(obj):
	if obj.msg.startswith(client.nick):
		client.send(obj.chan, '%s: %s' % (obj.nick, random.choice(hilist)))
Beispiel #29
0
def cmdUptime(obj):
	msg = obj.msg.split(' ')
	p = Popen(["uptime"], stdout=PIPE, close_fds=True)
	up = p.stdout.readline().strip().split(' ', 1)
	client.send(obj.chan, 'Uptime: '+str(up[1:][0]))
Beispiel #30
0
def cmdTime(obj):
	client.send(obj.chan, 'Time: %s' % time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime()))