我正在构建一个模因生成器电报机器人,它在用户命令/meme时发送一个模因。我正在使用API,比如"https://......meme-api....."。它给我一个模因的URL。我想在API提供的URL中发送媒体,作为对/meme命令的答复。“
dispatcher.add_handler(telegram.ext.CommandHandler("meme", meme))def meme(update, context):
response = requests.get('https://meme-api.herokuapp.com/gimme').json()
url = response.get('url')
print(url)
update.message.reply_text(url)我不知道怎么写模因函数。在不保存媒体的情况下,我应该使用什么消息回复类型发送媒体?
发布于 2022-09-27 12:01:21
正如Message.reply_text文档中所解释的那样,该方法是Bot.send_message的快捷方式,它对应于电报文档中的sendMessage。此方法发送文本消息。要发送照片和动画,您必须使用
Message.reply_photo / Bot.send_photo / sendPhotoMessage.reply_animantion / Bot.send_animantion / sendAnimantion,分别使用。
https://stackoverflow.com/questions/73862756
复制相似问题