Example #1
0
def cmdLogChan(obj):
	msg = obj.msg.split(' ', 1)
	if len(msg) == 2:
		if msg[1] not in chans and client.isClientInChannel(msg[1]):
			handle = logging.FileHandler('./logs/%s.log' % msg[1])
			handle.setFormatter('%(asctime)s %(message)s')
			chans[msg[1]] = [logging.getLogger(msg[1]), open('./logs/%s.log' % msg[1])]
			chans[msg[1]][0].addHandler(handle)
Example #2
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)
Example #3
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)
Example #4
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)
Example #5
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))