Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What am i doing wrong in python bot?

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

i try to change function. but idk how

>Solution :

@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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading