import telebot
import pyautogui
import time
bot = telebot.TeleBot('')
TOKEN = ''
tb = telebot.TeleBot(TOKEN)
keyboard1 = telebot.types.ReplyKeyboardMarkup()
keyboard1.row('Хром', 'Скрин', 'НеСпящий')
keyboard1.row('Искать', 'Написать')
@bot.message_handler(commands=['start'])
def start_message(message):
bot.send_message(message.chat.id, 'Начнём', reply_markup=keyboard1)
@bot.message_handler(content_types=['text'])
def send_text(message):
if message.text.lower() == 'хром':
pyautogui.moveTo(464, 1064, 1)
pyautogui.click()
time.sleep(3)
pyautogui.screenshot('my_screenshot.png')
photo = open('my_screenshot.png', 'rb')
tb.send_photo(message.chat.id, photo)
elif message.text.lower() == 'скрин':
pyautogui.screenshot('my_screenshot.png')
photo = open('my_screenshot.png', 'rb')
tb.send_photo(message.chat.id, photo)
elif message.text.lower() == 'неспящий':
pyautogui.moveTo(500, 500, 1)
pyautogui.moveTo(1, 1, 1)
elif message.text.lower() == 'искать':
pyautogui.hotkey('ctrl', 't')
time.sleep(3)
pyautogui.screenshot('my_screenshot.png')
photo = open('my_screenshot.png', 'rb')
tb.send_photo(message.chat.id, photo)
elif message.text.lower() == 'написать':
message = bot.send_message(message.chat.id, 'Введите текст')
bot.send_message(message.chat.id, message)
bot.polling()
elif message.text.lower() == 'написать':
message = bot.send_message(message.chat.id, 'Введите текст')
bot.send_message(message.chat.id, message)
@bot.message_handler(content_types=['text'])
def send_text(message):
if message.text.lower() == 'хром':
pyautogui.moveTo(464, 1064, 1)
pyautogui.click()
time.sleep(3)
pyautogui.screenshot('my_screenshot.png')
photo = open('my_screenshot.png', 'rb')
tb.send_photo(message.chat.id, photo)
elif message.text.lower() == 'скрин':
pyautogui.screenshot('my_screenshot.png')
photo = open('my_screenshot.png', 'rb')
tb.send_photo(message.chat.id, photo)
elif message.text.lower() == 'неспящий':
pyautogui.moveTo(500, 500, 1)
pyautogui.moveTo(1, 1, 1)
elif message.text.lower() == 'искать':
pyautogui.hotkey('ctrl', 't')
time.sleep(3)
pyautogui.screenshot('my_screenshot.png')
photo = open('my_screenshot.png', 'rb')
tb.send_photo(message.chat.id, photo)
elif message.text.lower() == 'написать':
message = bot.send_message(message.chat.id, 'Введите текст')
bot.register_next_step_handler(message, msg_0)
def msg_0(message):
msg=message.text
bot.send_message(message.chat.id, message)
bot.register_next_step_handler(message, send_text)
bot.polling()
elif message.text.lower() == 'написать':
msg = bot.send_message(message.chat.id, 'Введите текст')
bot.register_next_step_handler(msg, process_step)
bot.clear_step_handler(msg)
@bot.message_handler(content_types=['text'])
def process_step(message):
bot.send_message(message.chat.id, message.text)
bot.send_message(message.chat.id, 'Введите текст')
bot.register_next_step_handler(message, get_text)
def get_text(message):
message.text будет как раз запрашиваемый текст