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("🧾 Статус")
|
k_status = types.KeyboardButton("🧾 Статус")
|
||||||
menu.add(k_status)
|
menu.add(k_status)
|
||||||
|
|
||||||
|
k_rcon = types.KeyboardButton("🧾 RCON")
|
||||||
|
menu.add(k_rcon)
|
||||||
|
|
||||||
k_mods = types.KeyboardButton("⏬ Установка модов")
|
k_mods = types.KeyboardButton("⏬ Установка модов")
|
||||||
menu.add(k_mods)
|
menu.add(k_mods)
|
||||||
|
|
||||||
@ -97,31 +100,20 @@ def m_mainmenu(m):
|
|||||||
@hlna_bot.message_handler(content_types=["text"])
|
@hlna_bot.message_handler(content_types=["text"])
|
||||||
def m_chose(m):
|
def m_chose(m):
|
||||||
if m.text.strip() == '🦖 Старт':
|
if m.text.strip() == '🦖 Старт':
|
||||||
if list_config == []:
|
check_maps(m)
|
||||||
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)
|
|
||||||
elif m.text.strip() == '🧾 Статус':
|
elif m.text.strip() == '🧾 Статус':
|
||||||
check_status(m)
|
check_status(m)
|
||||||
elif m.text.strip() == 'Назад':
|
elif m.text.strip() == 'Назад':
|
||||||
m_mainmenu(m)
|
m_mainmenu(m)
|
||||||
for i in list_config:
|
elif m.text.strip() == '🧾 RCON':
|
||||||
if m.text.strip() == f'{i}':
|
hlna_bot.send_message(m.chat.id, text="{0.first_name}, Введите RCON команду".format(m.from_user),)
|
||||||
hlna.print_line(f"Старт карты {i}")
|
hlna_bot.register_next_step_handler(m, rcon)
|
||||||
hlna.start()
|
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"])
|
# @hlna_bot.message_handler(content_types=["text"])
|
||||||
# def m_mapstart(m):
|
# def m_mapstart(m):
|
||||||
@ -131,10 +123,38 @@ def m_chose(m):
|
|||||||
# hlna.print_line(f"Старт карты {i}")
|
# hlna.print_line(f"Старт карты {i}")
|
||||||
# hlna.start()
|
# 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):
|
def m_install(m):
|
||||||
if m.text.strip() == 'Установить':
|
if m.text.strip() == 'Установить':
|
||||||
hlna_bot.send_message(m.chat.id, subprocess.check_output(hlna.config(), shell=True))
|
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("Бот запущен")
|
print("Бот запущен")
|
||||||
|
Loading…
Reference in New Issue
Block a user