mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-06 20:06:12 +08:00
auto fix by pre-commit hooks
This commit is contained in:
parent
0d84e1771f
commit
036ab31f85
@ -323,11 +323,12 @@ async def test_platform_name_err(app: App):
|
|||||||
True,
|
True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
@respx.mock
|
@respx.mock
|
||||||
async def test_add_with_get_id(app: App):
|
async def test_add_with_get_id(app: App):
|
||||||
from nonebot.adapters.onebot.v11.event import Sender
|
from nonebot.adapters.onebot.v11.event import Sender
|
||||||
from nonebot.adapters.onebot.v11.message import Message,MessageSegment
|
from nonebot.adapters.onebot.v11.message import Message, MessageSegment
|
||||||
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
|
||||||
from nonebot_bison.platform import platform_manager
|
from nonebot_bison.platform import platform_manager
|
||||||
@ -359,7 +360,11 @@ async def test_add_with_get_id(app: App):
|
|||||||
ctx.should_pass_rule()
|
ctx.should_pass_rule()
|
||||||
ctx.should_call_send(
|
ctx.should_call_send(
|
||||||
event_1,
|
event_1,
|
||||||
Message(BotReply.add_reply_on_platform(platform_manager=platform_manager,common_platform=common_platform)),
|
Message(
|
||||||
|
BotReply.add_reply_on_platform(
|
||||||
|
platform_manager=platform_manager, common_platform=common_platform
|
||||||
|
)
|
||||||
|
),
|
||||||
True,
|
True,
|
||||||
)
|
)
|
||||||
event_3 = fake_group_message_event(
|
event_3 = fake_group_message_event(
|
||||||
@ -379,15 +384,15 @@ async def test_add_with_get_id(app: App):
|
|||||||
ctx.should_call_send(
|
ctx.should_call_send(
|
||||||
event_4_query,
|
event_4_query,
|
||||||
[MessageSegment(*BotReply.add_reply_on_id_input_search())],
|
[MessageSegment(*BotReply.add_reply_on_id_input_search())],
|
||||||
True
|
True,
|
||||||
)
|
)
|
||||||
'''
|
"""
|
||||||
line 362:
|
line 362:
|
||||||
鬼知道为什么要在这里这样写,
|
鬼知道为什么要在这里这样写,
|
||||||
没有[]的话assert不了(should_call_send使用[MessageSegment(...)]的格式进行比较)
|
没有[]的话assert不了(should_call_send使用[MessageSegment(...)]的格式进行比较)
|
||||||
不在这里MessageSegment()的话也assert不了(指不能让add_reply_on_id_input_search直接返回一个MessageSegment对象)
|
不在这里MessageSegment()的话也assert不了(指不能让add_reply_on_id_input_search直接返回一个MessageSegment对象)
|
||||||
amen
|
amen
|
||||||
'''
|
"""
|
||||||
event_abort = fake_group_message_event(
|
event_abort = fake_group_message_event(
|
||||||
message=Message("取消"), sender=Sender(card="", nickname="test", role="admin")
|
message=Message("取消"), sender=Sender(card="", nickname="test", role="admin")
|
||||||
)
|
)
|
||||||
@ -397,4 +402,4 @@ async def test_add_with_get_id(app: App):
|
|||||||
BotReply.add_reply_abort,
|
BotReply.add_reply_abort,
|
||||||
True,
|
True,
|
||||||
)
|
)
|
||||||
ctx.should_finished()
|
ctx.should_finished()
|
||||||
|
@ -70,7 +70,9 @@ from nonebot.adapters.onebot.v11.event import Sender
|
|||||||
fake_admin_user = Sender(nickname="test", role="admin")
|
fake_admin_user = Sender(nickname="test", role="admin")
|
||||||
fake_superuser = Sender(user_id=10001, nickname="superuser")
|
fake_superuser = Sender(user_id=10001, nickname="superuser")
|
||||||
|
|
||||||
from nonebot.adapters.onebot.v11.message import Message,MessageSegment
|
from nonebot.adapters.onebot.v11.message import Message, MessageSegment
|
||||||
|
|
||||||
|
|
||||||
class BotReply:
|
class BotReply:
|
||||||
def add_reply_on_platform(platform_manager, common_platform):
|
def add_reply_on_platform(platform_manager, common_platform):
|
||||||
return (
|
return (
|
||||||
@ -95,29 +97,30 @@ class BotReply:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def add_reply_on_id_input_search():
|
def add_reply_on_id_input_search():
|
||||||
search_url="https://nonebot-bison.vercel.app/usage/#%E6%89%80%E6%94%AF%E6%8C%81%E5%B9%B3%E5%8F%B0%E7%9A%84-uid"
|
search_url = "https://nonebot-bison.vercel.app/usage/#%E6%89%80%E6%94%AF%E6%8C%81%E5%B9%B3%E5%8F%B0%E7%9A%84-uid"
|
||||||
search_title="Bison所支持的平台UID"
|
search_title = "Bison所支持的平台UID"
|
||||||
search_content="查询相关平台的uid格式或获取方式"
|
search_content = "查询相关平台的uid格式或获取方式"
|
||||||
search_image="https://s3.bmp.ovh/imgs/2022/03/ab3cc45d83bd3dd3.jpg"
|
search_image = "https://s3.bmp.ovh/imgs/2022/03/ab3cc45d83bd3dd3.jpg"
|
||||||
type='share'
|
type = "share"
|
||||||
data={
|
data = {
|
||||||
'url':search_url,
|
"url": search_url,
|
||||||
'title':search_title,
|
"title": search_title,
|
||||||
'content':search_content,
|
"content": search_content,
|
||||||
'image':search_image
|
"image": search_image,
|
||||||
}
|
}
|
||||||
msg=[type,data]
|
msg = [type, data]
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
def add_reply_on_target_confirm(platform,name,id):
|
|
||||||
return (f"即将订阅的用户为:{platform} {name} {id}\n如有错误请输入“取消”重新订阅")
|
|
||||||
|
|
||||||
def add_reply_on_cats(platform_manager,platform:str):
|
|
||||||
return ("请输入要订阅的类别,以空格分隔,支持的类别有:{}".format(
|
|
||||||
" ".join(list(platform_manager[platform].categories.values()))))
|
|
||||||
|
|
||||||
def add_reply_on_cats_input_error(cat:str):
|
def add_reply_on_target_confirm(platform, name, id):
|
||||||
return ("不支持 {}".format(cat))
|
return f"即将订阅的用户为:{platform} {name} {id}\n如有错误请输入“取消”重新订阅"
|
||||||
|
|
||||||
|
def add_reply_on_cats(platform_manager, platform: str):
|
||||||
|
return "请输入要订阅的类别,以空格分隔,支持的类别有:{}".format(
|
||||||
|
" ".join(list(platform_manager[platform].categories.values()))
|
||||||
|
)
|
||||||
|
|
||||||
|
def add_reply_on_cats_input_error(cat: str):
|
||||||
|
return "不支持 {}".format(cat)
|
||||||
|
|
||||||
def add_reply_subscribe_success(name):
|
def add_reply_subscribe_success(name):
|
||||||
return "添加 {} 成功".format(name)
|
return "添加 {} 成功".format(name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user