Search code examples
pythonbotstelegramtelegram-bottelethon

telethon gives me error Button URL invalid


I m trying to display specific Ad's but what is the error everything is ok or what am I wrong I am crazy with this

img

        if (luckyButtonNews != None):
        print("AAAAA",luckyButtonNews[0][0])
        print("BBBBBBB",luckyButtonNews[0][1])
        # keyboard = [[Button.url(luckyButtonNews[0][0],luckyButtonNews[0][1])]]
        keyboard = [[Button.url(str(luckyButtonNews[0][0]),str(luckyButtonNews[0][1]))]]
    else:
        keyboard = [[Button.url('Advertise your project here 📞', "https://t.me/contractchecker")]]

    chat = await BOT.get_entity(chatId)


    await BOT.send_file(chat, 'giphy.gif', caption= text,buttons=keyboard, parse_mode = 'HTML')
else:
    print("Waiting for the next update")

error:

telethon.errors.rpcerrorlist.ButtonUrlInvalidError: Button URL invalid (caused by SendMediaRequest)

print

thanks!


Solution

  • According to your screenshot, one keyboard looks like Button.url(url, text) and the other like Button.url(text, url). Make sure the text always comes first, and the URL always comes second.