From d7e63d662efb867e948477a243c2b4820e27ee36 Mon Sep 17 00:00:00 2001 From: officereso Date: Sun, 23 Feb 2020 21:53:35 -0600 Subject: [PATCH] Push change.py for testing on server. --- .../SSC/ChangeServer/{change.py => Change.py} | 41 +++++++++++++------ scr/bot.py | 2 +- 2 files changed, 30 insertions(+), 13 deletions(-) rename scr/Modules/SSC/ChangeServer/{change.py => Change.py} (81%) diff --git a/scr/Modules/SSC/ChangeServer/change.py b/scr/Modules/SSC/ChangeServer/Change.py similarity index 81% rename from scr/Modules/SSC/ChangeServer/change.py rename to scr/Modules/SSC/ChangeServer/Change.py index b2c1a33..1c4a85c 100644 --- a/scr/Modules/SSC/ChangeServer/change.py +++ b/scr/Modules/SSC/ChangeServer/Change.py @@ -31,13 +31,13 @@ def change(ip1, ip2): os.system("systemctl stop mc mcL mcP mcEvent1 mcEvent2") -# for i in range(len(allServerRcon)): -# with MCRcon("192.168.1.52", "f{password}", allServerRcon[i]['serverIP']) as mcr: -# mcr.command("stop") + for i in range(len(allServerRcon)): + with MCRcon("192.168.1.52", "f{password}", allServerRcon[i]['serverIP']) as mcr: + mcr.command("stop") - # f = open("/etc/systemd/system/mcEvent1.service", "w") + f = open("/etc/systemd/system/mcEvent1.service", "w") - f = open("text.txt", 'w') + # f = open("text.txt", 'w') f.write( f"""\ [Unit] @@ -60,9 +60,9 @@ WantedBy=multi-user.target\ ) f.close() - # f = open("/etc/systemd/system/mcEvent2.service", "w") + f = open("/etc/syst1md/system/mcEvent2.service", "w") - f = open("text2.txt", 'w') + # f = open("text2.txt", 'w') f.write( f"""\ [Unit] @@ -85,7 +85,7 @@ WantedBy=multi-user.target\ ) f.close() - # f = open("/home/officereso/mcserver/lobby/plugins/ServerSelectorX/menu/default.yml + f = open("/home/officereso/mcserver/lobby/plugins/ServerSelectorX/menu/default.yml") f.write(f"""\ # Number of rows of slots of your server selector menu. For example '2' will mean 2*9 = 18 slots. Max value is 6. @@ -146,9 +146,9 @@ menu: # Server pinging help: https://github.com/ServerSelectorX/ServerSelectorX/wiki/Free-%7C-Server-Pinging # With server pinging disabled, the placeholders don't work and the plugin will always use the offline section. - ping-server: false - ip: 66.69.103.65 - port: 25568 + ping-server: {"false" if server1[0]['selectorPing'] == 0 else "true"} + ip: 192.168.1.52 + port: {server1[0]['serverIP']} # Action to run when the item is clicked action: 'srv:{server1[0]['action']}' @@ -197,6 +197,23 @@ menu: offline: item: LIGHT_GRAY_STAINED_GLASS_PANE\ """) + f.close() + + os.system("systemctl daemon-reload") + os.system("systemctl enable mc mcL mcP mcEvent1 mcEvent2") + os.system("systemctl start mc mcL mcP mcEvent1 mcEvent2") -change(25570, 25568) +class Change(commands.Cog): + def __init__(self, client): + self.client = client + + @commands.command(name="change") + def change_server(self, ctx, ip1, ip2): + if ctx.author != 305589587215122432: + return + change(ip1, ip2) + + +def setup(client): + client.add_cog(Change(client)) diff --git a/scr/bot.py b/scr/bot.py index 703332d..1842796 100644 --- a/scr/bot.py +++ b/scr/bot.py @@ -4,7 +4,7 @@ token = open("../token.txt") cogs = ["Modules.TGH.automod.automod", "Modules.TGH.automod.ouat", "Modules.SSC.autoReply.Join", "Modules.SSC.autoReply.Leave", - "Modules.Temp"] + "Modules.Temp", "Modules.SSC.ChangeServer.Change"] prefix = 'o!'