forked from SAGIRI-kawaii/saya_plugins_collection
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MessagePrinter.py
44 lines (33 loc) · 1.29 KB
/
MessagePrinter.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
from graia.saya import Saya, Channel
from graia.saya.builtins.broadcast.schema import ListenerSchema
from graia.application.event.messages import *
from graia.application.event.mirai import *
# 插件信息
__name__ = "MessagePrinter"
__description__ = "打印收到的消息"
__author__ = "SAGIRI-kawaii"
__usage__ = "发送消息即可触发"
saya = Saya.current()
channel = Channel.current()
channel.name(__name__)
channel.description(f"{__description__}\n使用方法:{__usage__}")
channel.author(__author__)
@channel.use(ListenerSchema(listening_events=[GroupMessage]))
async def group_message_listener(
message: MessageChain,
sender: Member,
group: Group
):
print(f"接收到来自群组 <{group.name} ({group.id})> 中成员 <{sender.name} ({sender.id})> 的消息:{message.asDisplay()}")
@channel.use(ListenerSchema(listening_events=[FriendMessage]))
async def friend_message_listener(
message: MessageChain,
sender: Friend
):
print(f"接收到来自好友 <{sender.nickname} ({sender.id})> 的消息:{message.asDisplay()}")
@channel.use(ListenerSchema(listening_events=[TempMessage]))
async def temp_message_listener(
message: MessageChain,
sender: Member
):
print(f"接收到来自 <{sender.name} ({sender.id})> 的临时消息:{message.asDisplay()}")