на серваке пробовал запускать через screen dmS и просто через venv + py3 в чем может быть проблема? при отправке любой команды получаю invalid input УПД ось armbian from subprocess import check_output import telebot from telebot import types import time bot = telebot.TeleBot("снес") user_id = #снес @bot.message_handler(content_types=["text"]) def main(message): if (user_id == message.chat.id): comand = message.text markup = types.InlineKeyboardMarkup() button = types.InlineKeyboardButton(text="re", callback_data=comand) markup.add(button) try: bot.send_message(user_id, check_output(comand, shell = True, reply_markup = markup)) except: bot.send_message(user_id, "Invalid input") @bot.callback_query_handler(func=lambda call: True) def callback(call): comand = call.data try: markup = types.InlineKeyboardMarkup() button = types.InlineKeyboardButton(text="re", callback_data=comand) markup.add(button) bot.send_message(user_id, check_output(comand, shell = True), reply_markup = markup) except: bot.send_message(user_id, "Invalid input") if __name__ == '__main__': while True: try: bot.polling(none_stop=True) except: time.sleep(10) Python from subprocess import check_output import telebot from telebot import types import time bot = telebot.TeleBot("снес") user_id = #снес @bot.message_handler(content_types=["text"]) def main(message): if (user_id == message.chat.id): comand = message.text markup = types.InlineKeyboardMarkup() button = types.InlineKeyboardButton(text="re", callback_data=comand) markup.add(button) try: bot.send_message(user_id, check_output(comand, shell = True, reply_markup = markup)) except: bot.send_message(user_id, "Invalid input") @bot.callback_query_handler(func=lambda call: True) def callback(call): comand = call.data try: markup = types.InlineKeyboardMarkup() button = types.InlineKeyboardButton(text="re", callback_data=comand) markup.add(button) bot.send_message(user_id, check_output(comand, shell = True), reply_markup = markup) except: bot.send_message(user_id, "Invalid input") if __name__ == '__main__': while True: try: bot.polling(none_stop=True) except: time.sleep(10)
Eternusta, привет! Возможно, проблема в том, что ты не указал полный путь к исполняемому файлу, который ты пытаешься запустить. Попробуй добавить полный путь к файлу в команду, например: bot.send_message(user_id, check_output('/полный/путь/к/файлу ' + comand, shell=True, reply_markup=markup)) Code bot.send_message(user_id, check_output('/полный/путь/к/файлу ' + comand, shell=True, reply_markup=markup)) Также, убедись, что ты запускаешь команду от имени пользователя, который имеет достаточные права на выполнение этой команды.
Eternusta, рад, что проблема была найдена! Если у тебя возникнут еще какие-либо вопросы, не стесняйся задавать их здесь. Я всегда готов помочь.
Eternusta, отлично, я вижу, что ты изменил код и теперь все работает. Рад, что я смог помочь! Если у тебя возникнут еще какие-либо вопросы, не стесняйся задавать их здесь. Я всегда готов помочь.
ну так ты exception обработай, да глянь че там except Exception as err: bot.send_message(user_id, f"Invalid input: {err}") Python except Exception as err: bot.send_message(user_id, f"Invalid input: {err}")