|
|
|
|
@ -140,13 +140,14 @@ class Rcon:
|
|
|
|
|
To view all the valid ARK servers for this guild see list_ark_servers."""
|
|
|
|
|
if checks.is_rcon_admin(self.bot, ctx):
|
|
|
|
|
if server is not None:
|
|
|
|
|
rcon_connections = json.loads(self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
|
|
|
|
'where guild_id = $1', ctx.guild.id))
|
|
|
|
|
rcon_connections = json.loads(await self.bot.db_con.fetchval('select rcon_connections '
|
|
|
|
|
'from guild_config where guild_id = $1',
|
|
|
|
|
ctx.guild.id))
|
|
|
|
|
server = server.replace('_', ' ').title()
|
|
|
|
|
if server in rcon_connections:
|
|
|
|
|
rcon_connections[server]["monitoring_chat"] = 1
|
|
|
|
|
self.bot.db_con.execute('update guild_config set rcon_connections = $2 where guild_id = $1',
|
|
|
|
|
ctx.guild.id, json.dumps(rcon_connections))
|
|
|
|
|
await self.bot.db_con.execute('update guild_config set rcon_connections = $2 where guild_id = $1',
|
|
|
|
|
ctx.guild.id, json.dumps(rcon_connections))
|
|
|
|
|
channel = self.bot.get_channel(rcon_connections[server]['game_chat_chan_id'])
|
|
|
|
|
await channel.send('Started monitoring on the {0} server.'.format(server))
|
|
|
|
|
await ctx.message.add_reaction('✅')
|
|
|
|
|
@ -182,10 +183,10 @@ class Rcon:
|
|
|
|
|
message = func(ctx, message, rcon_connections['server'])
|
|
|
|
|
await channel.send('{0}'.format(message))
|
|
|
|
|
await asyncio.sleep(1)
|
|
|
|
|
rcon_connections = json.loads(self.bot.db_con.fetchval('select rcon_connections '
|
|
|
|
|
'from guild_config '
|
|
|
|
|
'where guild_id = $1',
|
|
|
|
|
ctx.guild.id))
|
|
|
|
|
rcon_connections = json.loads(await self.bot.db_con.fetchval('select rcon_connections '
|
|
|
|
|
'from guild_config '
|
|
|
|
|
'where guild_id = $1',
|
|
|
|
|
ctx.guild.id))
|
|
|
|
|
await channel.send('Monitoring Stopped')
|
|
|
|
|
else:
|
|
|
|
|
await ctx.send(f'Server not found: {server}')
|
|
|
|
|
@ -201,13 +202,14 @@ class Rcon:
|
|
|
|
|
Context is the same as monitor_chat"""
|
|
|
|
|
if checks.is_rcon_admin(self.bot, ctx):
|
|
|
|
|
if server is not None:
|
|
|
|
|
rcon_connections = json.loads(self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
|
|
|
|
'where guild_id = $1', ctx.guild.id))
|
|
|
|
|
rcon_connections = json.loads(await self.bot.db_con.fetchval('select rcon_connections '
|
|
|
|
|
'from guild_config where guild_id = $1',
|
|
|
|
|
ctx.guild.id))
|
|
|
|
|
server = server.replace('_', ' ').title()
|
|
|
|
|
if server in rcon_connections:
|
|
|
|
|
rcon_connections[server]["monitoring_chat"] = 0
|
|
|
|
|
self.bot.db_con.execute('update guild_config set rcon_connections = $2 where guild_id = $1',
|
|
|
|
|
ctx.guild.id, json.dumps(rcon_connections))
|
|
|
|
|
await self.bot.db_con.execute('update guild_config set rcon_connections = $2 where guild_id = $1',
|
|
|
|
|
ctx.guild.id, json.dumps(rcon_connections))
|
|
|
|
|
else:
|
|
|
|
|
await ctx.send(f'Server not found: {server}')
|
|
|
|
|
else:
|
|
|
|
|
@ -228,8 +230,8 @@ class Rcon:
|
|
|
|
|
"first last"
|
|
|
|
|
To view all the valid ARK servers for this guild see list_ark_servers."""
|
|
|
|
|
if checks.is_rcon_admin(self.bot, ctx):
|
|
|
|
|
rcon_connections = json.loads(self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
|
|
|
|
'where guild_id = $1', ctx.guild.id))
|
|
|
|
|
rcon_connections = json.loads(await self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
|
|
|
|
'where guild_id = $1', ctx.guild.id))
|
|
|
|
|
if server is not None:
|
|
|
|
|
server = server.replace('_', ' ').title()
|
|
|
|
|
if server in rcon_connections:
|
|
|
|
|
@ -267,8 +269,8 @@ class Rcon:
|
|
|
|
|
All strings (<server>, <ip>, <password>) must be contained inside double quotes."""
|
|
|
|
|
if checks.is_rcon_admin(self.bot, ctx):
|
|
|
|
|
server = server.title()
|
|
|
|
|
rcon_connections = json.loads(self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
|
|
|
|
'where guild_id = $1', ctx.guild.id))
|
|
|
|
|
rcon_connections = json.loads(await self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
|
|
|
|
'where guild_id = $1', ctx.guild.id))
|
|
|
|
|
if server not in rcon_connections:
|
|
|
|
|
rcon_connections[server] = {
|
|
|
|
|
'ip': ip,
|
|
|
|
|
@ -279,8 +281,8 @@ class Rcon:
|
|
|
|
|
'msg_chan_id': 0,
|
|
|
|
|
'monitoring_chat': 0
|
|
|
|
|
}
|
|
|
|
|
self.bot.db_con.execute('update guild_config set rcon_connections = $2 where guild_id = $1',
|
|
|
|
|
ctx.guild.id, json.dumps(rcon_connections))
|
|
|
|
|
await self.bot.db_con.execute('update guild_config set rcon_connections = $2 where guild_id = $1',
|
|
|
|
|
ctx.guild.id, json.dumps(rcon_connections))
|
|
|
|
|
await ctx.send('{0} server has been added to my configuration.'.format(server))
|
|
|
|
|
else:
|
|
|
|
|
await ctx.send('This server name is already in my configuration. Please choose another.')
|
|
|
|
|
@ -296,12 +298,12 @@ class Rcon:
|
|
|
|
|
All strings <server> must be contained inside double quotes."""
|
|
|
|
|
if checks.is_rcon_admin(self.bot, ctx):
|
|
|
|
|
server = server.title()
|
|
|
|
|
rcon_connections = json.loads(self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
|
|
|
|
'where guild_id = $1', ctx.guild.id))
|
|
|
|
|
rcon_connections = json.loads(await self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
|
|
|
|
'where guild_id = $1', ctx.guild.id))
|
|
|
|
|
if server in rcon_connections:
|
|
|
|
|
del rcon_connections[server]
|
|
|
|
|
self.bot.db_con.execute('update guild_config set rcon_connections = $2 where guild_id = $1',
|
|
|
|
|
ctx.guild.id, json.dumps(rcon_connections))
|
|
|
|
|
await self.bot.db_con.execute('update guild_config set rcon_connections = $2 where guild_id = $1',
|
|
|
|
|
ctx.guild.id, json.dumps(rcon_connections))
|
|
|
|
|
await ctx.send('{0} has been removed from my configuration.'.format(server))
|
|
|
|
|
else:
|
|
|
|
|
await ctx.send('{0} is not in my configuration.'.format(server))
|
|
|
|
|
@ -316,8 +318,9 @@ class Rcon:
|
|
|
|
|
Example: 76561198024193239,76561198024193239,76561198024193239"""
|
|
|
|
|
if checks.is_rcon_admin(self.bot, ctx):
|
|
|
|
|
if steam_ids is not None:
|
|
|
|
|
rcon_connections = json.loads(self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
|
|
|
|
'where guild_id = $1', ctx.guild.id))
|
|
|
|
|
rcon_connections = json.loads(await self.bot.db_con.fetchval('select rcon_connections '
|
|
|
|
|
'from guild_config where guild_id = $1',
|
|
|
|
|
ctx.guild.id))
|
|
|
|
|
error = 0
|
|
|
|
|
error_msg = ''
|
|
|
|
|
success_msg = 'Adding to the running whitelist on all servers.'
|
|
|
|
|
@ -362,8 +365,8 @@ class Rcon:
|
|
|
|
|
If a server is not specified it will default to running saveworld on all servers in the guild\'s config.
|
|
|
|
|
Will print out "World Saved" for each server when the command completes successfully."""
|
|
|
|
|
if checks.is_rcon_admin(self.bot, ctx):
|
|
|
|
|
rcon_connections = json.loads(self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
|
|
|
|
'where guild_id = $1', ctx.guild.id))
|
|
|
|
|
rcon_connections = json.loads(await self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
|
|
|
|
'where guild_id = $1', ctx.guild.id))
|
|
|
|
|
success_msg = 'Running saveworld'
|
|
|
|
|
if server is None:
|
|
|
|
|
success_msg += ' on all the servers:'
|
|
|
|
|
@ -404,8 +407,8 @@ class Rcon:
|
|
|
|
|
The message will be prefixed with the Discord name of the person running the command.
|
|
|
|
|
Will print "Success" for each server once the broadcast is sent."""
|
|
|
|
|
if checks.is_rcon_admin(self.bot, ctx):
|
|
|
|
|
rcon_connections = json.loads(self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
|
|
|
|
'where guild_id = $1', ctx.guild.id))
|
|
|
|
|
rcon_connections = json.loads(await self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
|
|
|
|
'where guild_id = $1', ctx.guild.id))
|
|
|
|
|
if message is not None:
|
|
|
|
|
message = f'{ctx.author.display_name}: {message}'
|
|
|
|
|
success_msg = f'Broadcasting "{message}" to all servers.'
|
|
|
|
|
@ -441,8 +444,8 @@ class Rcon:
|
|
|
|
|
If <server> has more than one word in it's name it will either need to be surrounded
|
|
|
|
|
by double quotes or the words separated by _"""
|
|
|
|
|
if checks.is_rcon_admin(self.bot, ctx):
|
|
|
|
|
rcon_connections = json.loads(self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
|
|
|
|
'where guild_id = $1', ctx.guild.id))
|
|
|
|
|
rcon_connections = json.loads(await self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
|
|
|
|
'where guild_id = $1', ctx.guild.id))
|
|
|
|
|
if server is not None:
|
|
|
|
|
server = server.replace('_', ' ').title()
|
|
|
|
|
if message is not None:
|
|
|
|
|
@ -479,8 +482,8 @@ class Rcon:
|
|
|
|
|
These channels will be added to the guild's rcon config and are where the
|
|
|
|
|
server chat messages will be sent when monitor_chat is run."""
|
|
|
|
|
if checks.is_rcon_admin(self.bot, ctx):
|
|
|
|
|
rcon_connections = json.loads(self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
|
|
|
|
'where guild_id = $1', ctx.guild.id))
|
|
|
|
|
rcon_connections = json.loads(await self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
|
|
|
|
'where guild_id = $1', ctx.guild.id))
|
|
|
|
|
edited = 0
|
|
|
|
|
category = discord.utils.get(ctx.guild.categories, name='Server Chats')
|
|
|
|
|
if category is None:
|
|
|
|
|
@ -503,8 +506,8 @@ class Rcon:
|
|
|
|
|
rcon_connections[server]['game_chat_chan_id'] = chan.id
|
|
|
|
|
edited = 1
|
|
|
|
|
if edited == 1:
|
|
|
|
|
self.bot.db_con.execute('update guild_config set rcon_connections = $2 where guild_id = $1',
|
|
|
|
|
ctx.guild.id, json.dumps(rcon_connections))
|
|
|
|
|
await self.bot.db_con.execute('update guild_config set rcon_connections = $2 where guild_id = $1',
|
|
|
|
|
ctx.guild.id, json.dumps(rcon_connections))
|
|
|
|
|
await ctx.message.add_reaction('✅')
|
|
|
|
|
else:
|
|
|
|
|
await ctx.send(f'You are not authorized to run this command.')
|
|
|
|
|
@ -514,8 +517,8 @@ class Rcon:
|
|
|
|
|
@commands.check(checks.is_restricted_chan)
|
|
|
|
|
async def list_ark_servers(self, ctx):
|
|
|
|
|
"""Returns a list of all the ARK servers in the current guild\'s config."""
|
|
|
|
|
servers = json.loads(self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
|
|
|
|
'where guild_id = $1', ctx.guild.id))
|
|
|
|
|
servers = json.loads(await self.bot.db_con.fetchval('select rcon_connections from guild_config '
|
|
|
|
|
'where guild_id = $1', ctx.guild.id))
|
|
|
|
|
em = discord.Embed(style='rich',
|
|
|
|
|
title=f'__**There are currently {len(servers)} ARK servers in my config:**__',
|
|
|
|
|
color=discord.Colour.green()
|
|
|
|
|
|