Initial commit

This commit is contained in:
xtaodada 2022-02-02 21:03:59 +08:00
parent 5aae164e03
commit 8ee30d394c
No known key found for this signature in database
GPG Key ID: EE4DC37B55E24736

View File

@ -139,22 +139,24 @@ async def plugin(__: Client, context: Message):
if len(context.parameter) == 2: if len(context.parameter) == 2:
if exists(f"{plugin_directory}{context.parameter[1]}.py"): if exists(f"{plugin_directory}{context.parameter[1]}.py"):
remove(f"{plugin_directory}{context.parameter[1]}.py") remove(f"{plugin_directory}{context.parameter[1]}.py")
with open(f"{plugin_directory}version.json", 'r', encoding="utf-8") as f: if exists(f"{plugin_directory}version.json"):
version_json = json.load(f) with open(f"{plugin_directory}version.json", 'r', encoding="utf-8") as f:
version_json[context.parameter[1]] = '0.0' version_json = json.load(f)
with open(f"{plugin_directory}version.json", 'w') as f: version_json[context.parameter[1]] = '0.0'
json.dump(version_json, f) with open(f"{plugin_directory}version.json", 'w') as f:
json.dump(version_json, f)
result = await context.edit( result = await context.edit(
f"{lang('apt_remove_success')} {context.parameter[1]}, {lang('apt_reboot')} ") f"{lang('apt_remove_success')} {context.parameter[1]}, {lang('apt_reboot')} ")
await log(f"{lang('apt_remove')} {context.parameter[1]}.") await log(f"{lang('apt_remove')} {context.parameter[1]}.")
exit(1) exit(1)
elif exists(f"{plugin_directory}{context.parameter[1]}.py.disabled"): elif exists(f"{plugin_directory}{context.parameter[1]}.py.disabled"):
remove(f"{plugin_directory}{context.parameter[1]}.py.disabled") remove(f"{plugin_directory}{context.parameter[1]}.py.disabled")
with open(f"{plugin_directory}version.json", 'r', encoding="utf-8") as f: if exists(f"{plugin_directory}version.json"):
version_json = json.load(f) with open(f"{plugin_directory}version.json", 'r', encoding="utf-8") as f:
version_json[context.parameter[1]] = '0.0' version_json = json.load(f)
with open(f"{plugin_directory}version.json", 'w') as f: version_json[context.parameter[1]] = '0.0'
json.dump(version_json, f) with open(f"{plugin_directory}version.json", 'w') as f:
json.dump(version_json, f)
await context.edit(f"{lang('apt_removed_plugins')} {context.parameter[1]}.") await context.edit(f"{lang('apt_removed_plugins')} {context.parameter[1]}.")
await log(f"{lang('apt_removed_plugins')} {context.parameter[1]}.") await log(f"{lang('apt_removed_plugins')} {context.parameter[1]}.")
elif "/" in context.parameter[1]: elif "/" in context.parameter[1]: