bot rcon
This commit is contained in:
parent
f3b623538b
commit
368bc90298
62
hlna_bot.py
62
hlna_bot.py
@ -87,6 +87,9 @@ def m_mainmenu(m):
|
||||
k_status = types.KeyboardButton("🧾 Статус")
|
||||
menu.add(k_status)
|
||||
|
||||
k_rcon = types.KeyboardButton("🧾 RCON")
|
||||
menu.add(k_rcon)
|
||||
|
||||
k_mods = types.KeyboardButton("⏬ Установка модов")
|
||||
menu.add(k_mods)
|
||||
|
||||
@ -97,6 +100,44 @@ def m_mainmenu(m):
|
||||
@hlna_bot.message_handler(content_types=["text"])
|
||||
def m_chose(m):
|
||||
if m.text.strip() == '🦖 Старт':
|
||||
check_maps(m)
|
||||
elif m.text.strip() == '🧾 Статус':
|
||||
check_status(m)
|
||||
elif m.text.strip() == 'Назад':
|
||||
m_mainmenu(m)
|
||||
elif m.text.strip() == '🧾 RCON':
|
||||
hlna_bot.send_message(m.chat.id, text="{0.first_name}, Введите RCON команду".format(m.from_user),)
|
||||
hlna_bot.register_next_step_handler(m, rcon)
|
||||
hlna_bot.send_message(m.chat.id, text="Цикл FOR".format(m.from_user),)
|
||||
# Попробовать засунуть в отдельную функцию и вызвать через next_step в блоке Старт, после check_maps
|
||||
#for i in list_config:
|
||||
# if m.text.strip() == f'{i}':
|
||||
# hlna.print_line(f"Старт карты {i}")
|
||||
# hlna.start()
|
||||
|
||||
# @hlna_bot.message_handler(content_types=["text"])
|
||||
# def m_mapstart(m):
|
||||
# hlna.print_line("Старт карты")
|
||||
# for i in list_config:
|
||||
# if m.text.strip() == f'{i}':
|
||||
# hlna.print_line(f"Старт карты {i}")
|
||||
# hlna.start()
|
||||
|
||||
def rcon(m):
|
||||
command = m.text.strip()
|
||||
check_maps(m)
|
||||
|
||||
hlna_bot.register_next_step_handler(m, rcon_2, command)
|
||||
def rcon_2(m,command):
|
||||
print(m.text.strip())
|
||||
for i in list_config:
|
||||
if m.text.strip() == f'{i}':
|
||||
print(f"python3 ./hlna.py {command} -m {i}")
|
||||
os.system(f"python3 ./hlna.py {command} -m {i}")
|
||||
def m_install(m):
|
||||
if m.text.strip() == 'Установить':
|
||||
hlna_bot.send_message(m.chat.id, subprocess.check_output(hlna.config(), shell=True))
|
||||
def check_maps(m):
|
||||
if list_config == []:
|
||||
menu_install = types.ReplyKeyboardMarkup(resize_keyboard=True)
|
||||
k_install = types.KeyboardButton("Установить")
|
||||
@ -114,27 +155,6 @@ def m_chose(m):
|
||||
k_back = types.KeyboardButton("Назад")
|
||||
menu_start.add(k_back)
|
||||
hlna_bot.send_message(m.chat.id, text="{0.first_name}, выбери карту".format(m.from_user), reply_markup=menu_start)
|
||||
elif m.text.strip() == '🧾 Статус':
|
||||
check_status(m)
|
||||
elif m.text.strip() == 'Назад':
|
||||
m_mainmenu(m)
|
||||
for i in list_config:
|
||||
if m.text.strip() == f'{i}':
|
||||
hlna.print_line(f"Старт карты {i}")
|
||||
hlna.start()
|
||||
|
||||
# @hlna_bot.message_handler(content_types=["text"])
|
||||
# def m_mapstart(m):
|
||||
# hlna.print_line("Старт карты")
|
||||
# for i in list_config:
|
||||
# if m.text.strip() == f'{i}':
|
||||
# hlna.print_line(f"Старт карты {i}")
|
||||
# hlna.start()
|
||||
|
||||
|
||||
def m_install(m):
|
||||
if m.text.strip() == 'Установить':
|
||||
hlna_bot.send_message(m.chat.id, subprocess.check_output(hlna.config(), shell=True))
|
||||
|
||||
|
||||
print("Бот запущен")
|
||||
|
Loading…
Reference in New Issue
Block a user