2020-02-19 15:31:39 +00:00
|
|
|
""" PagerMaid module to manage plugins. """
|
|
|
|
|
2020-08-11 12:47:34 +00:00
|
|
|
import json
|
2020-08-11 14:30:54 +00:00
|
|
|
from re import search, I
|
2020-08-11 12:47:34 +00:00
|
|
|
from requests import get
|
2020-02-19 15:31:39 +00:00
|
|
|
from os import remove, rename, chdir, path
|
|
|
|
from os.path import exists
|
|
|
|
from shutil import copyfile, move
|
|
|
|
from glob import glob
|
|
|
|
from pagermaid import log, working_dir
|
|
|
|
from pagermaid.listener import listener
|
2021-06-15 04:31:05 +00:00
|
|
|
from pagermaid.utils import upload_attachment, lang, alias_command
|
2020-02-19 15:31:39 +00:00
|
|
|
from pagermaid.modules import plugin_list as active_plugins, __list_plugins
|
|
|
|
|
|
|
|
|
2021-06-14 10:24:23 +00:00
|
|
|
def get_html(url):
|
|
|
|
data = get(url)
|
|
|
|
return data.status_code, data.content
|
|
|
|
|
|
|
|
|
|
|
|
def remove_plugin(name):
|
|
|
|
plugin_directory = f"{working_dir}/plugins/"
|
|
|
|
try:
|
|
|
|
remove(f"{plugin_directory}{name}")
|
|
|
|
except FileNotFoundError:
|
|
|
|
pass
|
|
|
|
try:
|
|
|
|
remove(f"{plugin_directory}{name}.disabled")
|
|
|
|
except FileNotFoundError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
def download(name):
|
|
|
|
status, html = get_html(f'https://raw.githubusercontent.com/Xtao-Labs/PagerMaid_Plugins/master/{name}.py')
|
|
|
|
with open(f'plugins/{name}.py', mode='wb') as f:
|
|
|
|
f.write(html)
|
|
|
|
return f'plugins/{name}.py'
|
|
|
|
|
|
|
|
|
2021-02-07 10:55:35 +00:00
|
|
|
def move_plugin(file_path):
|
|
|
|
plugin_directory = f"{working_dir}/plugins/"
|
2021-06-14 10:24:23 +00:00
|
|
|
try:
|
2021-02-07 10:55:35 +00:00
|
|
|
remove(f"{plugin_directory}{file_path}")
|
2021-06-14 10:24:23 +00:00
|
|
|
except FileNotFoundError:
|
|
|
|
pass
|
|
|
|
try:
|
2021-02-07 10:55:35 +00:00
|
|
|
remove(f"{plugin_directory}{file_path}.disabled")
|
2021-06-14 10:24:23 +00:00
|
|
|
except FileNotFoundError:
|
|
|
|
pass
|
|
|
|
move(file_path, plugin_directory)
|
2021-02-07 10:55:35 +00:00
|
|
|
|
|
|
|
|
2021-06-14 10:24:23 +00:00
|
|
|
def update_version(plugin_name, version):
|
2021-02-07 11:04:25 +00:00
|
|
|
plugin_directory = f"{working_dir}/plugins/"
|
2021-02-07 10:55:35 +00:00
|
|
|
with open(f"{plugin_directory}version.json", 'r', encoding="utf-8") as f:
|
|
|
|
version_json = json.load(f)
|
|
|
|
version_json[plugin_name] = version
|
|
|
|
with open(f"{plugin_directory}version.json", 'w') as f:
|
|
|
|
json.dump(version_json, f)
|
|
|
|
|
|
|
|
|
2021-06-15 04:31:05 +00:00
|
|
|
@listener(is_plugin=False, outgoing=True, command=alias_command('apt'), diagnostics=False,
|
2021-04-12 16:25:32 +00:00
|
|
|
description=lang('apt_des'),
|
|
|
|
parameters=lang('apt_parameters'))
|
2020-02-19 15:31:39 +00:00
|
|
|
async def plugin(context):
|
2021-02-07 10:55:35 +00:00
|
|
|
if len(context.parameter) == 0:
|
2021-04-12 16:25:32 +00:00
|
|
|
await context.edit(lang('arg_error'))
|
2020-02-19 15:31:39 +00:00
|
|
|
return
|
|
|
|
reply = await context.get_reply_message()
|
|
|
|
plugin_directory = f"{working_dir}/plugins/"
|
|
|
|
if context.parameter[0] == "install":
|
|
|
|
if len(context.parameter) == 1:
|
2021-04-12 16:25:32 +00:00
|
|
|
await context.edit(lang('apt_processing'))
|
2020-02-19 15:31:39 +00:00
|
|
|
if reply:
|
|
|
|
file_path = await context.client.download_media(reply)
|
|
|
|
else:
|
|
|
|
file_path = await context.download_media()
|
|
|
|
if file_path is None or not file_path.endswith('.py'):
|
2021-04-12 16:25:32 +00:00
|
|
|
await context.edit(lang('apt_no_py'))
|
2020-02-19 15:31:39 +00:00
|
|
|
try:
|
|
|
|
remove(str(file_path))
|
|
|
|
except FileNotFoundError:
|
|
|
|
pass
|
|
|
|
return
|
2021-02-07 10:55:35 +00:00
|
|
|
move_plugin(file_path)
|
2021-06-14 10:24:23 +00:00
|
|
|
await context.edit(
|
|
|
|
f"{lang('apt_plugin')} {path.basename(file_path)[:-3]} {lang('apt_installed')},{lang('apt_reboot')}")
|
2021-04-12 16:25:32 +00:00
|
|
|
await log(f"{lang('apt_install_success')} {path.basename(file_path)[:-3]}.")
|
2020-02-19 15:31:39 +00:00
|
|
|
await context.client.disconnect()
|
2021-02-07 10:55:35 +00:00
|
|
|
elif len(context.parameter) >= 2:
|
2021-04-12 16:25:32 +00:00
|
|
|
await context.edit(lang('apt_processing'))
|
2021-06-14 10:24:23 +00:00
|
|
|
process_list = context.parameter
|
|
|
|
del process_list[0]
|
2021-02-07 10:55:35 +00:00
|
|
|
success_list = []
|
|
|
|
failed_list = []
|
|
|
|
noneed_list = []
|
2021-06-14 10:24:23 +00:00
|
|
|
temp, plugin_list = get_html("https://raw.githubusercontent.com/Xtao-Labs/PagerMaid_Plugins/master"
|
|
|
|
"/list.json")
|
|
|
|
plugin_list = json.loads(plugin_list)['list']
|
|
|
|
for i in process_list:
|
2021-02-07 10:55:35 +00:00
|
|
|
if exists(f"{plugin_directory}version.json"):
|
|
|
|
with open(f"{plugin_directory}version.json", 'r', encoding="utf-8") as f:
|
|
|
|
version_json = json.load(f)
|
|
|
|
try:
|
2021-06-14 10:24:23 +00:00
|
|
|
plugin_version = version_json[i]
|
2021-02-07 10:55:35 +00:00
|
|
|
except:
|
2021-06-14 10:24:23 +00:00
|
|
|
plugin_version = 0
|
2021-02-07 10:55:35 +00:00
|
|
|
else:
|
|
|
|
temp_dict = {}
|
|
|
|
with open(f"{plugin_directory}version.json", 'w') as f:
|
|
|
|
json.dump(temp_dict, f)
|
2021-06-14 10:24:23 +00:00
|
|
|
plugin_version = 0
|
|
|
|
temp = True
|
|
|
|
for x in plugin_list:
|
|
|
|
if x['name'] == i:
|
|
|
|
if (float(x['version']) - float(plugin_version)) <= 0:
|
|
|
|
noneed_list.append(i)
|
|
|
|
temp = False
|
|
|
|
break
|
2020-08-11 12:47:34 +00:00
|
|
|
else:
|
2021-06-14 10:24:23 +00:00
|
|
|
remove_plugin(f'{i}.py')
|
|
|
|
download(i)
|
2021-06-15 02:37:01 +00:00
|
|
|
update_version(i, x['version'])
|
2021-06-14 10:24:23 +00:00
|
|
|
success_list.append(i)
|
|
|
|
temp = False
|
|
|
|
break
|
|
|
|
if temp:
|
|
|
|
failed_list.append(i)
|
2021-02-07 10:55:35 +00:00
|
|
|
message = ""
|
|
|
|
if len(success_list) > 0:
|
2021-04-12 16:25:32 +00:00
|
|
|
message += lang('apt_install_success') + " : %s\n" % ", ".join(success_list)
|
2021-02-07 10:55:35 +00:00
|
|
|
if len(failed_list) > 0:
|
2021-04-12 16:25:32 +00:00
|
|
|
message += lang('apt_install_failed') + " %s\n" % ", ".join(failed_list)
|
2021-02-07 10:55:35 +00:00
|
|
|
if len(noneed_list) > 0:
|
2021-04-12 16:25:32 +00:00
|
|
|
message += lang('apt_no_update') + " %s\n" % ", ".join(noneed_list)
|
2021-02-07 10:55:35 +00:00
|
|
|
await log(message)
|
|
|
|
restart = len(success_list) > 0
|
|
|
|
if restart:
|
2021-04-12 16:25:32 +00:00
|
|
|
message += lang('apt_reboot')
|
2021-02-07 10:55:35 +00:00
|
|
|
await context.edit(message)
|
|
|
|
if restart:
|
|
|
|
await context.client.disconnect()
|
2020-02-19 15:31:39 +00:00
|
|
|
else:
|
2021-04-12 16:25:32 +00:00
|
|
|
await context.edit(lang('arg_error'))
|
2020-02-19 15:31:39 +00:00
|
|
|
elif context.parameter[0] == "remove":
|
|
|
|
if len(context.parameter) == 2:
|
|
|
|
if exists(f"{plugin_directory}{context.parameter[1]}.py"):
|
|
|
|
remove(f"{plugin_directory}{context.parameter[1]}.py")
|
2020-08-11 12:47:34 +00:00
|
|
|
with open(f"{plugin_directory}version.json", 'r', encoding="utf-8") as f:
|
|
|
|
version_json = json.load(f)
|
|
|
|
version_json[context.parameter[1]] = '0.0'
|
|
|
|
with open(f"{plugin_directory}version.json", 'w') as f:
|
|
|
|
json.dump(version_json, f)
|
2021-04-12 16:25:32 +00:00
|
|
|
await context.edit(f"{lang('apt_remove_success')} {context.parameter[1]}, {lang('apt_reboot')} ")
|
|
|
|
await log(f"{lang('apt_remove')} {context.parameter[1]}.")
|
2020-02-19 15:31:39 +00:00
|
|
|
await context.client.disconnect()
|
|
|
|
elif exists(f"{plugin_directory}{context.parameter[1]}.py.disabled"):
|
|
|
|
remove(f"{plugin_directory}{context.parameter[1]}.py.disabled")
|
2020-08-11 12:47:34 +00:00
|
|
|
with open(f"{plugin_directory}version.json", 'r', encoding="utf-8") as f:
|
|
|
|
version_json = json.load(f)
|
|
|
|
version_json[context.parameter[1]] = '0.0'
|
|
|
|
with open(f"{plugin_directory}version.json", 'w') as f:
|
|
|
|
json.dump(version_json, f)
|
2021-04-12 16:25:32 +00:00
|
|
|
await context.edit(f"{lang('apt_removed_plugins')} {context.parameter[1]}.")
|
|
|
|
await log(f"{lang('apt_removed_plugins')} {context.parameter[1]}.")
|
2020-02-19 15:31:39 +00:00
|
|
|
elif "/" in context.parameter[1]:
|
2021-04-12 16:25:32 +00:00
|
|
|
await context.edit(lang('arg_error'))
|
2020-02-19 15:31:39 +00:00
|
|
|
else:
|
2021-04-12 16:25:32 +00:00
|
|
|
await context.edit(lang('apt_not_exist'))
|
2020-02-19 15:31:39 +00:00
|
|
|
else:
|
2021-04-12 16:25:32 +00:00
|
|
|
await context.edit(lang('arg_error'))
|
2020-02-19 15:31:39 +00:00
|
|
|
elif context.parameter[0] == "status":
|
|
|
|
if len(context.parameter) == 1:
|
|
|
|
inactive_plugins = sorted(__list_plugins())
|
|
|
|
disabled_plugins = []
|
|
|
|
if not len(inactive_plugins) == 0:
|
|
|
|
for target_plugin in active_plugins:
|
|
|
|
inactive_plugins.remove(target_plugin)
|
|
|
|
chdir("plugins/")
|
|
|
|
for target_plugin in glob(f"*.py.disabled"):
|
|
|
|
disabled_plugins += [f"{target_plugin[:-12]}"]
|
|
|
|
chdir("../")
|
|
|
|
active_plugins_string = ""
|
|
|
|
inactive_plugins_string = ""
|
|
|
|
disabled_plugins_string = ""
|
|
|
|
for target_plugin in active_plugins:
|
|
|
|
active_plugins_string += f"{target_plugin}, "
|
|
|
|
active_plugins_string = active_plugins_string[:-2]
|
|
|
|
for target_plugin in inactive_plugins:
|
|
|
|
inactive_plugins_string += f"{target_plugin}, "
|
|
|
|
inactive_plugins_string = inactive_plugins_string[:-2]
|
|
|
|
for target_plugin in disabled_plugins:
|
|
|
|
disabled_plugins_string += f"{target_plugin}, "
|
|
|
|
disabled_plugins_string = disabled_plugins_string[:-2]
|
|
|
|
if len(active_plugins) == 0:
|
2021-04-12 16:25:32 +00:00
|
|
|
active_plugins_string = f"`{lang('apt_no_running_plugins')}`"
|
2020-02-19 15:31:39 +00:00
|
|
|
if len(inactive_plugins) == 0:
|
2021-04-12 16:25:32 +00:00
|
|
|
inactive_plugins_string = f"`{lang('apt_no_load_falied_plugins')}`"
|
2020-02-19 15:31:39 +00:00
|
|
|
if len(disabled_plugins) == 0:
|
2021-04-12 16:25:32 +00:00
|
|
|
disabled_plugins_string = f"`{lang('apt_no_disabled_plugins')}`"
|
|
|
|
output = f"**{lang('apt_plugin_list')}**\n" \
|
|
|
|
f"{lang('apt_plugin_running')}: {active_plugins_string}\n" \
|
|
|
|
f"{lang('apt_plugin_disabled')}: {disabled_plugins_string}\n" \
|
|
|
|
f"{lang('apt_plugin_failed')}: {inactive_plugins_string}"
|
2020-02-19 15:31:39 +00:00
|
|
|
await context.edit(output)
|
|
|
|
else:
|
2021-04-12 16:25:32 +00:00
|
|
|
await context.edit(lang('arg_error'))
|
2020-02-19 15:31:39 +00:00
|
|
|
elif context.parameter[0] == "enable":
|
|
|
|
if len(context.parameter) == 2:
|
|
|
|
if exists(f"{plugin_directory}{context.parameter[1]}.py.disabled"):
|
|
|
|
rename(f"{plugin_directory}{context.parameter[1]}.py.disabled",
|
|
|
|
f"{plugin_directory}{context.parameter[1]}.py")
|
2021-06-14 10:24:23 +00:00
|
|
|
await context.edit(
|
|
|
|
f"{lang('apt_plugin')} {context.parameter[1]} {lang('apt_enable')},{lang('apt_reboot')}")
|
2021-04-12 16:25:32 +00:00
|
|
|
await log(f"{lang('apt_enable')} {context.parameter[1]}.")
|
2020-02-19 15:31:39 +00:00
|
|
|
await context.client.disconnect()
|
|
|
|
else:
|
2021-04-12 16:25:32 +00:00
|
|
|
await context.edit(lang('apt_not_exist'))
|
2020-02-19 15:31:39 +00:00
|
|
|
else:
|
2021-04-12 16:25:32 +00:00
|
|
|
await context.edit(lang('arg_error'))
|
2020-02-19 15:31:39 +00:00
|
|
|
elif context.parameter[0] == "disable":
|
|
|
|
if len(context.parameter) == 2:
|
|
|
|
if exists(f"{plugin_directory}{context.parameter[1]}.py") is True:
|
|
|
|
rename(f"{plugin_directory}{context.parameter[1]}.py",
|
|
|
|
f"{plugin_directory}{context.parameter[1]}.py.disabled")
|
2021-06-14 10:24:23 +00:00
|
|
|
await context.edit(
|
|
|
|
f"{lang('apt_plugin')} {context.parameter[1]} {lang('apt_disable')},{lang('apt_reboot')}")
|
2021-04-12 16:25:32 +00:00
|
|
|
await log(f"{lang('apt_disable')} {context.parameter[1]}.")
|
2020-02-19 15:31:39 +00:00
|
|
|
await context.client.disconnect()
|
|
|
|
else:
|
2021-04-12 16:25:32 +00:00
|
|
|
await context.edit(lang('apt_not_exist'))
|
2020-02-19 15:31:39 +00:00
|
|
|
else:
|
2021-04-12 16:25:32 +00:00
|
|
|
await context.edit(lang('arg_error'))
|
2020-02-19 15:31:39 +00:00
|
|
|
elif context.parameter[0] == "upload":
|
|
|
|
if len(context.parameter) == 2:
|
|
|
|
file_name = f"{context.parameter[1]}.py"
|
|
|
|
reply_id = None
|
|
|
|
if reply:
|
|
|
|
reply_id = reply.id
|
|
|
|
if exists(f"{plugin_directory}{file_name}"):
|
|
|
|
copyfile(f"{plugin_directory}{file_name}", file_name)
|
|
|
|
elif exists(f"{plugin_directory}{file_name}.disabled"):
|
|
|
|
copyfile(f"{plugin_directory}{file_name}.disabled", file_name)
|
|
|
|
if exists(file_name):
|
2021-04-12 16:25:32 +00:00
|
|
|
await context.edit(lang('apt_uploading'))
|
2020-02-19 15:31:39 +00:00
|
|
|
await upload_attachment(file_name,
|
|
|
|
context.chat_id, reply_id,
|
2020-02-29 02:02:38 +00:00
|
|
|
caption=f"PagerMaid-Modify {context.parameter[1]} plugin.")
|
2020-02-19 15:31:39 +00:00
|
|
|
remove(file_name)
|
|
|
|
await context.delete()
|
|
|
|
else:
|
2021-04-12 16:25:32 +00:00
|
|
|
await context.edit(lang('apt_not_exist'))
|
2020-02-19 15:31:39 +00:00
|
|
|
else:
|
2021-04-12 16:25:32 +00:00
|
|
|
await context.edit(lang('arg_error'))
|
2020-08-11 12:47:34 +00:00
|
|
|
elif context.parameter[0] == "update":
|
2021-04-12 16:25:32 +00:00
|
|
|
unneed_update = lang('apt_no_update')
|
|
|
|
need_update = f"\n{lang('apt_updated')}:"
|
2021-01-23 12:22:59 +00:00
|
|
|
need_update_list = []
|
2020-08-11 15:49:16 +00:00
|
|
|
if not exists(f"{plugin_directory}version.json"):
|
2021-04-12 16:25:32 +00:00
|
|
|
await context.edit(lang('apt_why_not_install_a_plugin'))
|
2020-08-11 15:49:16 +00:00
|
|
|
return
|
2020-08-11 12:47:34 +00:00
|
|
|
with open(f"{plugin_directory}version.json", 'r', encoding="utf-8") as f:
|
|
|
|
version_json = json.load(f)
|
2021-06-14 10:24:23 +00:00
|
|
|
temp, plugin_list = get_html("https://raw.githubusercontent.com/Xtao-Labs/PagerMaid_Plugins/master/list"
|
|
|
|
".json")
|
|
|
|
plugin_online = json.loads(plugin_list)['list']
|
2020-08-11 12:47:34 +00:00
|
|
|
for key, value in version_json.items():
|
|
|
|
if value == "0.0":
|
|
|
|
continue
|
|
|
|
for i in plugin_online:
|
|
|
|
if key == i['name']:
|
|
|
|
if (float(i['version']) - float(value)) <= 0:
|
2021-04-12 16:25:32 +00:00
|
|
|
unneed_update += "\n`" + key + "`:Ver " + value
|
2020-08-11 12:47:34 +00:00
|
|
|
else:
|
2021-01-23 12:22:59 +00:00
|
|
|
need_update_list.extend([key])
|
2021-04-12 16:25:32 +00:00
|
|
|
need_update += "\n`" + key + "`:Ver " + value + " --> Ver " + i['version']
|
2020-08-11 12:47:34 +00:00
|
|
|
continue
|
2021-04-12 16:25:32 +00:00
|
|
|
if unneed_update == f"{lang('apt_no_update')}:":
|
2020-08-11 12:47:34 +00:00
|
|
|
unneed_update = ''
|
2021-04-12 16:25:32 +00:00
|
|
|
if need_update == f"\n{lang('apt_updated')}:":
|
2020-08-11 12:47:34 +00:00
|
|
|
need_update = ''
|
|
|
|
if unneed_update == '' and need_update == '':
|
2021-04-12 16:25:32 +00:00
|
|
|
await context.edit(lang('apt_why_not_install_a_plugin'))
|
2020-08-11 12:47:34 +00:00
|
|
|
else:
|
2021-01-23 12:22:59 +00:00
|
|
|
if len(need_update_list) == 0:
|
2021-04-12 16:25:32 +00:00
|
|
|
await context.edit(lang('apt_loading_from_online_but_nothing_need_to_update'))
|
2021-01-23 12:22:59 +00:00
|
|
|
else:
|
|
|
|
print(6)
|
2021-04-12 16:25:32 +00:00
|
|
|
await context.edit(lang('apt_loading_from_online_and_updating'))
|
2021-01-23 12:22:59 +00:00
|
|
|
plugin_directory = f"{working_dir}/plugins/"
|
|
|
|
for i in need_update_list:
|
2021-06-14 10:24:23 +00:00
|
|
|
remove_plugin(i)
|
|
|
|
download(i)
|
2021-01-23 12:22:59 +00:00
|
|
|
with open(f"{plugin_directory}version.json", 'r', encoding="utf-8") as f:
|
|
|
|
version_json = json.load(f)
|
|
|
|
for m in plugin_online:
|
|
|
|
if m['name'] == i:
|
|
|
|
version_json[i] = m['version']
|
|
|
|
with open(f"{plugin_directory}version.json", 'w') as f:
|
|
|
|
json.dump(version_json, f)
|
2021-04-12 16:25:32 +00:00
|
|
|
await context.edit(lang('apt_reading_list') + need_update)
|
2021-02-07 10:55:35 +00:00
|
|
|
await context.client.disconnect()
|
2020-08-11 12:47:34 +00:00
|
|
|
elif context.parameter[0] == "search":
|
|
|
|
if len(context.parameter) == 1:
|
2021-04-12 16:25:32 +00:00
|
|
|
await context.edit(lang('apt_search_no_name'))
|
2020-08-11 12:47:34 +00:00
|
|
|
elif len(context.parameter) == 2:
|
|
|
|
search_result = []
|
|
|
|
plugin_name = context.parameter[1]
|
2021-06-14 10:24:23 +00:00
|
|
|
temp, plugin_list = get_html(
|
|
|
|
"https://raw.githubusercontent.com/Xtao-Labs/PagerMaid_Plugins/master/list.json")
|
|
|
|
plugin_online = json.loads(plugin_list)['list']
|
2020-08-11 12:47:34 +00:00
|
|
|
for i in plugin_online:
|
2020-08-11 14:30:54 +00:00
|
|
|
if search(plugin_name, i['name'], I):
|
2020-08-11 12:47:34 +00:00
|
|
|
search_result.extend(['`' + i['name'] + '` / `' + i['version'] + '`\n ' + i['des-short']])
|
|
|
|
if len(search_result) == 0:
|
2021-04-12 16:25:32 +00:00
|
|
|
await context.edit(lang('apt_search_not_found'))
|
2020-08-11 12:47:34 +00:00
|
|
|
else:
|
2021-04-12 16:25:32 +00:00
|
|
|
await context.edit(f"{lang('apt_search_result_hint')}:\n\n" + '\n\n'.join(search_result))
|
2020-08-11 12:47:34 +00:00
|
|
|
else:
|
2021-04-12 16:25:32 +00:00
|
|
|
await context.edit(lang('arg_error'))
|
2020-08-11 12:47:34 +00:00
|
|
|
elif context.parameter[0] == "show":
|
|
|
|
if len(context.parameter) == 1:
|
2021-04-12 16:25:32 +00:00
|
|
|
await context.edit(lang('apt_search_no_name'))
|
2020-08-11 12:47:34 +00:00
|
|
|
elif len(context.parameter) == 2:
|
|
|
|
search_result = ''
|
|
|
|
plugin_name = context.parameter[1]
|
2021-06-14 10:24:23 +00:00
|
|
|
temp, plugin_list = get_html(
|
|
|
|
"https://raw.githubusercontent.com/Xtao-Labs/PagerMaid_Plugins/master/list.json")
|
|
|
|
plugin_online = json.loads(plugin_list)['list']
|
2020-08-11 12:47:34 +00:00
|
|
|
for i in plugin_online:
|
|
|
|
if plugin_name == i['name']:
|
|
|
|
if i['supported']:
|
2021-04-12 16:25:32 +00:00
|
|
|
search_support = lang('apt_search_supporting')
|
2020-08-11 12:47:34 +00:00
|
|
|
else:
|
2021-04-12 16:25:32 +00:00
|
|
|
search_support = lang('apt_search_not_supporting')
|
2021-06-14 10:24:23 +00:00
|
|
|
search_result = f"{lang('apt_plugin_name')}:`{i['name']}`\n" \
|
|
|
|
f"{lang('apt_plugin_ver')}:`Ver {i['version']}`\n" \
|
|
|
|
f"{lang('apt_plugin_section')}:`{i['section']}`\n" \
|
|
|
|
f"{lang('apt_plugin_maintainer')}:`{i['maintainer']}`\n" \
|
|
|
|
f"{lang('apt_plugin_size')}:`{i['size']}`\n" \
|
|
|
|
f"{lang('apt_plugin_support')}:{search_support}\n" \
|
|
|
|
f"{lang('apt_plugin_des_short')}:{i['des-short']}\n\n" \
|
|
|
|
f"{i['des']}"
|
2020-08-11 12:47:34 +00:00
|
|
|
break
|
|
|
|
if search_result == '':
|
2021-04-12 16:25:32 +00:00
|
|
|
await context.edit(lang('apt_search_not_found'))
|
2020-08-11 12:47:34 +00:00
|
|
|
else:
|
|
|
|
await context.edit(search_result)
|
2020-02-19 15:31:39 +00:00
|
|
|
else:
|
2021-04-12 16:25:32 +00:00
|
|
|
await context.edit(lang('arg_error'))
|