예제 #1
0
파일: bot.py 프로젝트: bmispelon/zenbot
 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)
예제 #2
0
파일: bot.py 프로젝트: bmispelon/zenbot
 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)
예제 #3
0
파일: bot.py 프로젝트: bmispelon/zenbot
 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))
예제 #4
0
파일: bot.py 프로젝트: bmispelon/zenbot
    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))