Esempio n. 1
0
    async def process_update(self, data: dict):
        if self._closed is True:
            raise RuntimeError("The bot isn't initialized")

        chat_type, incoming, content_type = recognize_type(data)
        handler = self.handlers.get(chat_type, incoming, content_type, data)
        await self._scheduler.spawn(
            self.middlewares(Message(self.client, data, self.ctx, chat_type, incoming, content_type), handler)
        )
Esempio n. 2
0
def test_recognize_type_none(mocker):
    mocker.patch("aiotelegrambot.types.recognize_incoming", return_value=None)
    assert recognize_type(mocker.MagicMock()) == (None, None, None)
Esempio n. 3
0
def test_recognize_type_incoming(mocker):
    incoming = mocker.MagicMock()
    incoming.is_message_or_post = False
    mocker.patch("aiotelegrambot.types.recognize_incoming", return_value=incoming)
    assert recognize_type(mocker.MagicMock()) == (None, incoming, None)
Esempio n. 4
0
def test_recognize_type(data):
    data, chat_type, incoming, content_type = data
    assert recognize_type(data) == (chat_type, incoming, content_type)