B
B
bilachayka2021-08-28 21:32:39
Bots
bilachayka, 2021-08-28 21:32:39

How to write a telegram bot (for me it's so simple, although xs I don't really rummage)?

How to write a tg bot that will send a command to my PC to run a batch file on it?
Is it simple, or is there a simpler option, and is it generally feasible, since I don’t really rummage,

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daniil Shevkunov, 2021-08-29
@danila763

Write the bot's token into the token

from aiogram import Bot, Dispatcher, executor, types
from os import system

token = ""

bot = Bot(token=token)
dp = Dispatcher(bot)

keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True)
keyboard.add("start_bat")

@dp.message_handler(commands="start")
async def cmd_test1(message: types.Message):
    await message.answer("Приступим", reply_markup=keyboard)

@dp.message_handler(lambda message: message.text == "start_bat") 
async def with_puree(message: types.Message):
    system("start C:/files/your_bat.bat")
    await message.answer("батник запущен")

executor.start_polling(dp, skip_updates=True)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question