.
This commit is contained in:
commit
3343480e11
0
111.py
0
111.py
65
dodo_bot.py
65
dodo_bot.py
@ -1,65 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
import time
|
||||
|
||||
import telebot
|
||||
from telebot import types
|
||||
|
||||
from dodo import *
|
||||
key_api = "6192661772:AAHB1dw4rXHOglgyTOpcsxwvLn4d3AKkvP4"
|
||||
#key_api = input("Укажите ключ бота")
|
||||
dodo_bot = telebot.TeleBot(f"{key_api}", parse_mode=None)
|
||||
|
||||
map_server = list_config
|
||||
|
||||
|
||||
@dodo_bot.message_handler(content_types=['text'])
|
||||
def start(call):
|
||||
if call.text == "/start":
|
||||
mainmenu = types.InlineKeyboardMarkup()
|
||||
k_start = types.InlineKeyboardButton(text='Старт 🦖', callback_data='k_start')
|
||||
k_stop = types.InlineKeyboardButton(text='Стоп 🦇', callback_data='k_stop')
|
||||
k_reboot = types.InlineKeyboardButton(text='Перезагрузка 🦕', callback_data='k_reboot')
|
||||
k_update = types.InlineKeyboardButton(text='Обновление 🔸', callback_data='k_update')
|
||||
k_status = types.InlineKeyboardButton(text='Статус 🧾', callback_data='k_status')
|
||||
k_mod = types.InlineKeyboardButton(text='Моды ⏬', callback_data='k_mod')
|
||||
mainmenu.add(k_start, k_stop, k_reboot, k_update, k_status, k_mod)
|
||||
dodo_bot.send_message(call.chat.id, 'Это главное меню!', reply_markup=mainmenu)
|
||||
|
||||
|
||||
@dodo_bot.callback_query_handler(func=lambda call: True)
|
||||
def back(call):
|
||||
if call.data == "mainmenu":
|
||||
mainmenu = types.InlineKeyboardMarkup()
|
||||
k_start = types.InlineKeyboardButton(text='Старт 🦖', callback_data='k_start')
|
||||
k_stop = types.InlineKeyboardButton(text='Стоп 🦇', callback_data='k_stop')
|
||||
k_reboot = types.InlineKeyboardButton(text='Перезагрузка 🦕', callback_data='k_reboot')
|
||||
k_update = types.InlineKeyboardButton(text='Обновление 🔸', callback_data='k_update')
|
||||
k_status = types.InlineKeyboardButton(text='Статус 🧾', callback_data='k_status')
|
||||
k_mod = types.InlineKeyboardButton(text='Моды ⏬', callback_data='k_mod')
|
||||
mainmenu.add(k_start, k_stop, k_reboot, k_update, k_status, k_mod)
|
||||
dodo_bot.edit_message_text('Это главное меню!', call.message.chat.id, call.message.message_id, reply_markup=mainmenu)
|
||||
elif call.data == "k_start":
|
||||
start_menu = types.InlineKeyboardMarkup()
|
||||
if map_server == []:
|
||||
dodo_bot.send_message(call.chat.id, text="Нет карт для запуска".format(call.from_user))
|
||||
k_allmap = types.InlineKeyboardButton(text='Все доступные', callback_data='k_allmap')
|
||||
back = types.InlineKeyboardButton(text='Назад', callback_data='mainmenu')
|
||||
for i in map_server:
|
||||
cluster_server, name_server, port_server, query_port, password_server, max_players, dir_server, mods_id, listen_server, cluster_id, cluster_dir_ovverride = read_yaml(i)
|
||||
k_Mapname = types.InlineKeyboardButton(text=f'{i}', callback_data='k_Mapname')
|
||||
start_menu.add(k_Mapname)
|
||||
start_menu.add(k_allmap, back)
|
||||
dodo_bot.edit_message_text('Выбрать карту, для start!', call.message.chat.id, call.message.message_id, reply_markup=start_menu)
|
||||
if call.data == "k_Mapname":
|
||||
start()
|
||||
elif call.data == "k_allmap":
|
||||
start()
|
||||
elif call.data == "key2":
|
||||
next_menu2 = types.InlineKeyboardMarkup()
|
||||
key4 = types.InlineKeyboardButton(text='Кнопка 4', callback_data='key4')
|
||||
back = types.InlineKeyboardButton(text='Назад', callback_data='mainmenu')
|
||||
next_menu2.add(key4, back)
|
||||
dodo_bot.edit_message_text('Это меню уровня 2, для кнопки2!', call.message.chat.id, call.message.message_id, reply_markup=next_menu2)
|
||||
|
||||
|
||||
dodo_bot.polling()
|
@ -13,17 +13,18 @@ import datetime
|
||||
|
||||
home_dir = Path.home()
|
||||
dir_server = f"{home_dir}/ARK_Servers/"
|
||||
config_dodo = f"{home_dir}/.config/dodo/"
|
||||
config_hlna = f"{home_dir}/.config/hlna/"
|
||||
mods_id = ""
|
||||
listen_server = True
|
||||
|
||||
|
||||
@click.group()
|
||||
def dodo():
|
||||
def hlna():
|
||||
pass
|
||||
|
||||
|
||||
list_config = next(os.walk(config_dodo), (None, None, []))[2] # [] if no file
|
||||
|
||||
list_config = next(os.walk(config_hlna), (None, None, []))[2] # [] if no file
|
||||
x = list_config.count('.directory')
|
||||
if x > 0:
|
||||
list_config.remove('.directory')
|
||||
@ -74,9 +75,10 @@ def check_int(number=""):
|
||||
|
||||
|
||||
create_dir(dir_server)
|
||||
create_dir(config_dodo)
|
||||
create_dir(config_hlna)
|
||||
|
||||
|
||||
<<<<<<< HEAD:dodo.py
|
||||
@dodo.command(help='Установка модов, укажите через запятую id модов')
|
||||
@click.option('--id', default="", help='id модификаций из мастерской steam')
|
||||
def modinstall(id, map_server=list_config):
|
||||
@ -90,6 +92,19 @@ def modinstall(id, map_server=list_config):
|
||||
|
||||
@dodo.command(help='Для конфигурирования параметров запускаемого сервера или кластера серверов')
|
||||
def config(map_server=list_config):
|
||||
=======
|
||||
@hlna.command(help='Для конфигурирования параметров запускаемого сервера или кластера серверов')
|
||||
def config(map_server=list_config):
|
||||
query_p = []
|
||||
port_s = []
|
||||
for i in map_server:
|
||||
with open(f"{home_dir}/.config/hlna/{i}", "r") as yamlfile:
|
||||
data = yaml.load(yamlfile, Loader=yaml.FullLoader)
|
||||
data = data[0]
|
||||
port_s.append(data['Port'])
|
||||
query_p.append(data['QueryPort'])
|
||||
|
||||
>>>>>>> master:hlna.py
|
||||
cluster_dir_override = ""
|
||||
cluster_id = ""
|
||||
count_cluster = check_int("""Укажите требуется ли кластер?
|
||||
@ -210,7 +225,7 @@ def config(map_server=list_config):
|
||||
|
||||
|
||||
def yaml_create(cluster_server, map_server, name_server, port_server, query_port, password_server, max_players, cluster_id, cluster_dir_override):
|
||||
settings_dodo = [
|
||||
settings_hlna = [
|
||||
{
|
||||
'Cluster' : cluster_server,
|
||||
'SessionName' : name_server,
|
||||
@ -225,19 +240,25 @@ def yaml_create(cluster_server, map_server, name_server, port_server, query_port
|
||||
]
|
||||
|
||||
if cluster_id != None:
|
||||
settings_dodo[0]['clusterid'] = cluster_id
|
||||
settings_dodo[0]['clusterdir'] = cluster_dir_override
|
||||
with open(config_dodo + f"{map_server[-1]}", 'w') as yamlfile:
|
||||
data = yaml.dump(settings_dodo, yamlfile)
|
||||
settings_hlna[0]['clusterid'] = cluster_id
|
||||
settings_hlna[0]['clusterdir'] = cluster_dir_override
|
||||
with open(config_hlna + f"{map_server[-1]}", 'w') as yamlfile:
|
||||
data = yaml.dump(settings_hlna, yamlfile)
|
||||
print(colorama.Fore.GREEN + "Конфиг создан" + colorama.Style.RESET_ALL)
|
||||
|
||||
|
||||
<<<<<<< HEAD:dodo.py
|
||||
@dodo.command()
|
||||
def servers(map_servers=list_config):
|
||||
if map_servers==[]:
|
||||
=======
|
||||
@hlna.command()
|
||||
def servers(map_server=list_config):
|
||||
if map_server==[]:
|
||||
>>>>>>> master:hlna.py
|
||||
print("Сервера не установлены")
|
||||
else:
|
||||
for i in map_servers:
|
||||
for i in map_server:
|
||||
cluster_server, name_server, port_server, query_port, password_server, max_players, dir_server, mods_id, listen_server, cluster_id, cluster_dir_ovverride = read_yaml(i)
|
||||
print(f"""
|
||||
Сервер: {i}
|
||||
@ -252,7 +273,7 @@ def servers(map_servers=list_config):
|
||||
print("\n")
|
||||
|
||||
|
||||
@dodo.command(help='Для запуска, сконфигурированного сервера или кластера')
|
||||
@hlna.command(help='Для запуска, сконфигурированного сервера или кластера')
|
||||
def start(map_server=list_config):
|
||||
if map_server == []:
|
||||
return print("Нет карт для запуска")
|
||||
@ -296,14 +317,35 @@ def choose_map(map_server):
|
||||
logging(traceback.format_exc())
|
||||
logging(f"Ошибка при выборе карт для запуска, пользователь ввел - {map_list}")
|
||||
print("Неправильный ввод")
|
||||
<<<<<<< HEAD:dodo.py
|
||||
for j in str(map_list):
|
||||
map_choise.append(map_server[int(j) - 1])
|
||||
map_server = map_choise
|
||||
return map_server
|
||||
=======
|
||||
print_line(map_list)
|
||||
for j in map_list:
|
||||
print_line(j)
|
||||
map_choise.append(map_server[int(j) - 1])
|
||||
map_server = map_choise
|
||||
|
||||
for i in map_server:
|
||||
cluster_server, name_server, port_server, query_port, password_server, max_players, dir_server, mods_id, listen_server, cluster_id, cluster_dir_ovverride = read_yaml(i)
|
||||
create_dir(dir_server + i)
|
||||
print_line("Качаем карту: " + i)
|
||||
os.system(f"steamcmd +force_install_dir {dir_server + i} +login anonymous +app_update 376030 +quit")
|
||||
print_line("Карта скачана: " + i)
|
||||
|
||||
def start(i):
|
||||
os.chdir(dir_server + i + "/ShooterGame/Binaries/Linux/")
|
||||
os.system(f"./ShooterGameServer {i}?SessionName={name_server}?Port={port_server}?QueryPort={query_port}?MaxPlayers={max_players}?GameModIds={mods_id}?listen={listen_server} -clusterid={cluster_id} -ClusterDirOverride={cluster_dir_ovverride}")
|
||||
threads = threading.Thread(target=start, args=(i,))
|
||||
threads.start()
|
||||
>>>>>>> master:hlna.py
|
||||
|
||||
|
||||
def read_yaml(map_server):
|
||||
with open(f"{home_dir}/.config/dodo/{map_server}", "r") as yamlfile:
|
||||
with open(f"{home_dir}/.config/hlna/{map_server}", "r") as yamlfile:
|
||||
data = yaml.load(yamlfile, Loader=yaml.FullLoader)
|
||||
data = data[0]
|
||||
dir_server = data['ServerPath']
|
||||
@ -321,4 +363,4 @@ def read_yaml(map_server):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
dodo()
|
||||
hlna()
|
113
hlna_bot.py
Executable file
113
hlna_bot.py
Executable file
@ -0,0 +1,113 @@
|
||||
#!/usr/bin/env python3
|
||||
import time
|
||||
import os
|
||||
import telebot
|
||||
from telebot import types
|
||||
|
||||
import hlna
|
||||
|
||||
|
||||
key_api = input("Укажите ключ бота")
|
||||
hlna_bot = telebot.TeleBot(f"{key_api}", parse_mode=None)
|
||||
map_server = hlna.list_config
|
||||
|
||||
|
||||
@hlna_bot.message_handler(commands=["start"])
|
||||
def m_start(m):
|
||||
menu = types.ReplyKeyboardMarkup(resize_keyboard=True)
|
||||
k_start = types.KeyboardButton("🦖 Старт")
|
||||
k_stop = types.KeyboardButton("🦇 Выключить")
|
||||
menu.add(k_start, k_stop)
|
||||
|
||||
k_restart = types.KeyboardButton("🦕 Перезагрузить")
|
||||
k_update = types.KeyboardButton("🔸 Обновить")
|
||||
menu.add(k_restart, k_update)
|
||||
|
||||
k_status = types.KeyboardButton("🧾 Статус")
|
||||
menu.add(k_status)
|
||||
|
||||
k_mods = types.KeyboardButton("⏬ Установка модов")
|
||||
menu.add(k_mods)
|
||||
|
||||
hlna_bot.send_message(m.chat.id, text="Привет, {0.first_name}! Это панель управления сервером".format(m.from_user),
|
||||
reply_markup=menu)
|
||||
|
||||
|
||||
@hlna_bot.message_handler(content_types=["text"])
|
||||
def m_chose(m):
|
||||
if m.text.strip() == '🦖 Старт':
|
||||
if map_server == []:
|
||||
hlna_bot.send_message(m.chat.id, text="{0.first_name}, ниодна карта не установлена".format(m.from_user))
|
||||
else:
|
||||
menu_start = types.ReplyKeyboardMarkup(resize_keyboard=True)
|
||||
for i in map_server:
|
||||
k_mapname = types.KeyboardButton(f"{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() == 'Назад':
|
||||
m_start(m)
|
||||
elif m.text.strip() == 'TheIsland':
|
||||
hlna.start()
|
||||
#def m_start(m):
|
||||
# print("Start")
|
||||
#
|
||||
|
||||
# subprocess.run(["arkmanager", "start", "--alwaysrestart", "@all"])
|
||||
# elif m.text.strip() == '🦇 Выключить':
|
||||
# subprocess.run(["arkmanager", "stop", "@all"])
|
||||
# elif m.text.strip() == '🦕 Перезагрузить':
|
||||
# subprocess.run(["arkmanager","restart", "--alwaysrestart", "--warn", "@all"])
|
||||
# elif (m.text.strip() == '🔸 Обновить'):
|
||||
# subprocess.run(["arkmanager", "update", "--update-mods", "@all"])
|
||||
# elif (m.text.strip() == '🧾 Статус'):
|
||||
# x = os.system("lsof -w -i :7777")
|
||||
# if x!=0:
|
||||
# bot.send_message(m.chat.id, text="Сервер не работает 🛑".format(
|
||||
# m.from_user))
|
||||
# else:
|
||||
# bot.send_message(m.chat.id, text="Сервер работает 🟢".format(
|
||||
# m.from_user))
|
||||
#
|
||||
# elif (m.text.strip() == '⏬ Установка модов'):
|
||||
# bot.send_message(m.from_user.id, "Введите id модификации")
|
||||
# bot.register_next_step_handler(m, mods)
|
||||
# else:
|
||||
# pass
|
||||
# else:
|
||||
# if m.text.strip() == 'Zxx843Aj':
|
||||
# th = Thread(target=check, args=(m,))
|
||||
# th.start()
|
||||
# id.append(m.chat.id)
|
||||
# bot.send_message(m.chat.id, text="{0.first_name} вы авторизованы, нажмите /start для работы с ботом".format(m.from_user))
|
||||
# return id
|
||||
# def mods(m):
|
||||
# id = m.text.strip()
|
||||
# subprocess.run(["arkmanager", "installmods", id, "@all"])
|
||||
# subprocess.run(["arkmanager", "enablemod", id, "@all"])
|
||||
# def check(m):
|
||||
#
|
||||
# while True:
|
||||
# x = os.system("lsof -w -i :7777")
|
||||
# if x!=0:
|
||||
# bot.send_message(m.chat.id, text="Сервер не работает 🛑".format(
|
||||
# m.from_user))
|
||||
# bot.send_message(-1001585320535,text="Сервер не работает 🛑".format(
|
||||
# m.from_user),reply_markup=types.ReplyKeyboardRemove())
|
||||
#
|
||||
# while x!=0:
|
||||
# time.sleep(5)
|
||||
# x = os.system("lsof -w -i :7778")
|
||||
# bot.send_message(m.chat.id, text="Сервер запустился 🟢".format(
|
||||
# m.from_user))
|
||||
# bot.send_message(-1001585320535,text="Сервер запустился 🟢".format(
|
||||
# m.from_user))
|
||||
#
|
||||
# elif x == 0:
|
||||
# time.sleep(30)
|
||||
# pass
|
||||
|
||||
print("Bot starting")
|
||||
hlna_bot.polling(none_stop=True, interval=0, timeout=999)
|
||||
|
Loading…
Reference in New Issue
Block a user