Update su_utils.py
This commit is contained in:
parent
b1872c2804
commit
b3127f89eb
1 changed files with 13 additions and 3 deletions
|
@ -145,12 +145,11 @@ async def _(msg: Bot.MessageSession):
|
||||||
await msg.finish([Plain(result), Image(path)])
|
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()
|
@purge.command()
|
||||||
async def purge_cache(msg: Bot.MessageSession):
|
async def _(msg: Bot.MessageSession):
|
||||||
cache_path = os.path.abspath(Config('cache_path'))
|
cache_path = os.path.abspath(Config('cache_path'))
|
||||||
|
|
||||||
if os.path.exists(cache_path):
|
if os.path.exists(cache_path):
|
||||||
if os.listdir(cache_path):
|
if os.listdir(cache_path):
|
||||||
shutil.rmtree(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"))
|
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_ = module('set', required_superuser=True, base=True)
|
||||||
|
|
||||||
@set_.command('modules <target_id> <modules> ...')
|
@set_.command('modules <target_id> <modules> ...')
|
||||||
|
|
Reference in a new issue