-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
test-qqapi.py
45 lines (37 loc) · 1.21 KB
/
test-qqapi.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
import os
from avilla.core import Avilla, Context, MessageReceived
from avilla.core.elements import Text
from avilla.qqapi.element import Reference
from avilla.qqapi.protocol import QQAPIProtocol, QQAPIWebsocketConfig, Intents
config = QQAPIWebsocketConfig(
os.getenv("QQGUILD_ID"),
os.getenv("QQGUILD_TOKEN"),
os.getenv("QQGUILD_SECRET"),
is_sandbox=True,
intent=Intents(guild_messages=True, at_messages=False, direct_message=True),
)
avilla = Avilla(message_cache_size=0)
avilla.apply_protocols(QQAPIProtocol().configure(config))
@avilla.listen(MessageReceived)
async def on_message_received(cx: Context, event: MessageReceived):
# debug(cx.artifacts.maps)
print(cx.client.channel)
print(cx.client.user)
print(event.message.content)
print(
await cx.scene.send_message(
[
Text("Hello, Avilla!"),
# Embed(
# "Test Embed",
# "Hello, Avilla!",
# fields=["line1", "line2"],
# )
],
reply=event.message,
)
)
print(await cx.scene.privilege())
print(await cx.scene.nick())
print(await cx.self.privilege())
avilla.launch()