@@ -32,33 +32,40 @@ async def on_message(self, msg: Message):
32
32
# send contact-card
33
33
print (msg )
34
34
if msg .type () == MessageType .MESSAGE_TYPE_CONTACT :
35
+ # we can receive the contact-card event, and get the contact from message
35
36
contact = await msg .to_contact ()
36
- room = self .Room .load ('19961884194@chatroom' )
37
+
38
+ # you can send all file to the specific room when you are at testing stage
39
+ room = self .Room .load ('room-id' )
37
40
await room .ready ()
38
41
39
42
if text == 'send card' :
40
- # find one of my friend
43
+ # find one of my friend to send to `from_contact`
41
44
contacts = await bot .Contact .find_all ()
42
45
if contacts :
43
46
# send one of my friend to the talker
47
+ # !! this interface is not supported now
44
48
await from_contact .say (contacts [0 ])
45
49
print ('have sended' )
46
50
elif msg .type () == MessageType .MESSAGE_TYPE_IMAGE :
47
51
img = await msg .to_file_box ()
52
+ # save the image as local file
48
53
await img .to_file (f'./{ img .name } ' )
49
-
54
+ # send image file to the specific room
50
55
await room .say (img )
51
56
52
57
elif msg .type () == MessageType .MESSAGE_TYPE_VIDEO :
53
58
video = await msg .to_file_box ()
59
+ # save the video as local file
54
60
await video .to_file (f'./{ video .name } ' )
55
-
61
+ # send video file to the specific room
56
62
await room .say (video )
57
63
58
64
elif msg .type () == MessageType .MESSAGE_TYPE_AUDIO :
59
65
audio = await msg .to_file_box ()
60
66
# save the audio file as local file
61
67
await audio .to_file (f'./{ audio .name } ' )
68
+ # !! we can't send audio to room/contact
62
69
63
70
print ('done' )
64
71
0 commit comments