Merge branch 'master' into development
This commit is contained in:
commit
71f824c21d
@ -18,7 +18,8 @@ RUN apk update && \
|
|||||||
# https://docs.djangoproject.com/en/dev/ref/django-admin/#dbshell
|
# https://docs.djangoproject.com/en/dev/ref/django-admin/#dbshell
|
||||||
&& apk add postgresql-client \
|
&& apk add postgresql-client \
|
||||||
# Install git
|
# Install git
|
||||||
&& apk add git openssh-client
|
&& apk add git openssh-client \
|
||||||
|
&& apk add ghc
|
||||||
|
|
||||||
RUN mkdir /code
|
RUN mkdir /code
|
||||||
WORKDIR /code
|
WORKDIR /code
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import inspect
|
|||||||
import sys
|
import sys
|
||||||
import psutil
|
import psutil
|
||||||
import math
|
import math
|
||||||
|
import time
|
||||||
from geeksbot.imports import utils
|
from geeksbot.imports import utils
|
||||||
|
|
||||||
admin_logger = logging.getLogger('admin')
|
admin_logger = logging.getLogger('admin')
|
||||||
@ -60,10 +61,10 @@ class Admin(commands.Cog):
|
|||||||
title=f'Pong 🏓',
|
title=f'Pong 🏓',
|
||||||
color=discord.Colour.green()
|
color=discord.Colour.green()
|
||||||
)
|
)
|
||||||
|
time1 = time.monotonic()
|
||||||
msg = await ctx.send(embed=em)
|
msg = await ctx.send(embed=em)
|
||||||
time1 = ctx.message.created_at
|
time_dif = (time.monotonic() - time1) * 1000
|
||||||
time = (msg.created_at - time1).total_seconds() * 1000
|
em.description = f'Response Time: **{math.ceil(time_dif)}ms**\n' \
|
||||||
em.description = f'Response Time: **{math.ceil(time)}ms**\n' \
|
|
||||||
f'Discord Latency: **{math.ceil(self.bot.latency*1000)}ms**'
|
f'Discord Latency: **{math.ceil(self.bot.latency*1000)}ms**'
|
||||||
await msg.edit(embed=em)
|
await msg.edit(embed=em)
|
||||||
|
|
||||||
|
|||||||
@ -559,83 +559,75 @@ class Rcon(commands.Cog):
|
|||||||
# await ctx.send(f'{server} is not currently in the configuration for this guild.')
|
# await ctx.send(f'{server} is not currently in the configuration for this guild.')
|
||||||
# else:
|
# else:
|
||||||
# await ctx.send(f'You are not authorized to run this command.')
|
# await ctx.send(f'You are not authorized to run this command.')
|
||||||
#
|
|
||||||
# @commands.group(case_insensitive=True)
|
async def _broadcast(self, *, message: str, server_name: str,
|
||||||
# async def broadcast(self, ctx):
|
msg: discord.Message, message_lock: asyncio.Lock):
|
||||||
# """Run help broadcast for more info"""
|
suc = await self.bot.aio_session.post(
|
||||||
# pass
|
f'{self.bot.api_base}/rcon/{msg.guild.id}/{server_name}/broadcast/',
|
||||||
#
|
headers=self.bot.auth_header,
|
||||||
# @broadcast.command(name='all', aliases=['a'])
|
json={'message': message}
|
||||||
# @commands.guild_only()
|
)
|
||||||
# async def broadcast_all(self, ctx, *, message=None):
|
print(await suc.json())
|
||||||
# """Sends a broadcast message to all servers in the guild config.
|
if suc.status == 400:
|
||||||
# The message will be prefixed with the Discord name of the person running the command.
|
resp = (await suc.json())['details']
|
||||||
# Will print "Success" for each server once the broadcast is sent."""
|
elif suc.status in (404, 408):
|
||||||
# if await checks.is_rcon_admin(self.bot, ctx):
|
resp = (await suc.json())['details']
|
||||||
# if message is not None:
|
else:
|
||||||
#
|
resp = '\n'.join(await suc.json())
|
||||||
# # noinspection PyShadowingNames
|
if resp == 'Server received, But no response!!':
|
||||||
# async def _broadcast(*, message: str, server_con: arcon.ARKServer, server_name: str,
|
with await message_lock:
|
||||||
# msg: discord.Message, message_lock: asyncio.Lock):
|
msg = await msg.channel.fetch_message(msg.id)
|
||||||
# print(server_con.host, server_con.port)
|
await msg.edit(content=f'{msg.content}\n{server_name} Success')
|
||||||
# response = await server_con.broadcast(message)
|
else:
|
||||||
# if response == 'Server received, But no response!!':
|
with await message_lock:
|
||||||
# with await message_lock:
|
msg = await msg.channel.fetch_message(msg.id)
|
||||||
# msg = await msg.channel.get_message(msg.id)
|
await msg.edit(content=f'{msg.content}\n{server_name} Failed\n{resp}')
|
||||||
# await msg.edit(content=f'{msg.content}\n{server_name} Success')
|
|
||||||
# else:
|
@commands.group(case_insensitive=True)
|
||||||
# with await message_lock:
|
@commands.guild_only()
|
||||||
# msg = await msg.channel.get_message(msg.id)
|
@checks.is_moderator()
|
||||||
# await msg.edit(content=f'{msg.content}\n{server_name} Failed')
|
async def broadcast(self, ctx, server_name, *, message=None):
|
||||||
# futures = []
|
"""Sends a broadcast message to all servers in the guild config.
|
||||||
# rcon_connections: dict = await self.get_rcon_server_by_name(guild_config=ctx.guild_config,
|
The message will be prefixed with the Discord name of the person running the command.
|
||||||
# name='*')
|
Will print "Success" for each server once the broadcast is sent."""
|
||||||
# if rcon_connections:
|
if message is not None:
|
||||||
# message = ''.join(i for i in f'{ctx.author.display_name}: {message}' if ord(i) < 128)
|
resp = await self.bot.aio_session.get(
|
||||||
# msg = await ctx.send(f'Broadcasting "{message}" to all servers.')
|
f'{self.bot.api_base}/rcon/{ctx.guild.id}/',
|
||||||
# lock = asyncio.Lock()
|
headers=self.bot.auth_header
|
||||||
# for server_name, server_con in rcon_connections.items():
|
)
|
||||||
# futures.append(_broadcast(message=message, server_con=server_con, server_name=server_name,
|
if resp.status != 200:
|
||||||
# msg=msg, message_lock=lock))
|
await ctx.send('There was a problem getting the servers for this guild.')
|
||||||
# self.bot.loop.create_task(asyncio.gather(*futures))
|
return
|
||||||
# await ctx.message.add_reaction('✅')
|
guild_servers = await resp.json()
|
||||||
# else:
|
# noinspection PyShadowingNames
|
||||||
# await ctx.send('There are no available servers for this guild.')
|
|
||||||
# else:
|
futures = []
|
||||||
# await ctx.send('You must include a message with this command.')
|
error = False
|
||||||
# else:
|
if server_name == 'all':
|
||||||
# await ctx.send(f'You are not authorized to run this command.')
|
message = ''.join(i for i in f'{ctx.author.display_name}: {message}' if ord(i) < 128)
|
||||||
#
|
msg = await ctx.send(f'Broadcasting "{message}" to all servers.')
|
||||||
# @broadcast.command(name='server')
|
lock = asyncio.Lock()
|
||||||
# @commands.guild_only()
|
for server in guild_servers:
|
||||||
# async def broadcast_server(self, ctx, server, *, message=None):
|
futures.append(self._broadcast(message=message, server_name=server["name"],
|
||||||
# """Sends a broadcast message to the specified server that is in the guild's config.
|
msg=msg, message_lock=lock))
|
||||||
# The message will be prefixed with the Discord name of the person running the command.
|
else:
|
||||||
# If <server> has more than one word in it's name it will either need to be surrounded
|
for server in guild_servers:
|
||||||
# by double quotes or the words separated by _"""
|
if server["name"].lower().replace(" ", "_") == server_name.lower():
|
||||||
# if await checks.is_rcon_admin(self.bot, ctx):
|
message = ''.join(i for i in f'{ctx.author.display_name}: {message}' if ord(i) < 128)
|
||||||
# if server is not None:
|
msg = await ctx.send(f'Broadcasting "{message}" to {server["name"]}.')
|
||||||
# server = server.replace('_', ' ').title()
|
lock = asyncio.Lock()
|
||||||
# if message is not None:
|
futures.append(self._broadcast(message=message, server_name=server["name"],
|
||||||
# message = ''.join(i for i in f'{ctx.author.display_name}: {message}' if ord(i) < 128)
|
msg=msg, message_lock=lock))
|
||||||
# server_con: arcon.ARKServer = await self.get_rcon_server_by_name(
|
break
|
||||||
# guild_config=ctx.guild_config, name=server
|
else:
|
||||||
# )
|
await ctx.send('That server is not configured in this guild.')
|
||||||
# if server_con:
|
error = True
|
||||||
# msg = await ctx.send(f'Broadcasting "{message}" to {server}.')
|
if not error:
|
||||||
# response = await server_con.broadcast(message)
|
await asyncio.gather(*futures, loop=self.bot.loop)
|
||||||
# if response == 'Server received, But no response!!':
|
await ctx.message.add_reaction('✅')
|
||||||
# await msg.add_reaction(self.bot.unicode_emojis['y'])
|
|
||||||
# else:
|
else:
|
||||||
# await msg.add_reaction(self.bot.unicode_emojis['x'])
|
await ctx.send('You must include a message with this command.')
|
||||||
# else:
|
|
||||||
# await ctx.send(f'{server} is not in the config for this guild')
|
|
||||||
# else:
|
|
||||||
# await ctx.send('You must include a message with this command.')
|
|
||||||
# else:
|
|
||||||
# await ctx.send('You must include a server with this command')
|
|
||||||
# else:
|
|
||||||
# await ctx.send(f'You are not authorized to run this command.')
|
|
||||||
#
|
#
|
||||||
# @commands.command(aliases=['servers', 'list_servers'])
|
# @commands.command(aliases=['servers', 'list_servers'])
|
||||||
# @commands.guild_only()
|
# @commands.guild_only()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user