-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
test-console.py
56 lines (44 loc) · 1.32 KB
/
test-console.py
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
from avilla.core import Avilla, Context, MessageReceived
from avilla.console.protocol import ConsoleProtocol
from avilla.console.element import Markdown
from avilla.core.elements import Face
avilla = Avilla()
avilla.apply_protocols(ConsoleProtocol())
@avilla.listen(MessageReceived)
async def on_message_received(ctx: Context, event: MessageReceived):
msg = str(event.message.content)
if msg == "/help":
await ctx.scene.send_message(
[Markdown("""\
## 菜单
- /help
- /echo
- /md
- /emoji
"""
)])
elif msg == "/md":
await ctx.scene.send_message(
[Markdown("""\
# Avilla-Console
`avilla` 的 `Console` 适配,使用 `Textual`
参考: [`nonebot-adapter-console`](https://github.com/nonebot/adapter-console)
## 样例
```python
from avilla.core import Avilla, Context, MessageReceived
from avilla.console.protocol import ConsoleProtocol
avilla = Avilla()
avilla.apply_protocols(ConsoleProtocol())
@broadcast.receiver(MessageReceived)
async def on_message_received(ctx: Context):
await ctx.scene.send_message("Hello, Avilla!")
avilla.launch()
```
"""
)]
)
elif msg == "/emoji":
await ctx.scene.send_message([Face("art"), " | this is apple -> ", Face("apple")])
else:
await ctx.scene.send_message("Hello, Avilla!")
avilla.launch()