Exemplo n.º 1
0
 def _default_reply(self, msg):
     default_reply = [
         u'Bad command "%s", You can ask me one of the following questions:\n' % msg['text'],
     ]
     default_reply += [u'    • `{0}` {1}'.format(p.pattern, v.__doc__ or "")
                       for p, v in iteritems(self._plugins.commands['respond_to'])]
         
     self._client.rtm_send_message(msg['channel'],
                                   '\n'.join(to_utf8(default_reply)))
Exemplo n.º 2
0
    def send(self, text):
        """
            Send a reply using RTM API

            (This function doesn't supports formatted message
            when using a bot integration)
        """
        self._client.rtm_send_message(
            self._body['channel'], to_utf8(text))
Exemplo n.º 3
0
Arquivo: bot.py Projeto: junhuqc/pybot
    def get_plugins(self, category, text):
        has_matching_plugin = False
        for matcher in self.commands[category]:
            m = matcher.search(text)
            if m:
                has_matching_plugin = True
                yield self.commands[category][matcher], to_utf8(m.groups())

        if not has_matching_plugin:
            yield None, None
Exemplo n.º 4
0
    def send_webapi(self, text, attachments=None):
        """
            Send a reply using Web API

            (This function supports formatted message
            when using a bot integration)
        """
        self._client.send_message(
            self._body['channel'],
            to_utf8(text),
            attachments=attachments)
Exemplo n.º 5
0
 def upload_file(self, fname, fpath, initial_comment=""):
     self._client.upload_file(self._body["id"], to_utf8(fname), to_utf8(fpath), to_utf8(initial_comment))
Exemplo n.º 6
0
 def upload_file(self, channel, fname, fpath, comment):
     fname = fname or to_utf8(os.path.basename(fpath))
     self.webapi.files.upload(fpath, channels=channel, filename=fname, initial_comment=comment)