mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-04 02:26:11 +08:00
* 🐛 查询订阅时提示不存在的平台 fix #515 * 💄 auto fix by pre-commit hooks * 🐛 删除订阅时,获取详细信息跳过不存在的platform * ✅ 添加对于不存在的平台的单元测试 * 🐛 删除订阅时跳过不存在的platform * 💄 规范化订阅列表的输出 * 💄 规范化订阅列表的输出 * 💄 规范化订阅列表的输出 * 💄 规范化订阅列表的输出 --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
32 lines
1.3 KiB
Python
32 lines
1.3 KiB
Python
from nonebot.params import Arg
|
|
from nonebot.matcher import Matcher
|
|
from nonebot_plugin_saa import MessageFactory, PlatformTarget
|
|
|
|
from ..config import config
|
|
from ..types import Category
|
|
from ..utils import parse_text
|
|
from .utils import ensure_user_info
|
|
from ..platform import platform_manager
|
|
|
|
|
|
def do_query_sub(query_sub: type[Matcher]):
|
|
query_sub.handle()(ensure_user_info(query_sub))
|
|
|
|
@query_sub.handle()
|
|
async def _(user_info: PlatformTarget = Arg("target_user_info")):
|
|
sub_list = await config.list_subscribe(user_info)
|
|
res = "订阅的帐号为:\n"
|
|
for sub in sub_list:
|
|
res += f"{sub.target.platform_name} {sub.target.target_name} {sub.target.target}\n"
|
|
if platform := platform_manager.get(sub.target.platform_name):
|
|
if platform.categories:
|
|
res += " [{}]".format(", ".join(platform.categories[Category(x)] for x in sub.categories))
|
|
if platform.enable_tag:
|
|
res += " {}".format(", ".join(sub.tags))
|
|
else:
|
|
res += f" (平台 {sub.target.platform_name} 已失效,请删除此订阅)"
|
|
if res[-1] != "\n":
|
|
res += "\n"
|
|
await MessageFactory(await parse_text(res)).send()
|
|
await query_sub.finish()
|