I’m trying to make a menu bot. All is working but I can’t put a GIF for decoration before the keyboard and message.
I used some variations of .inputmedia
and .document
from here.
I know nothing and have zero python knowledge. I can only understand on the fly from reading on the internet. I really can’t understand how to phrase it.
from telegram.ext import Updater
from telegram.ext import CommandHandler, CallbackQueryHandler
from telegram import InlineKeyboardButton, InlineKeyboardMarkup
import emoji
def start(bot, update):
update.message.reply_text(main_menu_message(),
reply_markup=main_menu_keyboard())
def main_menu(bot, update):
query = update.callback_query
bot.edit_message_text(chat_id=query.message.chat_id,
message_id=query.message.message_id,
text=main_menu_message(),
reply_markup=main_menu_keyboard())
def first_menu(bot, update):
query = update.callback_query
bot.edit_message_text(chat_id=query.message.chat_id,
message_id=query.message.message_id,
text=first_menu_message(),
reply_markup=first_menu_keyboard())
pretty much all i need is an example how to phrase a inputgif
command with some text and a markup keyboard. Thanks!
2
Answers
You mean something like this?
If yes, read on! If no, tell me in the comments.
send_animation
method from telegram.Bot class.file_id
of the GIF that we wish to send! Important: We need to get thefile_id
in the same chat with the bot!Here’s how we can send a GIF with a
caption
and aninline keyboard
(you can see the full code on my GitHub: wehavetogoback.py)use these methods:
update.message.send_animation()
bot.send_animation()
bot.edit_message_media()
For example:
upd: @amir-a-shabani thank you for edition and thanks to @david-kha for using code examples)