My Telegram bot in Python fails to send an image on receiving the ‘pic’ command. See the code below:
import telegram
bot = telegram.Bot('TOKEN')
if msg['text'] == 'pic': bot.send_img(msg['chat']['id'], "photo.jpg")
My Telegram bot in Python fails to send an image on receiving the ‘pic’ command. See the code below:
import telegram
bot = telegram.Bot('TOKEN')
if msg['text'] == 'pic': bot.send_img(msg['chat']['id'], "photo.jpg")
hey try using bot.send_photo instead of send_img and open your image in rb mode. it should work fine
Reviewing similar challenges I encountered, it is important to note that some methods have been deprecated in more recent versions of Python Telegram libraries. In my case, switching to the current API function with precise file handling resolved the issue. I resolved it by reading the image file in binary mode and ensuring that the correct method name is used as per the library documentation. Verifying that your package version supports the function you intend to use can help avoid such implementation pitfalls.