Ejemplo n.º 1
0
	def run( self ):
		server = self.server
		while True:
			response = server.recv()
			lines	= response.split("\n");
			if len( response ) < 4:
				exit( 0 )
			else:
				pass
				#print( response )
				
			for line in lines:
				if "PING :" in line[0:7]:
					server.send( line.replace( "I", "O", 3 ))
					print( "-----[ Sent pong ]-----" )
				elif "PRIVMSG" in line:
					parsed = irc.parse_message( line );
				
					if parsed:
						if parsed["channel"][0] == "#":
							reply_to = parsed["channel"]
						else:
							reply_to = parsed["nick"]
						#print( "[debug] got: %s: %s" % ( reply_to, parsed["message"] ))
						if parsed["message"][0] == "!":
							self.p_man.exec_cmd( parsed )
Ejemplo n.º 2
0
 def handle_line(self, line):
     self.log.info("Recv: " + line)
     if line is None:
         self.tearDown()
         return
     prefix, command, args = parse_message(line)
     if prefix.startswith("snail!") and command == "NOTICE":
         if args[-1] == "log":
             print "Reloading config"
             loadLogConfig()
             getLogger().warn("WARN")
             getLogger().debug("DEBUG")
Ejemplo n.º 3
0
 def handle_line(self, line):
     self.log.info("Recv: " + line)
     if line is None:
         self.tearDown()
         return
     prefix, command, args = parse_message(line)
     if prefix.startswith("snail!") and command == "NOTICE":
         if args[-1] == "log":
             print "Reloading config"
             loadLogConfig()
             getLogger().warn("WARN")
             getLogger().debug("DEBUG")
Ejemplo n.º 4
0
    def on_raw(self, raw_line):
        super(SimplePlugin, self).on_raw(raw_line)
        prefix, command, args = parse_message(raw_line)
        if command != 'PRIVMSG':
            return
        msg = args[-1]
        if not msg[1:].startswith(self.command_prefix):
            return

        if ' ' in msg:
            cmd, msg = msg.split(' ', 1)
        else:
            cmd, msg = msg, ''
        who = prefix.split("!")[0]
        evt = Event(message=msg, location=args[0], sender=who)
        {  # Prefix to handler map
            "!": self.triggered,
            "?": self.usage
        }[cmd[0]](evt)  #execute
Ejemplo n.º 5
0
 def dispatch(self, event, args):
     msg = args[0].rstrip()
     parts = irc.parse_message(msg)
     evt = "IRC_%s" % parts[1]
     self.manager.handle_event(evt, parts)