def on_message(self, sender, channel, flags, message, private): req = Request(message=message) req.nick = sender.nickname req.private = private req.silc_sender = sender if private: req.addressed = True req.sendto = sender req.channel = u'privmsg' else: req.addressed = False req.sendto = channel req.channel = channel.channel_name req.message = decode(req.message) req.message = self.colorlib.strip_color(req.message) self.check_addressing(req) if req.message.startswith(u'^'): req.message = req.message[1:] req.colorize = True else: req.colorize = False self.process_message(req)
def on_message(self, server, event, private, action=False): """process incoming messages""" req = Request(message=event.arguments()[0]) req.nick = irclib.nm_to_n(event.source()) req.channel = event.target() req.private = private req.action = action if private: req.sendto = req.nick req.addressed = True else: req.sendto = req.channel req.addressed = False req.message = req.message.decode(settings.ENCODING, 'replace') # strip control codes from incoming lines req.message = self.colorlib.strip_color(req.message) # strip adressing and set req attributes self.check_addressing(req) # lines that start with ^ will have their output rainbowed if req.message.startswith(u'^'): req.message = req.message[1:] req.colorize = True else: req.colorize = False # send to bot subsystem for processing self.process_message(req)
def on_message(self, server, event, private, action=False): """process incoming messages""" req = Request(message=event.arguments()[0]) req.nick = irclib.nm_to_n(event.source()) req.channel = event.target() req.private = private req.action = action if private: req.sendto = req.nick req.addressed = True else: req.sendto = req.channel req.addressed = False req.message = decode(req.message) # strip control codes from incoming lines req.message = self.colorlib.strip_color(req.message) # strip adressing and set req attributes self.check_addressing(req) # lines that start with ^ will have their output rainbowed if req.message.startswith(u'^'): req.message = req.message[1:] req.colorize = True else: req.colorize = False # send to bot subsystem for processing self.process_message(req)
def on_message(self, sender, channel, flags, message, private): req = Request(message=message) req.nick = sender.nickname req.private = private req.silc_sender = sender if private: req.addressed = True req.sendto = sender req.channel = u'privmsg' else: req.addressed = False req.sendto = channel req.channel = channel.channel_name req.message = decode(req.message) req.message = self.colorlib.strip_color(req.message) self.check_addressing(req) if req.message.startswith(u'^'): req.message = req.message[1:] req.colorize = True else: req.colorize = False self.process_message(req)
def process_message(self, message, nick): """Create request object from recived message and process it""" # this object persists as it's processed by the bot subsystem. # if this requests generates a response, you will receive it along # with the response message in protocol_output(), which means you # can set arbitrary attributes and access them later, for example # a channel to send to for multi-channel protocols, etc. req = Request(message) # required for most modules req.nick = nick # some modules expect this to be set as well as logging facility req.channel = 'console' # force bot into addressed mode # many modules require the bot is addressed before triggering. req.addressed = True # this sets the above flag to true if the user addresses the bot, # as well as strips off the bots nick. self.checkAddressing(req) # pass to substem for final processing Madcow.process_message(self, req)
def process_message(self, message, nick): """Create request object from recived message and process it""" # this object persists as it's processed by the bot subsystem. # if this requests generates a response, you will receive it along # with the response message in protocol_output(), which means you # can set arbitrary attributes and access them later, for example # a channel to send to for multi-channel protocols, etc. req = Request(message) # required for most modules req.nick = nick # some modules expect this to be set as well as logging facility req.channel = 'console' # force bot into addressed mode # many modules require the bot is addressed before triggering. req.addressed = True # this sets the above flag to true if the user addresses the bot, # as well as strips off the bots nick. self.checkAddressing(req) # pass to substem for final processing Madcow.process_message(self, req)
def process_message(self, message): """Create request object from recived message and process it""" req = Request(message=message) req.nick = os.environ['USER'] req.channel = 'ipython' req.addressed = True self.check_addressing(req) Madcow.process_message(self, req)
def process_message(self, message): """Create request object from recived message and process it""" req = Request(message=message) req.nick = os.environ['USER'] req.channel = 'ipython' req.addressed = True self.check_addressing(req) Madcow.process_message(self, req)
def receiveMessage(self, user, multiparts, flags): req = Request(message=stripHTML(multiparts[0][0])) req.nick = user.name req.channel = 'AIM' req.private = True req.addressed = True req.aim = self log.info('[AIM] <%s> %s' % (req.nick, req.message)) self.bot.checkAddressing(req) self.bot.process_message(req)
def receiveMessage(self, user, multiparts, flags): req = Request(message=stripHTML(multiparts[0][0])) req.nick = user.name req.channel = 'AIM' req.private = True req.addressed = True req.aim = self log.info('[AIM] <%s> %s' % (req.nick, req.message)) self.bot.checkAddressing(req) self.bot.process_message(req)
def response(self, nick, args, kwargs): testmod = args[0] results = {} for mod_name, obj in self.madcow.modules: if testmod is not None and mod_name != testmod: continue try: test = tests[mod_name] except: continue if not test: continue if isinstance(test, dict): test = [test] passed = True sys.stderr.write('testing %s ... ' % mod_name) for t in test: try: response = '' req = Request(message=t['request']) req.nick = 'test' req.channel = 'test' req.private = True req.sendTo = 'test' req.addressed = True req.colorize = False req.correction = True try: args = obj.pattern.search(req.message).groups() except: print "\n* args didn't match" passed = False break kwargs = {'req': req} kwargs.update(req.__dict__) response = obj.response(req.nick, args, kwargs) if isinstance(t['result'], str): if response != t['result']: passed = False print "\n* string object didn't match" break elif isinstance(t['result'], retype): if t['result'].search(response) is None: passed = False print "\n* regex didn't match" break except Exception, e: print "\n* exception: %s" % e passed = False if passed: sys.stderr.write('ok\r\n') else: sys.stderr.write('fail [%s]\r\n' % repr(response)) results[mod_name] = passed
def on_message(self, user, message, private, addressed, chat=None): """Process incoming messages and dispatch to main bot""" if user.name == self.bot.botname(): return message = strip_html(message) req = Request(message=message) req.nick = user.name req.channel = u'AIM' req.aim = self req.private = private req.addressed = addressed req.chat = chat self.bot.log.info(u'[AIM] <%s> %s' % (req.nick, req.message)) self.bot.check_addressing(req) self.bot.process_message(req)
def on_message(self, user, message, private, addressed, chat=None): """Process incoming messages and dispatch to main bot""" if user.name == self.bot.botname(): return message = strip_html(message) req = Request(message=message) req.nick = user.name req.channel = u'AIM' req.aim = self req.private = private req.addressed = addressed req.chat = chat self.bot.log.info(u'[AIM] <%s> %s' % (req.nick, req.message)) self.bot.check_addressing(req) self.bot.process_message(req)
def run(self): self.output(u"type 'help' for a list of commands") while self.running: self.check_response_queue() try: input = self.shell.readline(self._prompt) except IOError: # this happens when you get EINTR from SIGHUP handling continue input = input.decode(sys.stdin.encoding, 'replace') if input.lower() == u'quit': break if input.lower() == u'history': print u'history: %s' % repr(self.shell.history) continue if input.lower() == u'clear': sys.stdout.write(self._clear) continue if len(input) > 0: req = Request(message=input) req.nick = self.user_nick req.channel = u'cli' req.private = True req.addressed = True self.check_addressing(req) if req.message.startswith(u'^'): req.colorize = True req.message = req.message[1:] try: self.user_nick = self._new_nick.search(req.message).group(1) self.output(u'nick changed to: %s' % self.user_nick, req) continue except: pass self.process_message(req)
def run(self): self.output("type 'help' for a list of commands") while self.running: self.check_response_queue() try: input = self.shell.readline(self._prompt) except IOError: # this happens when you get EINTR from SIGHUP handling continue if input.lower() == 'quit': break if input.lower() == 'history': print 'history: %s' % repr(self.shell.history) if input.lower() == 'clear': sys.stdout.write(self._clear) continue if len(input) > 0: req = Request(message=input) req.nick = self.user_nick req.channel = 'cli' req.private = True req.addressed = True self.checkAddressing(req) if req.message.startswith('^'): req.colorize = True req.message = req.message[1:] try: self.user_nick = self._new_nick.search( req.message).group(1) self.output('nick changed to: %s' % self.user_nick, req) continue except: pass self.process_message(req)
def on_message(self, user, message, private, addressed, chat=None): """Process incoming messages and dispatch to main bot""" if user.name == self.bot.botname(): return message = stripHTML(message) req = Request(message=message) # lines that start with ^ will have their output rainbowed #if req.message.startswith(u'^'): # req.message = req.message[1:] # req.colorize = True #else: # req.colorize = False req.nick = user.name req.channel = u'AIM' req.aim = self req.private = private req.addressed = addressed req.chat = chat log.info(u'[AIM] <%s> %s' % (req.nick, req.message)) self.bot.check_addressing(req) self.bot.process_message(req)