Exemple #1
0
 def received_channel_message(self, user, channel, msg):
     """This will get called when a message is sent a the channel where the
     bot is present.
     
     """
     ZEN_CMD = '!zen'
     if msg.startswith(ZEN_CMD):
         search = msg[len(ZEN_CMD):].strip()
         z = zen(search)
         if z:
             self.pubmsg(channel, z)
Exemple #2
0
 def received_channel_message(self, user, channel, msg):
     """This will get called when a message is sent a the channel where the
     bot is present.
     
     """
     ZEN_CMD = '!zen'
     if msg.startswith(ZEN_CMD):
         search = msg[len(ZEN_CMD):].strip()
         z = zen(search)
         if z:
             self.pubmsg(channel, z)
Exemple #3
0
 def received_direct_message(self, user, channel, msg):
     """This will get called when the bot receives a direct message
     (ie someone writes a message that starts with the bot's nickname').
     
     """
     known_commands = {
         'about': "Hi, I'm a zen robot. Find me at https://github.com/bmispelon/zenbot .",
         'help': "Type !zen <search> to search for a corresponding line in the python zen. Without an argument, you'll get a random one.",
         'easteregg': "I'm affraid I can't do that...",
     }
     
     query = msg.strip().lower()
     msg = known_commands.get(query)
     
     if not msg:
         msg = zen(query)
     
     if msg:
         self.pubmsg(channel, "%s: %s" % (user, msg))
Exemple #4
0
    def received_direct_message(self, user, channel, msg):
        """This will get called when the bot receives a direct message
        (ie someone writes a message that starts with the bot's nickname').
        
        """
        known_commands = {
            'about':
            "Hi, I'm a zen robot. Find me at https://github.com/bmispelon/zenbot .",
            'help':
            "Type !zen <search> to search for a corresponding line in the python zen. Without an argument, you'll get a random one.",
            'easteregg': "I'm affraid I can't do that...",
        }

        query = msg.strip().lower()
        msg = known_commands.get(query)

        if not msg:
            msg = zen(query)

        if msg:
            self.pubmsg(channel, "%s: %s" % (user, msg))