initial commit

This commit is contained in:
officereso 2020-12-06 00:27:37 -06:00
parent 7691d28050
commit 8247cf1c44
12 changed files with 3 additions and 378 deletions

2
.gitignore vendored
View File

@ -1,4 +1,4 @@
/sqlPass.txt
/token.txt
/scr/Modules/SSC/ChangeServer/text.txt
/scr/Modules/TMC/ChangeServer/text.txt
/rcon.txt

View File

@ -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))

View File

@ -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")

View File

@ -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))

View File

@ -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))

View File

@ -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))

View File

@ -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))

View File

@ -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!'