@emperorman

Ошибка в коде Python, не могу понять?

Код общается с линуксом

Создал кнопки A,B,C

Далее прописал что хочу чтобы кнопка A отправляла в чат uptime команду допустим, но бот отправляет команду A а не uptime

Помогите новичку тока разбираюсь)

from subprocess import check_output
import telebot
import time
from telebot import types

bot = telebot.TeleBot("7fYlqRvrWrsi0SXmqOlkGLQ")
user_id = 1985

@bot.message_handler(commands=['start'])
def start(message):
  markup = types.ReplyKeyboardMarkup()
  buttonA = types.KeyboardButton(text ='A', callback_data ='a')
  buttonB = types.KeyboardButton('B')
  buttonC = types.KeyboardButton('C')

  markup.row(buttonA, buttonB)
  markup.row(buttonC)

  bot.send_message(message.chat.id, 'It works!', reply_markup=markup)

@bot.callback_query_handler(func = lambda call: True)
def answer(call):
    if call.data == 'a':
    bot.send_message(message.chat.id, 'uptime')

@bot.message_handler(content_types=["text"])
def main(message):
   if (user_id == message.chat.id):
      try:
         bot.send_message(message.chat.id, check_output(comand, shell = True))
      except:
         bot.send_message(message.chat.id, "Invalid input")


if __name__ == '__main__':
    while True:
        try:
            bot.polling(none_stop=True)
        except:
            time.sleep(10)
  • Вопрос задан
  • 293 просмотра
Пригласить эксперта
Ответы на вопрос 1
Sergomen
@Sergomen
Просто делай добро и оно вернётся
Там отступа после if не хватает
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы