aiogram 消息处理程序未触发包含媒体的消息

aiogram message handler not firing for a message containing media

我正在使用 aiogram 2.11.2 作为 Telegram API 的 Python 接口,但我在最简单的回调中遇到了一个问题:当消息仅为文本时它会激活,但是每当连接任何媒体时都会失败。这包括带或不带标题的照片、视频、音频、贴纸和 GIF。

我希望我没有错过任何东西。

import aiogram


class TelegramBot(object):
    def __init__(self):
        self.bot = aiogram.Bot(token="TOKEN")
        self.dispatcher = aiogram.Dispatcher(bot=self.bot)
        self.dispatcher.register_message_handler(self.on_msg,)
    
    async def on_msg(self, msg: aiogram.types.Message):
        print("Message received in telegram")

原来我真的错过了什么。监听各种消息,定义content_type

即可
dispatcher.register_message_handler(self.on_msg, content_type=aiogram.types.ContentType.all())

感谢answerer to my Git issue