From 8247cf1c44ebd8e5a1cccbe38ee0e74ab555693a Mon Sep 17 00:00:00 2001 From: officereso Date: Sun, 6 Dec 2020 00:27:37 -0600 Subject: [PATCH] initial commit --- .gitignore | 2 +- scr/Modules/SSC/ChangeServer/Change.py | 225 -------------------- scr/Modules/SSC/ChangeServer/mcrconTest.py | 7 - scr/Modules/TGH/automod/automod.py | 23 -- scr/Modules/TGH/automod/lastmemsjoined | 0 scr/Modules/TGH/automod/ouat.py | 26 --- scr/Modules/TGH/automod/ows.py | 19 -- scr/Modules/TGH/uno.py | 74 ------- scr/Modules/{SSC => TMC}/autoReply/Join.py | 0 scr/Modules/{SSC => TMC}/autoReply/Leave.py | 0 scr/Modules/{SSC => TMC}/automod/Spam.py | 0 scr/bot.py | 5 +- 12 files changed, 3 insertions(+), 378 deletions(-) delete mode 100644 scr/Modules/SSC/ChangeServer/Change.py delete mode 100644 scr/Modules/SSC/ChangeServer/mcrconTest.py delete mode 100644 scr/Modules/TGH/automod/automod.py delete mode 100644 scr/Modules/TGH/automod/lastmemsjoined delete mode 100644 scr/Modules/TGH/automod/ouat.py delete mode 100644 scr/Modules/TGH/automod/ows.py delete mode 100644 scr/Modules/TGH/uno.py rename scr/Modules/{SSC => TMC}/autoReply/Join.py (100%) rename scr/Modules/{SSC => TMC}/autoReply/Leave.py (100%) rename scr/Modules/{SSC => TMC}/automod/Spam.py (100%) diff --git a/.gitignore b/.gitignore index af526c1..51ae0ce 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ /sqlPass.txt /token.txt -/scr/Modules/SSC/ChangeServer/text.txt +/scr/Modules/TMC/ChangeServer/text.txt /rcon.txt diff --git a/scr/Modules/SSC/ChangeServer/Change.py b/scr/Modules/SSC/ChangeServer/Change.py deleted file mode 100644 index ddba29b..0000000 --- a/scr/Modules/SSC/ChangeServer/Change.py +++ /dev/null @@ -1,225 +0,0 @@ -from discord.ext import commands -import pymysql -import os -from mcrcon import MCRcon - -password = open("../sqlPass.txt", 'r').read() -rcon = open("../rcon.txt", 'r').read() - -con = pymysql.connect(host='localhost', - user='Bot', - password=f'{password}', - db='serverIDs', - charset='utf8mb4', - port=5618, - cursorclass=pymysql.cursors.DictCursor) - - -def change(ip1, ip2): - print(ip1+' '+ip2) - - os.system("systemctl disable mc mcL mcP mcEvent1 mcEvent2") - - with con: - cur = con.cursor() - cur.execute(f"SELECT * FROM Bot.McServer where serverIP = {ip1}") - server1 = cur.fetchall() - - cur.execute(f"SELECT * FROM Bot.McServer where serverIP = {ip2}") - server2 = cur.fetchall() - - cur.execute("SELECT serverRCON FROM Bot.McServer ORDER BY serverRCON DESC") - allServerRcon = cur.fetchall() - - # for i in range(len(allServerRcon)): - # print("192.168.1.52 " + f"{rcon} " + str(allServerRcon[i]['serverRCON']) + "________________________________________________________________________________________________") - # - # for i in range(len(allServerRcon)): - # with MCRcon("192.168.1.52", f"{rcon}", port=allServerRcon[i]['serverRCON']) as mcr: - # mcr.command("stop") - - os.system("systemctl stop mc mcL mcP mcEvent1 mcEvent2") - - f = open("/etc/systemd/system/mcEvent1.service", "w") - - # f = open("text.txt", 'w') - f.write( - f"""\ -[Unit] -Description=Minecraft Server -After=network.target -StartLimitIntervalSec=0 - -[Service] -Type=simple -Restart=always -RestartSec=1 -User=officereso -group=minecraft -ExecStart=/usr/bin/java -jar -Xmx4000m -Xms4000m {server1[0]['serverJarPath']} --nogui -WorkingDirectory={server1[0]['workingDirectory']} - -[Install] -WantedBy=multi-user.target\ -""" - ) - f.close() - - f = open("/etc/systemd/system/mcEvent2.service", "w") - - # f = open("text2.txt", 'w') - f.write( - f"""\ -[Unit] -Description=Minecraft Server -After=network.target -StartLimitIntervalSec=0 - -[Service] -Type=simple -Restart=always -RestartSec=1 -User=officereso -group=minecraft -ExecStart=/usr/bin/java -jar -Xmx4000m -Xms4000m {server2[0]['serverJarPath']} --nogui -WorkingDirectory={server2[0]['workingDirectory']} - -[Install] -WantedBy=multi-user.target\ -""" - ) - f.close() - - f = open("/home/officereso/mcserver/lobby/plugins/ServerSelectorX/menu/default.yml", 'w') - - 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. -rows: 2 - -# This will be displayed as the title of the menu. -title: 'Server Selector' - -# This will be the name of the server selector item -item-name: 'Server Selector' - -item-lore: -- 'Line 1' -- 'Line 2' - -# The name of the server selector item. -item: COMPASS - -# Give the item when a player joins? -on-join: true - -# What slot should the item be in? Specify -1 to automatically put it in the first available slot. -inv-slot: 0 - -# URL clickable message -url-message: '&3&lClick here' - -# Command to open the menu. Specify "none" for no command. (without /) -command: "menu" - -# https://github.com/ServerSelectorX/ServerSelectorX/wiki/Free-%7C-Items-in-the-server-selector -menu: - - # Server item - 3: - - # 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: 25569 - - # Action to run when the item is clicked - action: 'srv:plots' - - online: - item: COMMAND_BLOCK - name: '&aPlots Server' - - - offline: - item: COMMAND_BLOCK - name: '&aPlots Server' - - - # Message item - 5: - - # 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" 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']}' - - online: - item: {server1[0]['selectorItem']} - name: '{server1[0]['selectorTextColor']}{server1[0]['serverName']}' - lore: - - {server1[0]['selectorLore']} - - - offline: - item: {server1[0]['selectorItem']} - name: '{server1[0]['selectorTextColor']}{server1[0]['serverName']}' - lore: - - {server1[0]['selectorLore']} - - - 13: - - # 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: 25567 - - # Action to run when the item is clicked - action: 'srv:{server2[0]['action']}' - - online: - item: {server2[0]['selectorItem']} - name: '{server2[0]['selectorTextColor']}{server2[0]['serverName']}' - lore: - - {server2[0]['selectorLore']} - - - offline: - item: {server2[0]['selectorItem']} - name: '{server2[0]['selectorTextColor']}{server2[0]['serverName']}' - lore: - - {server2 [0]['selectorLore']} - - # No action item - -1: # -1 means everything else - action: 'none' - 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 restart mc mcL mcP mcEvent1 mcEvent2") - - -class Change(commands.Cog): - def __init__(self, client): - self.client = client - - @commands.command(pass_context=True, name="change") - async def change_server(self, ctx, ip1: int, ip2: int): - print(ctx.author.id) - if ctx.author.id != 305589587215122432: - return - change(ip1, ip2) - - -def setup(client): - client.add_cog(Change(client)) diff --git a/scr/Modules/SSC/ChangeServer/mcrconTest.py b/scr/Modules/SSC/ChangeServer/mcrconTest.py deleted file mode 100644 index 64e8f15..0000000 --- a/scr/Modules/SSC/ChangeServer/mcrconTest.py +++ /dev/null @@ -1,7 +0,0 @@ -from mcrcon import MCRcon - -allServerRcon = [] - -for i in range(len(allServerRcon)): - with MCRcon("192.168.1.52", "f{password}", allServerRcon[i]) as mcr: - mcr.command("stop") diff --git a/scr/Modules/TGH/automod/automod.py b/scr/Modules/TGH/automod/automod.py deleted file mode 100644 index 8906f37..0000000 --- a/scr/Modules/TGH/automod/automod.py +++ /dev/null @@ -1,23 +0,0 @@ -from discord.ext import commands -import discord -import time - - -class Automod(commands.Cog): - def __init__(self, client): - self._last_member = None - self.client = client - - @commands.Cog.listener() - async def on_member_join(self, member): - lastmemjoin = open("lastmemsjoined", 'a') - lastmemjoin.write(str(member) + "\n" + str(time.monotonic())) - - @commands.Cog.listener() - async def on_message(self, message): - - await self.client.process_commands(message) - - -def setup(client): - client.add_cog(Automod(client)) diff --git a/scr/Modules/TGH/automod/lastmemsjoined b/scr/Modules/TGH/automod/lastmemsjoined deleted file mode 100644 index e69de29..0000000 diff --git a/scr/Modules/TGH/automod/ouat.py b/scr/Modules/TGH/automod/ouat.py deleted file mode 100644 index 49b97f8..0000000 --- a/scr/Modules/TGH/automod/ouat.py +++ /dev/null @@ -1,26 +0,0 @@ -from discord.ext import commands - - -class Ouat(commands.Cog): - def __init__(self, client): - self._last_member = None - self.client = client - - @commands.Cog.listener() - async def on_message(self, message): - if self.client.get_channel(message.channel.id) == self.client.get_channel(507386320604102696): # ouat auto mod - letter_number = 0 - number_of_periods = 0 - place_of_period = 0 - for letter in message.content: - letter_number += 1 - if letter == '.': - number_of_periods += 1 - place_of_period = letter_number - if number_of_periods > 1 or not (place_of_period == len(message.content)) or number_of_periods == 0: - await message.delete() - await self.client.process_commands(message) - - -def setup(client): - client.add_cog(Ouat(client)) diff --git a/scr/Modules/TGH/automod/ows.py b/scr/Modules/TGH/automod/ows.py deleted file mode 100644 index 5d0370f..0000000 --- a/scr/Modules/TGH/automod/ows.py +++ /dev/null @@ -1,19 +0,0 @@ -from discord.ext import commands - - -class Ows(commands.Cog): - def __init__(self, client): - self._last_member = None - self.client = client - - @commands.Cog.listener() - async def on_message(self, message): - if self.client.get_channel(message.channel.id) == self.client.get_channel(492089451476942848): # ows auto mod - words = message.content.split(' ') - if len(words) > 1: - await message.delete() - await self.client.process_commands(message) - - -def setup(client): - client.add_cog(Ows(client)) diff --git a/scr/Modules/TGH/uno.py b/scr/Modules/TGH/uno.py deleted file mode 100644 index b8536a0..0000000 --- a/scr/Modules/TGH/uno.py +++ /dev/null @@ -1,74 +0,0 @@ -from discord.ext import commands -import discord -import asyncio - - -def check_for_mention_1_player(message): - if len(message.mentions) == 1: - return True - else: - return False - - -def accept(message): - return True - - - -class UnoGameCog(commands.Cog): - def __init__(self, client): - self.client = client - - @commands.command() - async def uno_create(self, ctx): - if self.client.get_channel(ctx.channel.id) == self.client.get_channel(555052075306713109): - embed = discord.Embed(colour=discord.Colour.purple()) - embed.set_author(name="How many players?") - msg = await ctx.send(embed=embed) - await msg.add_reaction('2⃣') - await msg.add_reaction('3⃣') - await asyncio.sleep(1) - - try: - reaction, user = await self.client.wait_for('reaction_add', timeout=20.0) - - if str(reaction) == '2⃣' and ctx.author == user: - embed.set_author(name="Cool, mention the other player") - await msg.edit(embed=embed) - message = await self.client.wait_for('message', timeout=20.0, check=check_for_mention_1_player) - - - - - - - - - - - - - - embed.set_author(name="Awesome, that user has 20 seconds to say \"accept\" in chat") - await msg.edit(embed=embed) - await self.client.wait_for('message', timeout=20.0, check=accept) - - - - - - - - - - - - - - - except asyncio.TimeoutError: - await ctx.send("time out or incorrect query") - - -def setup(client): - client.add_cog(UnoGameCog(client)) diff --git a/scr/Modules/SSC/autoReply/Join.py b/scr/Modules/TMC/autoReply/Join.py similarity index 100% rename from scr/Modules/SSC/autoReply/Join.py rename to scr/Modules/TMC/autoReply/Join.py diff --git a/scr/Modules/SSC/autoReply/Leave.py b/scr/Modules/TMC/autoReply/Leave.py similarity index 100% rename from scr/Modules/SSC/autoReply/Leave.py rename to scr/Modules/TMC/autoReply/Leave.py diff --git a/scr/Modules/SSC/automod/Spam.py b/scr/Modules/TMC/automod/Spam.py similarity index 100% rename from scr/Modules/SSC/automod/Spam.py rename to scr/Modules/TMC/automod/Spam.py diff --git a/scr/bot.py b/scr/bot.py index fcdff9e..fc0bd58 100644 --- a/scr/bot.py +++ b/scr/bot.py @@ -2,9 +2,8 @@ from discord.ext.commands import Bot token = open("../token.txt") -cogs = ["Modules.TGH.automod.automod", "Modules.TGH.automod.ouat", - "Modules.SSC.autoReply.Join", "Modules.SSC.autoReply.Leave", - "Modules.SSC.ChangeServer.Change"] +cogs = ["Modules.TMC.autoReply.Join", "Modules.TMC.autoReply.Leave", + "Modules.TMC.ChangeServer.Change"] prefix = 'o!'