pythonbotstelegramaiogram

How can I make bot reply to an audio message?


How can I make aiogram bot reply to an audio message? I have already tried this:

if message.Audio.duration <= 60:
    await message.reply("message")

Solution

  • @dp.message_handler(content_types=types.ContentTypes.VOICE | types.ContentTypes.AUDIO)
    async def audio_message_handler(msg: types.Message):
        if msg.content_type == "voice":
            await msg.reply("Voice message")
        elif msg.content_type == "audio":
            await msg.reply("Audio message")