【发布时间】:2021-09-14 23:02:06
【问题描述】:
当我发出命令时,它只是没有响应。我所有的其他命令都工作正常。我正在使用pytelegrambotapi。
我的代码-
import telebot
from PIL import Image
import requests
from io import BytesIO
#This is my image link
IMAGE_LINK = "https://pixabay.com/images/id-1127657/"
@bot.message_handler(commands=['image'])
def image(message):
response = requests.get(IMAGE_LINK)
img = Image.open(BytesIO(response.content))
#send the photo
bot.send_photo(message.chat.id, img)
【问题讨论】:
-
考虑到您传递的链接,我认为您发送的是 html,而不是照片。您还可以捕获 send_photo 可能触发的任何异常,然后查看实际问题。
标签: python bots telegram telegram-bot py-telegram-bot-api