fix bug
This commit is contained in:
parent
4bf9045784
commit
2826b9411d
@ -396,7 +396,7 @@ class ChainBase(metaclass=ABCMeta):
|
|||||||
return self.run_module("scrape_metadata", path=path, mediainfo=mediainfo)
|
return self.run_module("scrape_metadata", path=path, mediainfo=mediainfo)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def register_commands(self, commands: dict) -> None:
|
def register_commands(self, commands: Dict[str, dict]) -> None:
|
||||||
"""
|
"""
|
||||||
注册菜单命令
|
注册菜单命令
|
||||||
"""
|
"""
|
||||||
|
@ -53,11 +53,13 @@ class Command(metaclass=Singleton):
|
|||||||
"/cookiecloud": {
|
"/cookiecloud": {
|
||||||
"func": CookieCloudChain(self._db).remote_sync,
|
"func": CookieCloudChain(self._db).remote_sync,
|
||||||
"description": "同步站点",
|
"description": "同步站点",
|
||||||
|
"category": "站点",
|
||||||
"data": {}
|
"data": {}
|
||||||
},
|
},
|
||||||
"/sites": {
|
"/sites": {
|
||||||
"func": SiteChain(self._db).remote_list,
|
"func": SiteChain(self._db).remote_list,
|
||||||
"description": "查询站点",
|
"description": "查询站点",
|
||||||
|
"category": "站点",
|
||||||
"data": {}
|
"data": {}
|
||||||
},
|
},
|
||||||
"/site_cookie": {
|
"/site_cookie": {
|
||||||
@ -78,21 +80,25 @@ class Command(metaclass=Singleton):
|
|||||||
"/mediaserver_sync": {
|
"/mediaserver_sync": {
|
||||||
"func": MediaServerChain(self._db).remote_sync,
|
"func": MediaServerChain(self._db).remote_sync,
|
||||||
"description": "同步媒体服务器",
|
"description": "同步媒体服务器",
|
||||||
|
"category": "管理",
|
||||||
"data": {}
|
"data": {}
|
||||||
},
|
},
|
||||||
"/subscribes": {
|
"/subscribes": {
|
||||||
"func": SubscribeChain(self._db).remote_list,
|
"func": SubscribeChain(self._db).remote_list,
|
||||||
"description": "查询订阅",
|
"description": "查询订阅",
|
||||||
|
"category": "订阅",
|
||||||
"data": {}
|
"data": {}
|
||||||
},
|
},
|
||||||
"/subscribe_refresh": {
|
"/subscribe_refresh": {
|
||||||
"func": SubscribeChain(self._db).remote_refresh,
|
"func": SubscribeChain(self._db).remote_refresh,
|
||||||
"description": "刷新订阅",
|
"description": "刷新订阅",
|
||||||
|
"category": "订阅",
|
||||||
"data": {}
|
"data": {}
|
||||||
},
|
},
|
||||||
"/subscribe_search": {
|
"/subscribe_search": {
|
||||||
"func": SubscribeChain(self._db).remote_search,
|
"func": SubscribeChain(self._db).remote_search,
|
||||||
"description": "搜索订阅",
|
"description": "搜索订阅",
|
||||||
|
"category": "订阅",
|
||||||
"data": {}
|
"data": {}
|
||||||
},
|
},
|
||||||
"/subscribe_delete": {
|
"/subscribe_delete": {
|
||||||
@ -103,11 +109,13 @@ class Command(metaclass=Singleton):
|
|||||||
"/downloading": {
|
"/downloading": {
|
||||||
"func": DownloadChain(self._db).remote_downloading,
|
"func": DownloadChain(self._db).remote_downloading,
|
||||||
"description": "正在下载",
|
"description": "正在下载",
|
||||||
|
"category": "下载",
|
||||||
"data": {}
|
"data": {}
|
||||||
},
|
},
|
||||||
"/transfer": {
|
"/transfer": {
|
||||||
"func": TransferChain(self._db).process,
|
"func": TransferChain(self._db).process,
|
||||||
"description": "下载文件整理",
|
"description": "下载文件整理",
|
||||||
|
"category": "下载",
|
||||||
"data": {}
|
"data": {}
|
||||||
},
|
},
|
||||||
"/redo": {
|
"/redo": {
|
||||||
@ -118,6 +126,7 @@ class Command(metaclass=Singleton):
|
|||||||
"/clear_cache": {
|
"/clear_cache": {
|
||||||
"func": SystemChain(self._db).remote_clear_cache,
|
"func": SystemChain(self._db).remote_clear_cache,
|
||||||
"description": "清理缓存",
|
"description": "清理缓存",
|
||||||
|
"category": "管理",
|
||||||
"data": {}
|
"data": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -128,6 +137,7 @@ class Command(metaclass=Singleton):
|
|||||||
cmd=command.get('cmd'),
|
cmd=command.get('cmd'),
|
||||||
func=Command.send_plugin_event,
|
func=Command.send_plugin_event,
|
||||||
desc=command.get('desc'),
|
desc=command.get('desc'),
|
||||||
|
category=command.get('category'),
|
||||||
data={
|
data={
|
||||||
'etype': command.get('event'),
|
'etype': command.get('event'),
|
||||||
'data': command.get('data')
|
'data': command.get('data')
|
||||||
@ -171,13 +181,15 @@ class Command(metaclass=Singleton):
|
|||||||
"""
|
"""
|
||||||
return self._commands
|
return self._commands
|
||||||
|
|
||||||
def register(self, cmd: str, func: Any, data: dict = None, desc: str = None) -> None:
|
def register(self, cmd: str, func: Any, data: dict = None,
|
||||||
|
desc: str = None, category: str = None) -> None:
|
||||||
"""
|
"""
|
||||||
注册命令
|
注册命令
|
||||||
"""
|
"""
|
||||||
self._commands[cmd] = {
|
self._commands[cmd] = {
|
||||||
"func": func,
|
"func": func,
|
||||||
"description": desc,
|
"description": desc,
|
||||||
|
"category": category,
|
||||||
"data": data or {}
|
"data": data or {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import json
|
import json
|
||||||
from typing import Optional, Union, List, Tuple, Any
|
from typing import Optional, Union, List, Tuple, Any, Dict
|
||||||
|
|
||||||
from app.core.context import MediaInfo, Context
|
from app.core.context import MediaInfo, Context
|
||||||
from app.core.config import settings
|
from app.core.config import settings
|
||||||
@ -120,7 +120,7 @@ class TelegramModule(_ModuleBase):
|
|||||||
"""
|
"""
|
||||||
return self.telegram.send_torrents_msg(title=message.title, torrents=torrents, userid=message.userid)
|
return self.telegram.send_torrents_msg(title=message.title, torrents=torrents, userid=message.userid)
|
||||||
|
|
||||||
def register_commands(self, commands: dict):
|
def register_commands(self, commands: Dict[str, dict]):
|
||||||
"""
|
"""
|
||||||
注册命令,实现这个函数接收系统可用的命令菜单
|
注册命令,实现这个函数接收系统可用的命令菜单
|
||||||
:param commands: 命令字典
|
:param commands: 命令字典
|
||||||
|
@ -2,7 +2,7 @@ import re
|
|||||||
import threading
|
import threading
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from threading import Event
|
from threading import Event
|
||||||
from typing import Optional, List
|
from typing import Optional, List, Dict
|
||||||
|
|
||||||
import telebot
|
import telebot
|
||||||
from telebot import apihelper
|
from telebot import apihelper
|
||||||
@ -198,7 +198,7 @@ class Telegram(metaclass=Singleton):
|
|||||||
|
|
||||||
return True if ret else False
|
return True if ret else False
|
||||||
|
|
||||||
def register_commands(self, commands: dict):
|
def register_commands(self, commands: Dict[str, dict]):
|
||||||
"""
|
"""
|
||||||
注册菜单命令
|
注册菜单命令
|
||||||
"""
|
"""
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import xml.dom.minidom
|
import xml.dom.minidom
|
||||||
from typing import Optional, Union, List, Tuple, Any
|
from typing import Optional, Union, List, Tuple, Any, Dict
|
||||||
|
|
||||||
from app.core.config import settings
|
from app.core.config import settings
|
||||||
from app.core.context import Context, MediaInfo
|
from app.core.context import Context, MediaInfo
|
||||||
@ -152,7 +152,7 @@ class WechatModule(_ModuleBase):
|
|||||||
"""
|
"""
|
||||||
return self.wechat.send_torrents_msg(title=message.title, torrents=torrents, userid=message.userid)
|
return self.wechat.send_torrents_msg(title=message.title, torrents=torrents, userid=message.userid)
|
||||||
|
|
||||||
def register_commands(self, commands: dict):
|
def register_commands(self, commands: Dict[str, dict]):
|
||||||
"""
|
"""
|
||||||
注册命令,实现这个函数接收系统可用的命令菜单
|
注册命令,实现这个函数接收系统可用的命令菜单
|
||||||
:param commands: 命令字典
|
:param commands: 命令字典
|
||||||
|
@ -2,7 +2,7 @@ import json
|
|||||||
import re
|
import re
|
||||||
import threading
|
import threading
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Optional, List
|
from typing import Optional, List, Dict
|
||||||
|
|
||||||
from app.core.config import settings
|
from app.core.config import settings
|
||||||
from app.core.context import MediaInfo, Context
|
from app.core.context import MediaInfo, Context
|
||||||
@ -273,7 +273,7 @@ class WeChat(metaclass=Singleton):
|
|||||||
logger.error(f"发送请求失败,错误信息:{err}")
|
logger.error(f"发送请求失败,错误信息:{err}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def create_menus(self, commands: dict):
|
def create_menus(self, commands: Dict[str, dict]):
|
||||||
"""
|
"""
|
||||||
自动注册微信菜单
|
自动注册微信菜单
|
||||||
:param commands: 命令字典
|
:param commands: 命令字典
|
||||||
@ -282,10 +282,11 @@ class WeChat(metaclass=Singleton):
|
|||||||
"/cookiecloud": {
|
"/cookiecloud": {
|
||||||
"func": CookieCloudChain(self._db).remote_sync,
|
"func": CookieCloudChain(self._db).remote_sync,
|
||||||
"description": "同步站点",
|
"description": "同步站点",
|
||||||
|
"category": "站点",
|
||||||
"data": {}
|
"data": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
注册报文格式:
|
注册报文格式,子菜单最多只有5条:
|
||||||
{
|
{
|
||||||
"button":[
|
"button":[
|
||||||
{
|
{
|
||||||
@ -313,24 +314,34 @@ class WeChat(metaclass=Singleton):
|
|||||||
"""
|
"""
|
||||||
# 请求URL
|
# 请求URL
|
||||||
req_url = self._create_menu_url % (self.__get_access_token(), self._appid)
|
req_url = self._create_menu_url % (self.__get_access_token(), self._appid)
|
||||||
# 按钮
|
|
||||||
buttons = []
|
# 对commands按category分组
|
||||||
|
category_dict = {}
|
||||||
for key, value in commands.items():
|
for key, value in commands.items():
|
||||||
buttons.append({
|
category: Dict[str, dict] = value.get("category")
|
||||||
|
if category:
|
||||||
|
if not category_dict.get(category):
|
||||||
|
category_dict[category] = {}
|
||||||
|
category_dict[category][key] = value
|
||||||
|
|
||||||
|
# 一级菜单
|
||||||
|
buttons = []
|
||||||
|
for category, menu in category_dict.items():
|
||||||
|
# 二级菜单
|
||||||
|
sub_buttons = []
|
||||||
|
for key, value in menu.items():
|
||||||
|
sub_buttons.append({
|
||||||
"type": "click",
|
"type": "click",
|
||||||
"name": value.get("description"),
|
"name": value.get("description"),
|
||||||
"key": key
|
"key": key
|
||||||
})
|
})
|
||||||
|
buttons.append({
|
||||||
|
"name": category,
|
||||||
|
"sub_button": sub_buttons
|
||||||
|
})
|
||||||
|
|
||||||
if buttons:
|
if buttons:
|
||||||
# 请求参数
|
|
||||||
menus = {
|
|
||||||
"button": [
|
|
||||||
{
|
|
||||||
"name": "操作",
|
|
||||||
"sub_button": buttons
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
# 发送请求
|
# 发送请求
|
||||||
self.__post_request(req_url, menus)
|
self.__post_request(req_url, {
|
||||||
|
"button": buttons
|
||||||
|
})
|
||||||
|
@ -65,7 +65,8 @@ class _PluginBase(metaclass=ABCMeta):
|
|||||||
[{
|
[{
|
||||||
"cmd": "/xx",
|
"cmd": "/xx",
|
||||||
"event": EventType.xx,
|
"event": EventType.xx,
|
||||||
"desc": "xxxx",
|
"desc": "名称",
|
||||||
|
"category": "分类,需要注册到Wechat时必须有分类",
|
||||||
"data": {}
|
"data": {}
|
||||||
}]
|
}]
|
||||||
"""
|
"""
|
||||||
|
@ -212,6 +212,7 @@ class AutoSignIn(_PluginBase):
|
|||||||
"cmd": "/site_signin",
|
"cmd": "/site_signin",
|
||||||
"event": EventType.SiteSignin,
|
"event": EventType.SiteSignin,
|
||||||
"desc": "站点签到",
|
"desc": "站点签到",
|
||||||
|
"category": "站点",
|
||||||
"data": {}
|
"data": {}
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
@ -133,6 +133,7 @@ class DoubanSync(_PluginBase):
|
|||||||
"cmd": "/douban_sync",
|
"cmd": "/douban_sync",
|
||||||
"event": EventType.DoubanSync,
|
"event": EventType.DoubanSync,
|
||||||
"desc": "同步豆瓣想看",
|
"desc": "同步豆瓣想看",
|
||||||
|
"category": "订阅",
|
||||||
"data": {}
|
"data": {}
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
@ -110,6 +110,7 @@ class MediaSyncDel(_PluginBase):
|
|||||||
"cmd": "/sync_del",
|
"cmd": "/sync_del",
|
||||||
"event": EventType.HistoryDeleted,
|
"event": EventType.HistoryDeleted,
|
||||||
"desc": "媒体库同步删除",
|
"desc": "媒体库同步删除",
|
||||||
|
"category": "管理",
|
||||||
"data": {}
|
"data": {}
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
@ -150,6 +150,7 @@ class SiteStatistic(_PluginBase):
|
|||||||
"cmd": "/site_statistic",
|
"cmd": "/site_statistic",
|
||||||
"event": EventType.SiteStatistic,
|
"event": EventType.SiteStatistic,
|
||||||
"desc": "站点数据统计",
|
"desc": "站点数据统计",
|
||||||
|
"category": "站点",
|
||||||
"data": {}
|
"data": {}
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user