Compare commits
No commits in common. "946590a3a14461ff73fee015feb183a1d3361f14" and "1ddf76707456e92c3693a7a577b167bd9d266563" have entirely different histories.
946590a3a1
...
1ddf767074
@ -26,8 +26,6 @@ from .shared_libs.loggable import Loggable
|
|||||||
# Init logging to output on INFO level to stderr.
|
# Init logging to output on INFO level to stderr.
|
||||||
logging.basicConfig(level="INFO")
|
logging.basicConfig(level="INFO")
|
||||||
|
|
||||||
REBOOT_FILE = "sebimachine/config/reboot"
|
|
||||||
|
|
||||||
|
|
||||||
# If uvloop is installed, change to that eventloop policy as it
|
# If uvloop is installed, change to that eventloop policy as it
|
||||||
# is more efficient
|
# is more efficient
|
||||||
@ -77,11 +75,13 @@ class SebiMachine(commands.Bot, LoadConfig, Loggable):
|
|||||||
# Load plugins
|
# Load plugins
|
||||||
# Add your cog file name in this list
|
# Add your cog file name in this list
|
||||||
with open(in_here("extensions.txt")) as cog_file:
|
with open(in_here("extensions.txt")) as cog_file:
|
||||||
cogs = {f'sebimachine.cogs.{c.strip()}' for c in cog_file.readlines()}
|
cogs = cog_file.readlines()
|
||||||
|
|
||||||
for cog in cogs:
|
for cog in cogs:
|
||||||
|
# Could this just be replaced with `strip()`?
|
||||||
try:
|
try:
|
||||||
self.load_extension(cog)
|
cog = cog.replace("\n", "")
|
||||||
|
self.load_extension(f"src.cogs.{cog}")
|
||||||
self.logger.info(f"Loaded: {cog}")
|
self.logger.info(f"Loaded: {cog}")
|
||||||
except (ModuleNotFoundError, ImportError) as ex:
|
except (ModuleNotFoundError, ImportError) as ex:
|
||||||
logging.exception(f'Could not load {cog}', exc_info=(type(ex), ex, ex.__traceback__))
|
logging.exception(f'Could not load {cog}', exc_info=(type(ex), ex, ex.__traceback__))
|
||||||
@ -90,8 +90,7 @@ class SebiMachine(commands.Bot, LoadConfig, Loggable):
|
|||||||
async def on_ready(self):
|
async def on_ready(self):
|
||||||
"""On ready function"""
|
"""On ready function"""
|
||||||
self.maintenance and self.logger.warning("MAINTENANCE ACTIVE")
|
self.maintenance and self.logger.warning("MAINTENANCE ACTIVE")
|
||||||
if os.path.exists(REBOOT_FILE):
|
with open(f"src/config/reboot", "r") as f:
|
||||||
with open(REBOOT_FILE, "r") as f:
|
|
||||||
reboot = f.readlines()
|
reboot = f.readlines()
|
||||||
if int(reboot[0]) == 1:
|
if int(reboot[0]) == 1:
|
||||||
await self.get_channel(int(reboot[1])).send("Restart Finished.")
|
await self.get_channel(int(reboot[1])).send("Restart Finished.")
|
||||||
@ -101,7 +100,7 @@ class SebiMachine(commands.Bot, LoadConfig, Loggable):
|
|||||||
f'FAILED TO LOAD {cog} BECAUSE OF {type(ex).__name__}: {ex}\n'
|
f'FAILED TO LOAD {cog} BECAUSE OF {type(ex).__name__}: {ex}\n'
|
||||||
f'{tb}'
|
f'{tb}'
|
||||||
)
|
)
|
||||||
with open(REBOOT_FILE, "w") as f:
|
with open(f"src/config/reboot", "w") as f:
|
||||||
f.write(f"0")
|
f.write(f"0")
|
||||||
|
|
||||||
async def on_command_error(self, ctx, error):
|
async def on_command_error(self, ctx, error):
|
||||||
|
|||||||
@ -11,7 +11,7 @@ class BotManager:
|
|||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
# The member is a bot
|
# The member is a bot
|
||||||
bot_owner = member.guild.get_member(await self.bot.db_con.fetchval('select owner from bots where id = $1', member.id))
|
bot_owner = member.guild.get_member((await self.bot.db_con.fetchval('select owner from bots where id = $1', member.id))
|
||||||
await bot_owner.add_roles(discord.utils.get(member.guild.roles, name='Bot Developers'))
|
await bot_owner.add_roles(discord.utils.get(member.guild.roles, name='Bot Developers'))
|
||||||
|
|
||||||
await member.add_roles(discord.utils.get(member.guild.roles, name='Bots'))
|
await member.add_roles(discord.utils.get(member.guild.roles, name='Bots'))
|
||||||
@ -61,7 +61,7 @@ class BotManager:
|
|||||||
await ctx.send(embed=em)
|
await ctx.send(embed=em)
|
||||||
|
|
||||||
em = discord.Embed(title="Bot invite", colour=discord.Color(0x363941))
|
em = discord.Embed(title="Bot invite", colour=discord.Color(0x363941))
|
||||||
em.description = discord.utils.oauth_url(client_id, permissions=None, guild=ctx.guild)
|
em.description = discord.utils.oauth_url(client_id, permissions=None, guild=ctx.guild))
|
||||||
em.set_thumbnail(url=bot.avatar_url)
|
em.set_thumbnail(url=bot.avatar_url)
|
||||||
em.add_field(name="Bot name", value=bot.name)
|
em.add_field(name="Bot name", value=bot.name)
|
||||||
em.add_field(name="Bot id", value="`" + str(bot.id) + "`")
|
em.add_field(name="Bot id", value="`" + str(bot.id) + "`")
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import asyncio
|
|||||||
class Tag:
|
class Tag:
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
with open("sebimachine/shared_libs/tags.json", "r") as fp:
|
with open("src/shared_libs/tags.json", "r") as fp:
|
||||||
json_data = fp.read()
|
json_data = fp.read()
|
||||||
global tags
|
global tags
|
||||||
tags = json.loads(json_data)
|
tags = json.loads(json_data)
|
||||||
|
|||||||
@ -174,36 +174,38 @@ def to_list_of_str(items, out: list=list(), level=1, recurse=0):
|
|||||||
out = to_list_of_str(item, out, new_level, 1)
|
out = to_list_of_str(item, out, new_level, 1)
|
||||||
out.append(f'{" "*level}}}')
|
out.append(f'{" "*level}}}')
|
||||||
else:
|
else:
|
||||||
out.append(f'{" "*level}{quote+key+quote+": " if key else ""}{repr(item)},')
|
out.append(
|
||||||
|
f'{" "*level}{quote+key+quote+": " if key else ""}{repr(item)},'
|
||||||
|
)
|
||||||
|
|
||||||
if type(items) == list:
|
if type(items) == list:
|
||||||
if not recurse:
|
if not recurse:
|
||||||
out = list()
|
out = list()
|
||||||
out.append('[')
|
out.append("[")
|
||||||
for item in items:
|
for item in items:
|
||||||
rec_loop(item, None, out, level)
|
rec_loop(item, None, out, level)
|
||||||
if not recurse:
|
if not recurse:
|
||||||
out.append(']')
|
out.append("]")
|
||||||
elif type(items) == dict:
|
elif type(items) == dict:
|
||||||
if not recurse:
|
if not recurse:
|
||||||
out = list()
|
out = list()
|
||||||
out.append('{')
|
out.append("{")
|
||||||
for key in items:
|
for key in items:
|
||||||
rec_loop(items[key], key, out, level)
|
rec_loop(items[key], key, out, level)
|
||||||
if not recurse:
|
if not recurse:
|
||||||
out.append('}')
|
out.append("}")
|
||||||
|
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
def paginate(text, maxlen=1990):
|
def paginate(text, maxlen=1990):
|
||||||
paginator = Paginator(prefix='```py', max_size=maxlen+10)
|
paginator = Paginator(prefix="```py", max_size=maxlen + 10)
|
||||||
if type(text) == list:
|
if type(text) == list:
|
||||||
data = to_list_of_str(text)
|
data = to_list_of_str(text)
|
||||||
elif type(text) == dict:
|
elif type(text) == dict:
|
||||||
data = to_list_of_str(text)
|
data = to_list_of_str(text)
|
||||||
else:
|
else:
|
||||||
data = str(text).split('\n')
|
data = str(text).split("\n")
|
||||||
for line in data:
|
for line in data:
|
||||||
if len(line) > maxlen:
|
if len(line) > maxlen:
|
||||||
n = maxlen
|
n = maxlen
|
||||||
@ -219,7 +221,8 @@ async def run_command(args):
|
|||||||
process = await asyncio.create_subprocess_shell(
|
process = await asyncio.create_subprocess_shell(
|
||||||
args,
|
args,
|
||||||
# stdout must a pipe to be accessible as process.stdout
|
# stdout must a pipe to be accessible as process.stdout
|
||||||
stdout=asyncio.subprocess.PIPE)
|
stdout=asyncio.subprocess.PIPE,
|
||||||
|
)
|
||||||
# Wait for the subprocess to finish
|
# Wait for the subprocess to finish
|
||||||
stdout, stderr = await process.communicate()
|
stdout, stderr = await process.communicate()
|
||||||
# Return stdout
|
# Return stdout
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user