Skip to content

Commit

Permalink
patched version installer
Browse files Browse the repository at this point in the history
  • Loading branch information
greeeen-dev committed Nov 26, 2024
1 parent 4c9c20c commit 3b99b07
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 7 deletions.
40 changes: 35 additions & 5 deletions bridge_revolt.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import revolt
import traceback
import time
from utils import log
from utils import log, restrictions_legacy as r_legacy
import hashlib
import random
import string
Expand All @@ -33,12 +33,15 @@
import datetime
import re
import json
import sys

try:
import ujson as json # pylint: disable=import-error
except:
pass

restrictions_legacy = r_legacy.Restrictions()

mentions = nextcord.AllowedMentions(everyone=False, roles=False, users=False)

def timetoint(t):
Expand Down Expand Up @@ -178,6 +181,7 @@ def __init__(self,bot):
self.bot.revolt_session = None
self.bot.revolt_client_task = asyncio.create_task(self.revolt_boot())
self.logger = log.buildlogger(self.bot.package, 'revolt.core', self.bot.loglevel)
restrictions_legacy.attach_bot(self.bot)

def db(self):
return self.bot.db
Expand Down Expand Up @@ -1379,10 +1383,9 @@ async def revolt_boot(self):
break

@commands.command(name='stop-revolt', hidden=True)
@restrictions_legacy.owner()
async def stop_revolt(self, ctx):
"""Kills the Revolt client. This is automatically done when upgrading Unifier."""
if not ctx.author.id == self.bot.config['owner']:
return
try:
await self.bot.revolt_session.close()
self.bot.revolt_client_task.cancel()
Expand All @@ -1396,10 +1399,9 @@ async def stop_revolt(self, ctx):
await ctx.send('Something went wrong while killing the instance.')

@commands.command(name='restart-revolt', hidden=True)
@restrictions_legacy.owner()
async def restart_revolt(self, ctx):
"""Restarts the Revolt client."""
if not ctx.author.id == self.bot.config['owner']:
return
try:
await self.bot.revolt_session.close()
self.bot.revolt_client_task.cancel()
Expand All @@ -1412,5 +1414,33 @@ async def restart_revolt(self, ctx):
self.logger.exception('Something went wrong!')
await ctx.send('Something went wrong while restarting the instance.')

@commands.command(name='fix-revolt', hidden=True)
@restrictions_legacy.owner()
async def fix_revolt(self, ctx):
"""Fixes Revolt permissions check bug by switching to a patched version. You only need to run this once."""
with open('boot_config.json') as file:
boot_config = json.load(file)

binary = boot_config['bootloader'].get('binary')
user_option = ' --user' if not boot_config['bootloader'].get('global_dep_install', False) else ''

if not binary:
if sys.platform == 'win32':
binary = 'py -3'
else:
binary = 'python3'

msg = await ctx.send(f'{self.bot.ui_emojis.loading} Fixing...')
code = await self.bot.loop.run_in_executor(
None, lambda: os.system(
f'{binary} -m pip install{user_option} --force https://github.com/greeeen-dev/revolt.py'
)
)

if code > 0:
await msg.edit(content=f'{self.bot.ui_emojis.error} Could not install the patched version.')
else:
await msg.edit(content=f'{self.bot.ui_emojis.success} Installed patch version! Please reboot the bot.')

def setup(bot):
bot.add_cog(Revolt(bot))
4 changes: 2 additions & 2 deletions plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"id": "revolt",
"name": "Revolt Support",
"description": "Unifier Revolt Support extension",
"version": "v1.3.8",
"release": 38,
"version": "v1.3.9",
"release": 39,
"minimum": 58,
"services": [
"bridge_platform"
Expand Down

0 comments on commit 3b99b07

Please sign in to comment.