-
Notifications
You must be signed in to change notification settings - Fork 0
/
message.py
62 lines (51 loc) · 1.57 KB
/
message.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
57
58
59
60
61
62
from botpy.types.message import Reference
import os
class Event:
channel_id = None
client = None
user_id = None
message_id = None
message = None
async def msg(
content: str = None,
channel_id=Event.channel_id,
embed=None,
ark=None,
message_reference=None,
image: str = None,
file_image=None,
msg_id: str = None,
event_id: str = None,
markdown=None,
keyboard=None):
# print(channel_id) # None why?????
await Event.client.api.post_message(
channel_id=channel_id,
content=content,
embed=embed,
ark=ark,
message_reference=message_reference if embed or ark or image or file_image or markdown or keyboard == None else None,
image=image,
file_image=file_image,
msg_id=msg_id,
event_id=event_id,
markdown=markdown,
keyboard=keyboard
)
async def send(content: str):
await msg(content=content, channel_id=Event.channel_id)
class MessageSegment:
async def reply(content: str):
await msg(content=content, channel_id=Event.channel_id,
message_reference=Reference(message_id=Event.message_id, ignore_get_message_error=True))
async def at(content: str, reply: bool = None, pic: str = None):
'''
reply: 可默认不写,默认为不引用
pic: 图片路径,如果有图片将无法使用reply
'''
await msg(
content=f'<@{Event.user_id}> {content}',
channel_id=Event.channel_id,
message_reference=Reference(message_id=Event.message_id) if reply and pic is None else None,
file_image=pic if pic is not None and os.path.isfile(pic) else None
)