Exemplo n.º 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"
Exemplo n.º 2
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"
Exemplo n.º 3
0
    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