Archived
1
0
Fork 0

Update su_utils.py

This commit is contained in:
多羅狼 2023-12-07 14:40:33 +08:00 committed by GitHub
parent b1872c2804
commit b3127f89eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -145,12 +145,11 @@ async def _(msg: Bot.MessageSession):
await msg.finish([Plain(result), Image(path)])
purge = module('purge', required_superuser=True, base=True)
purge = module('purge', developers=['DoroWolf'], required_superuser=True, base=True)
@purge.command()
async def purge_cache(msg: Bot.MessageSession):
async def _(msg: Bot.MessageSession):
cache_path = os.path.abspath(Config('cache_path'))
if os.path.exists(cache_path):
if os.listdir(cache_path):
shutil.rmtree(cache_path)
@ -163,6 +162,17 @@ async def purge_cache(msg: Bot.MessageSession):
await msg.finish(msg.locale.t("core.message.purge.empty"))
@purge.schedule(CronTrigger.from_crontab('0 0 * * *'))
async def _():
cache_path = os.path.abspath(Config('cache_path'))
Logger.info('Start purging cache...')
if os.path.exists(cache_path):
shutil.rmtree(cache_path)
os.mkdir(cache_path)
else:
os.mkdir(cache_path)
set_ = module('set', required_superuser=True, base=True)
@set_.command('modules <target_id> <modules> ...')