bot rcon
This commit is contained in:
parent
f3b623538b
commit
368bc90298
66
hlna_bot.py
66
hlna_bot.py
@ -86,6 +86,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,31 +100,20 @@ def m_mainmenu(m):
|
||||
@hlna_bot.message_handler(content_types=["text"])
|
||||
def m_chose(m):
|
||||
if m.text.strip() == '🦖 Старт':
|
||||
if list_config == []:
|
||||
menu_install = types.ReplyKeyboardMarkup(resize_keyboard=True)
|
||||
k_install = types.KeyboardButton("Установить")
|
||||
k_back = types.KeyboardButton("Назад")
|
||||
menu_install.add(k_back, k_install)
|
||||
hlna_bot.send_message(m.chat.id, text="{0.first_name}, ниодна карта не установлена".format(m.from_user),
|
||||
reply_markup=menu_install)
|
||||
hlna_bot.register_next_step_handler(m, m_install)
|
||||
else:
|
||||
hlna.read_yaml(list_config[-1], flag=True)
|
||||
menu_start = types.ReplyKeyboardMarkup(resize_keyboard=True)
|
||||
for i in list_config:
|
||||
k_mapname = types.KeyboardButton(i)
|
||||
menu_start.add(k_mapname)
|
||||
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)
|
||||
check_maps(m)
|
||||
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()
|
||||
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):
|
||||
@ -131,11 +123,39 @@ def m_chose(m):
|
||||
# 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("Установить")
|
||||
k_back = types.KeyboardButton("Назад")
|
||||
menu_install.add(k_back, k_install)
|
||||
hlna_bot.send_message(m.chat.id, text="{0.first_name}, ниодна карта не установлена".format(m.from_user),
|
||||
reply_markup=menu_install)
|
||||
hlna_bot.register_next_step_handler(m, m_install)
|
||||
else:
|
||||
hlna.read_yaml(list_config[-1], flag=True)
|
||||
menu_start = types.ReplyKeyboardMarkup(resize_keyboard=True)
|
||||
for i in list_config:
|
||||
k_mapname = types.KeyboardButton(i)
|
||||
menu_start.add(k_mapname)
|
||||
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)
|
||||
|
||||
|
||||
print("Бот запущен")
|
||||
hlna_bot.polling(none_stop=True, interval=0, timeout=999)
|
||||
|
Loading…
Reference in New Issue
Block a user