我在python bot中做错了什么?

jgwigjjp  于 2023-02-14  发布在  Python
关注(0)|答案(1)|浏览(156)

我不明白我哪里错了。谁能给我看看正确的密码
我的代码:

@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

我错了:

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

我试着改变功能,但是我不知道怎么做

dldeef67

dldeef671#

@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

相关问题