Ejemplo n.º 1
0
def msg(s, nick, ident, host, channel, text):
	
	
	if nick in meta.conf['ignore']:
		return False
	
	if text[0] != "\001": return True

	
	if text == "\001VERSION\001":
		meta.sendNotice(s, nick, "\001VERSION Jobot, written in python\001")
		return
	
	elif text == "\001TIME\001":
		meta.sendNotice(s, nick, "\001TIME "+ time.ctime() +"\001")
		return
	
	elif text[:5] == "\001PING":
		meta.sendNotice(s, nick, text)
		return
Ejemplo n.º 2
0
def notice(s, sender, ident, host, channel, text):

    displayNotice(sender, text)

    authd = meta.isAuthor(sender, ident, host)
    text = text.lower()

    if text == "+logmsg" and authd:
        if meta.conf["logmsg"]:
            meta.sendNotice(s, sender, "Confirm - Logging is already On.")
        else:
            meta.sendNotice(s, sender, "Confirm - Logging is now On.")
        meta.conf["logmsg"] = True

    elif text == "-logmsg" and authd:
        if meta.conf["logmsg"]:
            meta.sendNotice(s, sender, "Confirm - Logging is now Off.")
        else:
            meta.sendNotice(s, sender, "Confirm - Logging is already Off.")
        meta.conf["logmsg"] = False

    elif text == "mode?":
        if meta.conf["logmsg"]:
            meta.sendNotice(s, sender, "Mode: Logging is On.")
        else:
            meta.sendNotice(s, sender, "Mode: Logging is Off.")
Ejemplo n.º 3
0
def notice(s, sender, ident, host, channel, text):
	
	authd = meta.isAuthor(sender, ident, host)
	
	textLower = text.lower()
	
	if textLower == '+bucket' and authd:
		if meta.conf['bucket']:
			meta.sendNotice(s, sender, "Confirm - Bucket is already On.")
		else:
			meta.sendNotice(s, sender, "Confirm - Bucket is now On.")
			meta.conf['bucket'] = True
		return False
		
	elif textLower == '-bucket' and authd:
		if not meta.conf['bucket']:
			meta.sendNotice(s, sender, "Confirm - Bucket is already Off.")
		else:
			meta.sendNotice(s, sender, "Confirm - Bucket is now Off.")
			meta.conf['bucket'] = False
		return False
		
	if textLower.find('+censor ') == 0 and authd:
		censor = text[8:].split()
		for p in censor:
			if not p: continue
			if p in meta.conf['censor_channel']:
				meta.sendNotice(s, sender, "Confirm - Already censoring \"%s\"." % (p,))
			else:
				meta.conf['censor_channel'].append(p)
				meta.sendNotice(s, sender, "Confirm - Now censoring \"%s\"." % (p,))
			
		return False
		
	if textLower.find('-censor ') == 0 and authd:
		censor = text[8:].split()
		for p in censor:
			if not p: continue
			if p not in meta.conf['censor_channel']:
				meta.sendNotice(s, sender, "Confirm - Wasn't censoring \"%s\"." % (p,))
			else:
				meta.conf['censor_channel'].remove(p)
				meta.sendNotice(s, sender, "Confirm - Not censoring \"%s\"." % (p,))
			
		return False
		
	elif textLower.find('ignore ') == 0 and authd:
		ignore = text[7:].split()
		for p in ignore:
			if not p: continue
			if p in meta.conf['ignore']:
				meta.sendNotice(s, sender, "Confirm - Already ignoring \"%s\"." % (p,))
			else:
				meta.conf['ignore'].append(p)
				meta.sendNotice(s, sender, "Confirm - Now ignoring \"%s\"." % (p,))
		return False
		
	elif textLower.find('unignore ') == 0 and authd:
		ignore = text[9:].split()
		for p in ignore:
			if not p: continue
			if p in meta.conf['ignore']:
				meta.conf['ignore'].remove(p)
				meta.sendNotice(s, sender, "Confirm - Now Listening to \"%s\"." % (p,))
			else:
				meta.sendNotice(s, sender, "Confirm - \"%s\" not currently ignored." % (p,))
		return False
		
	elif textLower == 'mode?':
		if meta.conf['bucket']:
			meta.sendNotice(s, sender, "Mode: Bucket is On.")
		else:
			meta.sendNotice(s, sender, "Mode: Bucket is Off.")
Ejemplo n.º 4
0
def notice(s, nick, ident, host, sender, text):
	
	
	authd = meta.isAuthor(nick, ident, host)
	
	textLower = text.lower()
	
		
	if textLower[:7] == 'say to ' and authd:
		meta.conf['talkto'] = textLower[7:]
		return False
		
	elif textLower[:4] == 'say ' and authd:
		meta.sendMsg(s, meta.conf['talkto'], text[4:])
		return False
		
	elif textLower[:4] == 'act ' and authd:
		meta.sendMsg(s, meta.conf['talkto'], "\001ACTION %s\001" % text[4:])
		return False
		
	elif textLower == '+talk' and authd:
		if meta.conf['talk']:
			meta.sendNotice(s, nick, "Confirm - Talking is already On.")
		else:
			meta.sendNotice(s, nick, "Confirm - Talking is now On.")
			meta.conf['talk'] = True
		return False
		
	elif textLower == '-talk' and authd:
		if meta.conf['talk']:
			meta.sendNotice(s, nick, "Confirm - Talking is already Off.")
		else:
			meta.sendNotice(s, nick, "Confirm - Talking is now Off.")
			meta.conf['talk'] = False
		return False
		
	elif textLower == 'mode?':
		if meta.conf['talk']:
			meta.sendNotice(s, nick, "Mode: Talking is On.")
		else:
			meta.sendNotice(s, nick, "Mode: Talking is Off.")
Ejemplo n.º 5
0
def notice(s, nick, ident, host, sender, text):
	
	
	authd = meta.isAuthor(nick, ident, host)
	
	textLower = text.lower()
	
		
	if textLower[:11] == '+greetchan ' and authd:
		chan = text[11:]
		if chan.lower() in meta.conf['greetchan']:
			meta.sendNotice(s, nick, "Confirm - %s already being greeted."%chan)
		else:
			meta.conf['greetchan'][chan.lower()] = chan
			meta.sendNotice(s, nick, "Confirm - Now greeting %s."%chan)
		return False
	
		
	elif textLower[:11] == '-greetchan ' and authd:
		chan = text[11:]
		if chan.lower() in meta.conf['greetchan']:
			del meta.conf['greetchan'][chan.lower()]
			meta.sendNotice(s, nick, "Confirm - No longer greeting %s."%chan)
		else:
			meta.sendNotice(s, nick, "Confirm - %s was never being greeted."%chan)
		return False
		
	elif textLower[:6] == '+greet' and authd:
		meta.sendNotice(s, nick, "Confirm - Greet is On.")
		meta.conf['greet'] = True
		return False
		
	elif textLower[:6] == '-greet' and authd:
		meta.sendNotice(s, nick, "Confirm - Greet is Off.")
		meta.conf['greet'] = False
		return False
		
	elif textLower == 'mode?':
		if meta.conf['greet']:
			meta.sendNotice(s, nick, "Mode: Greeting is On.")
		else:
			meta.sendNotice(s, nick, "Mode: Greeting is Off.")
		meta.sendNotice(s, nick, "Greeting channels: %s"%repr(meta.conf['greetchan']))
Ejemplo n.º 6
0
def notice(s, sender, ident, host, channel, text):
	
	# Don't parse anything from nick or chan server. They wont be telling us
	# to do things.
	senderLower = sender.lower()
	if senderLower == 'chanserv' or senderLower == 'nickserv':
		return True
	
	authd = meta.isAuthor(sender, ident, host)
	
	textLower = text.lower()
	
	if textLower.find('join ') == 0 and authd:
		meta.send(s, "JOIN %s\r\n" % textLower[5:].strip())
		return False
	
	elif textLower.find('part ') == 0 and authd:
		meta.send(s, "PART %s\r\n" % textLower[5:].strip())
		return False
	
	elif textLower.find('nick ') == 0 and authd:
		meta.send(s, "NICK %s\r\n" % text[5:].strip())
		meta.conf['nick'] = text[5:].strip()
		return False
	
	elif textLower.find('nickpass ') == 0 and authd:
		meta.sendMsg(s, "NickServ", "IDENTIFY %s" % textLower[9:].strip())
		return False
	
	elif textLower.find('reload ') == 0 and authd:
		print("Reloading Module:", textLower[7:].strip())
		meta.reload.append(textLower[7:].strip())
		return False
		
	elif textLower.find('test ') == 0 and authd:
		meta.sendMsg(s, "Joey", "asdf1456")
		return False
		
	elif textLower.find('raw ') == 0 and authd:
		meta.send(s, "%s\r\n" % textLower[4:])
		return False
	
	elif textLower.find('msg ') == 0 and authd:
		rest = text[4:].strip()
		x = rest.find(' ')
		if not x: return False
		meta.sendMsg(s, rest[:x].rstrip(), rest[x+1:].lstrip())
		return False
		params = text[4:].strip().split()
		if len(params) < 2: return False
		meta.sendMsg(s, params[0], text[4+strlen(params[0]):].strip())
		return False
		
	
	elif textLower.find('notice ') == 0 and authd:
		rest = text[4:].strip()
		x = rest.find(' ')
		if not x: return False
		meta.sendMsg(s, rest[:x].rstrip(), rest[x+1:].lstrip())
		return False
		params = text[7:].strip().split()
		if len(params) < 2: return False
		meta.sendMsg(s, params[0], text[4+strlen(params[0]):].strip())
		return False
		
	elif textLower == 'mode?':
		if meta.conf['autovoice']:
			meta.sendNotice(s, sender, "Mode: AutoVoice is On.")
		else:
			meta.sendNotice(s, sender, "Mode: AutoVoice is Off.")
		# continue through to the other modules.
		# This command should return all the modules state to the requesting
		# user.
		return True
	
	noBlock = True
	
	# break down our text into commands to be processed by 
	cmds = text.split()
	while(cmds):
		#print(cmds[0])
		
		if cmds[0] == '-autovoice' and authd:
			if not meta.conf['autovoice']:
				meta.sendNotice(s, sender, "Confirm - AutoVoice is already Off.")
			else:
				meta.sendNotice(s, sender, "Confirm - AutoVoice is now Off.")
				meta.conf['autovoice'] = False
			noBlock = False
			
		elif cmds[0] == '+autovoice' and authd:
			if meta.conf['autovoice']:
				meta.sendNotice(s, sender, "Confirm - AutoVoice is already On.")
			else:
				meta.sendNotice(s, sender, "Confirm - AutoVoice is now On.")
				meta.conf['autovoice'] = True
			noBlock = False
			
		elif cmds[0] == '+auth':
			# This command takes 1 parameter that should immediatly follow it.
			# pop off the current command (+auth) so that we can grab the pass
			cmds.pop(0)
			
			# grab the pass
			upass = cmds[0]
			
			if upass == meta.conf['auth']:
				# save the authors exact identity
				meta.setAuthor(sender, ident, host)
				
				meta.sendNotice(s, sender, "Confirm - You are now Authorized.")
				print(sender, "is now authorized.")
				
				# set the local authorized variable so that the user is
				# authorized for the rest of the commands.
				authd = True
				
				# no other modules should ever get their hands on the password
				noBlock = False
			else:
				print("FAILED AUTHORIZATION BY", sender, ident, host)
			
		elif cmds[0] == '-auth':
			if authd:
				# un auth the sender
				meta.unsetAuthor()
				
				meta.sendNotice(s, sender, "Confirm - Authorization Removed.")
				print(sender, "has been deauthorized.")
				
				noBlock = False
			else:
				print("FAILED DEAUTH BY", sender, ident, host)
				
		elif cmds[0] == '+loud' and authd:
			if meta.conf['loud']:
				meta.sendNotice(s, sender, "CONFIRM - I WAS ALREADY REALLY REALLY ANNOYING.")
			else:
				meta.conf['loud'] = True
				meta.sendNotice(s, sender, "CONFIRM - I AM NOW REALLY REALLY ANNOYING.")
		elif cmds[0] == '-loud' and authd:
			if not meta.conf['loud']:
				meta.sendNotice(s, sender, "Confirm - Loud was already Off.")
			else:
				meta.conf['loud'] = False;
				meta.sendNotice(s, sender, "Confirm - Loud is now Off.")
				
		elif cmds[0] == '+tenso' and authd:
			if meta.conf['tenso']:
				meta.sendNotice(s, sender, "CONFIRM - TENSO was already On.")
			else:
				meta.conf['tenso'] = True
				meta.sendNotice(s, sender, "CONFIRM - TENSO")
		elif cmds[0] == '-tenso' and authd:
			if not meta.conf['tenso']:
				meta.sendNotice(s, sender, "Confirm - TENSO was already Off.")
			else:
				meta.conf['tenso'] = False;
				meta.sendNotice(s, sender, "Confirm - TENSO is now Off.")
			
		#elif cmds[0] == '+reload' and authd:
		#	cmds.pop(0)
		#	print("trying to reload:", cmds[0])
		#	print(__main__.__dict__)
		#	for plugin in __main__.plugins:
		#		print(" plugin:", plugin.__name__)
		#		if plugin.__name__ == cmds[0]:
		#			plugin = imp.reload(plugin)
		#			break
			
		elif cmds[0] == '-quit' and authd:
			meta.quit = True
			noBlock = False
			
		elif cmds[0] == '-restart' and authd:
			meta.quit = True
			meta.restart = True
			noBlock = False
		
		
		# if the first command fails dont continue trying to process commands
		# This is useful in situations where the notice is something like a 
		# talk command and this module shouldn't process anything in that
		# message.
		if noBlock: return True
		
		# pop the old command that we just worked on, off the queue
		cmds.pop(0)
		
	return noBlock