コード例 #1
0
def test_chat_reply():
    bot = MockBot()
    msg = text_msg("Reply!")
    chat = Chat.from_message(bot, msg)

    chat.reply("Hi " + repr(chat.sender))
    assert "sendMessage" in bot.calls
    assert bot.calls["sendMessage"]["text"] == "Hi John"
コード例 #2
0
ファイル: test_callbacks.py プロジェクト: bliz937/aiotg
def test_chat_reply():
    bot = MockBot()
    msg = text_msg("Reply!")
    chat = Chat.from_message(bot, msg)

    chat.reply("Hi " + repr(chat.sender))
    assert "sendMessage" in bot.calls
    assert bot.calls["sendMessage"]["text"] == "Hi John"
コード例 #3
0
ファイル: bot.py プロジェクト: spbpython/spb_python_bot
    def _process_message(self, message):

        chat = Chat.from_message(self, message)

        if ("text" in message and "from" in message
                and message["from"]["id"] in self.moderators):
            for patterns, handler in self._moderators_commands:
                m = re.search(patterns, message["text"], re.I)
                if m:
                    self.track(message, handler.__name__)
                    return handler(chat, m)

        handler = super(Bot, self)._process_message(message)

        return handler