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