Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/322.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
当使用python Telegrame机器人按下start时,如何使用内联键盘发送gif?_Python_Telegram_Telegram Bot_Python Telegram Bot - Fatal编程技术网

当使用python Telegrame机器人按下start时,如何使用内联键盘发送gif?

当使用python Telegrame机器人按下start时,如何使用内联键盘发送gif?,python,telegram,telegram-bot,python-telegram-bot,Python,Telegram,Telegram Bot,Python Telegram Bot,我想做一个菜单机器人。一切正常,但我不能在键盘和信息前放置GIF装饰 我使用了.inputmedia和.document 从 我什么都不懂,也不懂python。我只能通过网上阅读来理解。我真的不明白该怎么说 from telegram.ext import Updater from telegram.ext import CommandHandler, CallbackQueryHandler from telegram import InlineKeyboardButton, InlineKe

我想做一个菜单机器人。一切正常,但我不能在键盘和信息前放置GIF装饰

我使用了
.inputmedia
.document

我什么都不懂,也不懂python。我只能通过网上阅读来理解。我真的不明白该怎么说

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())

我所需要的几乎就是一个示例,如何使用一些文本和标记键盘来表达
inputgif
命令。谢谢

你的意思是这样的

如果是,请继续阅读!如果没有,请在评论中告诉我

  • 我们将使用类中的
    send\u animation
    方法。 使用此方法发送动画文件(GIF或无声音的H.264/MPEG-4 AVC视频)

  • 我们需要知道我们希望发送的GIF的
    文件id
    重要信息:我们需要获取
    文件id
下面是我们如何发送带有
标题
内联键盘
的GIF(您可以在我的GitHub上看到完整的代码:)

键盘=[
[

InlineKeyboardButton('是的你是指这样的东西吗

如果是,请继续阅读!如果不是,请在评论中告诉我

  • 我们将使用类中的
    send\u animation
    方法。 使用此方法发送动画文件(GIF或无声音的H.264/MPEG-4 AVC视频)

  • 我们需要知道我们希望发送的GIF的
    文件id
    重要信息:我们需要获取
    文件id
下面是我们如何发送带有
标题
内联键盘
的GIF(您可以在我的GitHub上看到完整的代码:)

键盘=[
[
InlineKeyboardButton('是使用以下方法:

  • update.message.send\u animation()
  • bot.send\u animation()
  • bot.edit\u message\u media()
例如:

upd:@amir-a-shabani感谢您的编辑,感谢@david kha使用代码示例)

使用以下方法:

  • update.message.send\u animation()
  • bot.send\u animation()
  • bot.edit\u message\u media()
例如:


upd:@amir-a-shabani感谢您的编辑,感谢@david kha使用代码示例)

你明白了^一件小事;最后一行代码需要4个空格!我试图再次编辑它,但社区机器人拒绝了。2个空格!我向你的队友表示哀悼:)他们也会用2个空格)如果你能在@david code示例中看到,我想这也是我的工作)我明白了,祝你编写代码愉快^一件小事;最后一行代码代码之前需要4个空格!我试图再次编辑它,但社区机器人拒绝了它。2个空格!我对你的队友表示哀悼:)他们也可以使用2个空格)如果你能在@david code示例中看到,我认为这也是我的工作)我明白了,祝你编写代码愉快嗨,我的答案解决了你的问题吗?如果是,请随意接受。嗨,我的答案解决了你的问题吗问题?如果是这样,请随意接受。
keyboard = [
    [
        InlineKeyboardButton('yes use these methods:

  • update.message.send_animation()
  • bot.send_animation()
  • bot.edit_message_media()
For example:

def start(bot, update):
    gif_link='https://media.giphy.com/media/yFQ0ywscgobJK/giphy.gif'
    update.message.reply_animation(
        animation=gif_link,
        caption=main_menu_message(),
        reply_markup=main_menu_keyboard(),
        parse_mode=ParseMode.MARKDOWN
    )