1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
import pytest
from nonebug import App
from .utils import make_fake_message, make_fake_event
@pytest.mark.asyncio
async def test_main_help(app: App):
from ATRI.plugins.help import main_help
Message = make_fake_message()
async with app.test_matcher(main_help) as ctx:
bot = ctx.create_bot()
msg = Message("菜单")
event = make_fake_event(_message=msg, _to_me=True)()
ctx.receive_event(bot, event)
ctx.should_call_send(
event,
"""
哦呀?~需要帮助?
关于 -查看bot基本信息
服务列表 -以查看所有可用服务
帮助 [服务] -以查看对应服务帮助
Tip: 均需要at触发。@bot 菜单 以打开此页面
""",
True,
)
@pytest.mark.asyncio
async def test_about_me(app: App):
from ATRI import __version__
from ATRI.config import BotSelfConfig
from ATRI.plugins.help import about_me
temp_list = list()
for i in BotSelfConfig.nickname:
temp_list.append(i)
nickname = "、".join(map(str, temp_list))
Message = make_fake_message()
async with app.test_matcher(about_me) as ctx:
bot = ctx.create_bot()
msg = Message("关于")
event = make_fake_event(_message=msg, _to_me=True)()
ctx.receive_event(bot, event)
ctx.should_call_send(
event,
f"""
唔...是来认识咱的么
可以称呼咱:{nickname}
咱的型号是:{__version__}
想进一步了解:
https://github.com/Kyomotoi/ATRI
""",
True,
)
@pytest.mark.asyncio
async def test_service_list(app: App):
import os
from ATRI.service import SERVICES_DIR
from ATRI.plugins.help import service_list
files = os.listdir(SERVICES_DIR)
temp_list = list()
for i in files:
service = i.replace(".json", "")
temp_list.append(service)
services = "、".join(map(str, temp_list))
Message = make_fake_message()
async with app.test_matcher(service_list) as ctx:
bot = ctx.create_bot()
msg = Message("服务列表")
event = make_fake_event(_message=msg, _to_me=True)()
ctx.receive_event(bot, event)
ctx.should_call_send(
event,
f"""
咱搭载了以下服务~
{services}
@bot 帮助 [服务] -以查看对应服务帮助
""",
True,
)
@pytest.mark.asyncio
async def test_service_info(app: App):
from ATRI.plugins.help import service_info
Message = make_fake_message()
async with app.test_matcher(service_info) as ctx:
bot = ctx.create_bot()
msg = Message("帮助")
event = make_fake_event(_message=msg, _to_me=True)()
ctx.receive_event(bot, event)
ctx.should_call_send(event, "请检查是否输入错误...", True)
async with app.test_matcher(service_info) as ctx:
bot = ctx.create_bot()
msg = Message("帮助 状态")
event = make_fake_event(_message=msg, _to_me=True)()
ctx.receive_event(bot, event)
ctx.should_call_send(
event,
"""
服务名:状态
说明:
检查咱自身状态
可用命令:
/ping、/status
是否全局启用:True
Tip: 帮助 [服务] [命令] 以查看对应命令详细信息
""",
True,
)
async with app.test_matcher(service_info) as ctx:
bot = ctx.create_bot()
msg = Message("帮助 状态 /ping")
event = make_fake_event(_message=msg, _to_me=True)()
ctx.receive_event(bot, event)
ctx.should_call_send(
event,
"""
命令:/ping
类型:command
说明:检测bot简单信息处理速度
更多触发方式:[]
""",
True,
)
|