mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-09-03 22:52:25 +08:00
update
This commit is contained in:
parent
a5c7b6b0d6
commit
4f8d2d8c32
@ -84,7 +84,7 @@ class Weibo(NewMessage):
|
|||||||
if super_topic_img:
|
if super_topic_img:
|
||||||
try:
|
try:
|
||||||
res.append(
|
res.append(
|
||||||
super_topic_img.parent.parent.find("span", class_="surl-text").text
|
super_topic_img.parent.parent.find("span", class_="surl-text").text # type: ignore
|
||||||
+ "超话"
|
+ "超话"
|
||||||
)
|
)
|
||||||
except:
|
except:
|
||||||
|
@ -21,9 +21,7 @@ class Post:
|
|||||||
target_name: Optional[str] = None
|
target_name: Optional[str] = None
|
||||||
compress: bool = False
|
compress: bool = False
|
||||||
override_use_pic: Optional[bool] = None
|
override_use_pic: Optional[bool] = None
|
||||||
pics: Union[list[Union[str, bytes]], list[str], list[bytes]] = field(
|
pics: list[Union[str, bytes]] = field(default_factory=list)
|
||||||
default_factory=list
|
|
||||||
)
|
|
||||||
extra_msg: list[Message] = field(default_factory=list)
|
extra_msg: list[Message] = field(default_factory=list)
|
||||||
|
|
||||||
_message: Optional[list] = None
|
_message: Optional[list] = None
|
||||||
|
@ -14,7 +14,11 @@ from .utils import fake_admin_user, fake_group_message_event
|
|||||||
async def test_add_with_target(app: App):
|
async def test_add_with_target(app: App):
|
||||||
from nonebot.adapters.onebot.v11.message import Message
|
from nonebot.adapters.onebot.v11.message import Message
|
||||||
from nonebot_bison.config import Config
|
from nonebot_bison.config import Config
|
||||||
from nonebot_bison.config_manager import add_sub_matcher, common_platform
|
from nonebot_bison.config_manager import (
|
||||||
|
add_sub_matcher,
|
||||||
|
common_platform,
|
||||||
|
query_sub_matcher,
|
||||||
|
)
|
||||||
from nonebot_bison.platform import platform_manager
|
from nonebot_bison.platform import platform_manager
|
||||||
|
|
||||||
config = Config()
|
config = Config()
|
||||||
@ -122,6 +126,7 @@ async def test_add_with_target(app: App):
|
|||||||
)
|
)
|
||||||
ctx.receive_event(bot, event_6)
|
ctx.receive_event(bot, event_6)
|
||||||
ctx.should_call_send(event_6, ("添加 明日方舟Arknights 成功"), True)
|
ctx.should_call_send(event_6, ("添加 明日方舟Arknights 成功"), True)
|
||||||
|
ctx.should_finished()
|
||||||
subs = config.list_subscribe(10000, "group")
|
subs = config.list_subscribe(10000, "group")
|
||||||
assert len(subs) == 1
|
assert len(subs) == 1
|
||||||
sub = subs[0]
|
sub = subs[0]
|
||||||
@ -179,3 +184,73 @@ async def test_platform_name_err(app: App):
|
|||||||
"平台输入错误",
|
"平台输入错误",
|
||||||
True,
|
True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_query_sub(app: App):
|
||||||
|
from nonebot.adapters.onebot.v11.message import Message
|
||||||
|
from nonebot_bison.config import Config
|
||||||
|
from nonebot_bison.config_manager import query_sub_matcher
|
||||||
|
from nonebot_bison.platform import platform_manager
|
||||||
|
|
||||||
|
config = Config()
|
||||||
|
config.user_target.truncate()
|
||||||
|
config.add_subscribe(
|
||||||
|
10000,
|
||||||
|
"group",
|
||||||
|
"6279793937",
|
||||||
|
"明日方舟Arknights",
|
||||||
|
"weibo",
|
||||||
|
[platform_manager["weibo"].reverse_category["图文"]],
|
||||||
|
["明日方舟"],
|
||||||
|
)
|
||||||
|
async with app.test_matcher(query_sub_matcher) as ctx:
|
||||||
|
bot = ctx.create_bot()
|
||||||
|
event = fake_group_message_event(message=Message("查询订阅"), to_me=True)
|
||||||
|
ctx.receive_event(bot, event)
|
||||||
|
ctx.should_pass_rule()
|
||||||
|
ctx.should_pass_permission()
|
||||||
|
ctx.should_call_send(
|
||||||
|
event, Message("订阅的帐号为:\nweibo 明日方舟Arknights 6279793937 [图文] 明日方舟\n"), True
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_del_sub(app: App):
|
||||||
|
from nonebot.adapters.onebot.v11.message import Message
|
||||||
|
from nonebot_bison.config import Config
|
||||||
|
from nonebot_bison.config_manager import del_sub_matcher
|
||||||
|
from nonebot_bison.platform import platform_manager
|
||||||
|
|
||||||
|
config = Config()
|
||||||
|
config.user_target.truncate()
|
||||||
|
config.add_subscribe(
|
||||||
|
10000,
|
||||||
|
"group",
|
||||||
|
"6279793937",
|
||||||
|
"明日方舟Arknights",
|
||||||
|
"weibo",
|
||||||
|
[platform_manager["weibo"].reverse_category["图文"]],
|
||||||
|
["明日方舟"],
|
||||||
|
)
|
||||||
|
async with app.test_matcher(del_sub_matcher) as ctx:
|
||||||
|
bot = ctx.create_bot()
|
||||||
|
event = fake_group_message_event(
|
||||||
|
message=Message("删除订阅"), to_me=True, sender=fake_admin_user
|
||||||
|
)
|
||||||
|
ctx.receive_event(bot, event)
|
||||||
|
ctx.should_pass_rule()
|
||||||
|
ctx.should_pass_permission()
|
||||||
|
ctx.should_call_send(
|
||||||
|
event,
|
||||||
|
Message(
|
||||||
|
"订阅的帐号为:\n1 weibo 明日方舟Arknights 6279793937 [图文] 明日方舟\n请输入要删除的订阅的序号"
|
||||||
|
),
|
||||||
|
True,
|
||||||
|
)
|
||||||
|
event_1_err = fake_group_message_event(
|
||||||
|
message=Message("2"), sender=fake_admin_user
|
||||||
|
)
|
||||||
|
ctx.receive_event(bot, event_1_err)
|
||||||
|
ctx.should_call_send(event_1_err, "删除错误", True)
|
||||||
|
ctx.should_rejected()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user