Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions dozer/cogs/maintenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,26 @@ async def update(self, ctx: DozerContext):
This pulls from whatever repository `origin` is linked to.
If there are changes to download, and the download is successful, the bot restarts to apply changes.
"""
msg = await ctx.send("Updating...")
res = os.popen("git pull").read()
if res.startswith('Already up to date.') or "CONFLICT (content):" in res:
await ctx.send('```\n' + res + '```')
else:
await ctx.send('```\n' + res + '```')
# Run pip update on requirements.txt
res = os.popen("pip install -r requirements.txt").read()
new_res = ""
for line in res.split('\n'):
if line.startswith('Requirement already satisfied'):
new_res += "Requirement already satisfied...\n"
else:
new_res += line + '\n'
if len(new_res) > 2000:
await ctx.send("```\n" + new_res[:2000] + "```")
await ctx.send("```\n" + new_res[2000:3999] + "```")
else:
await ctx.send('```\n' + new_res + '```')
await msg.edit(content="Restarting...")
await ctx.bot.get_command('restart').callback(self, ctx)

update.example_usage = """
Expand Down