示例#1
0
def setRegistered(evname, net, message):
	if not net.authenticated:
		log.info("Registered with %s", net.name)
		net.authenticated=True
		if message.command=='001':
			net.nick=message.parameters[0]
		event.trigger('Network/Authenticated/'+net.name, net=net)
示例#2
0
def dispatchCommands(evname, net, message):
	commandchar=config.get('Networks/'+net.name+'/Channels/'+message.parameters[0]+'/CommandChar')
	if commandchar is None: commandchar=config.get('Networks/'+net.name+'/CommandChar')
	if commandchar is None: commandchar=config.get('CommandChar', '!')
	if message.parameters[-1].startswith('?trigger'):
		message.reply("This bots current trigger is "+commandchar)
		return
	#if not message.parameters[-1].startswith(commandchar): return
	match=re.match(r'^'+commandchar+r'(\S+)(?:\s+(.*))?$', message.parameters[-1])
	if not match: return
	event.trigger("Command/"+match.group(1).upper(), net=net, message=message, args=parseArguments(match.group(2)))
示例#3
0
def dispatchMessages(evname, net):
	global dataQueue
	data=net.recv()
	if not data:
		net.lostConnection('connection reset by peer')
		return
	if not data.endswith("\r\n"):
		if not dataQueue.has_key(net.name):
			dataQueue[net.name]=""
		dataQueue[net.name]+=data
		log.edebug("Queued %db for net %s", len(data), net.name)
		return
	if dataQueue.has_key(net.name) and dataQueue[net.name]:
		log.edebug("Unqueued %db for net %s", len(dataQueue[net.name]), net.name)
		data=dataQueue[net.name]+data
		del(dataQueue[net.name])
	data=data.strip()
	data=re.split('\r\n', data)
	for line in data:
		message=IRCMessage.parse(net, line)
		event.trigger('Network/Incoming/Message/*/'+net.name, net, message)
		event.trigger('Network/Incoming/Message/'+message.command+'/'+net.name, net, message)
示例#4
0
def sendNickServ(evname, net, message):
	global sendPass
	
	if not net.name in sendPass: sendPass[net.name] = 0
	
	#log.edebug("sendPass="******"NICKSERV:"+str(config.get("Networks/"+net.name+"/NickServ")))		#Displays nickserv config entry for debugging purposes.
	
	if config.get("Networks/"+net.name+"/NickServ") is None:
		consoleMessage(net.name, "No NickServ entry found in config for "+net.name+" - Bypassing NickServ module.")
		event.trigger("Network/Event/AutoJoin", net)
		sendPass[net.name] = 2
		return
	
	if config.get("Networks/"+net.name+"/NickServ") == "":
		consoleMessage(net.name, "NickServ entry for "+net.name+" is blank. - Bypassing NickServ module.")
		event.trigger("Network/Event/AutoJoin", net)
		sendPass[net.name] = 2
		return
	
	chkMessage = str(message).split(":",1)
	if len(chkMessage) < 2: return
	chkMessage = str(chkMessage[1]).split("!",1)
	#log.edebug("chkMessage="+str(chkMessage[0]))		#Displays chkMessage for debugging purposes.
	
	if str(chkMessage[0]) == "NickServ":
		if sendPass[net.name] == 1:
			event.trigger("Network/Event/AutoJoin", net)
			return
		
		consoleMessage(net.name, "NickServ entry found in fwee.conf for "+net.name)
		consoleMessage(net.name, "Sending NickServ password...")
		net.send("PRIVMSG NickServ :"+config.get("Networks/"+net.name+"/NickServ")+"\r\n")
		sendPass[net.name] = 1
	
	if str(chkMessage[0]) == "AuthServ":
		if sendPass[net.name] == 1:
			event.trigger("Network/Event/AutoJoin", net)
			return
		
		consoleMessage(net.name, "NickServ entry found in fwee.conf for "+net.name)
		consoleMessage(net.name, "Sending AuthServ password...")
		net.send("PRIVMSG AuthServ :"+config.get("Networks/"+net.name+"/NickServ")+"\r\n")
		sendPass[net.name] = 1