import telebot import urllib.request import pyautogui bot = telebot.TeleBot("TOKEN", parse_mode=None) @bot.message_handler('start') def send_welcome(message): bot.reply_to(message, "Hi Wellcome To Server Manager Bot") enter code here @bot.message_handler('getip') def send_targetip(message): target_ip = urllib.request.urlopen("http://ip.42.pl/short") ip = target_ip.read() bot.reply_to(message,ip) @bot.message_handler('screen') def capture_screen(send_photo): screenimage = pyautogui.screenshot("screen.png") screenimage.save("C:\Users\HO3IN\Desktop\screen.png") photo = open("C:\Users\user\Desktop\screen.png",'rb') bot.send_photo(capture_screen,photo) photo.close() bot.polling()
I can't send screenshot from bot, show me this error:
init.py:515 MainThread) ERROR - TeleBot: "A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: chat not found"
You should use "message.chat.id" instead of "message".
bot.reply_to(message.chat.id,"Hi") bot.reply_to(message.chat.id,ip) bot.send_photo(send_photo.chat.id,photo)
2.1m questions
2.1m answers
60 comments
57.0k users