What am i doing wrong in python bot?

Question:

I don’t understand what is my mistake.
Can someone show me the correct code

My code:

@dp.message_handler(content_types=['text'])
async def Text(update):
    dl = downloader.tiktok_downloader()
    global last_use
    meseg = update.message.text
    getvid = dl.musicaldown(url=meseg,output_name='video.mp4')
    if getvid:
        bot.send_video()
        return
    if getvid == False:
                getvid = dl.ttscraper(url=meseg, output_name="video.mp4")
                if getvid:
                    bot.send_videoo()
                    return
                else:
                    bot.send_message('"failed to download video.check link and try again"')
                    return

My wrong:

    meseg = update.message.text
AttributeError: 'Message' object has no attribute 'message'

i try to change function. but idk how

Asked By: Alex

||

Answers:

@dp.message_handler(content_types=['text'])
async def text_handler(message: types.Message):
    dl = downloader.tiktok_downloader()
    meseg = message.text
    getvid = dl.musicaldown(url=meseg, output_name='video.mp4')
    if getvid:
        with open("video.mp4", "rb") as f:
            await bot.send_video(chat_id=message.chat.id, video=f)
        return
    if getvid == False:
        getvid = dl.ttscraper(url=meseg, output_name="video.mp4")
        if getvid:
            with open("video.mp4", "rb") as f:
                await bot.send_video(chat_id=message.chat.id, video=f)
            return
        else:
            await bot.send_message(chat_id=message.chat.id, text='"failed to download video.check link and try again"')
            return
Answered By: 6c00h