@@ -24,56 +24,51 @@ async def message(msg: Message):
24
24
from_contact = msg .talker ()
25
25
text = msg .text ()
26
26
room = msg .room ()
27
- conversationer : Union [
27
+ conversation : Union [
28
28
Room , Contact ] = from_contact if room is None else room
29
29
30
30
global chat_friend
31
31
32
32
if "#关闭闲聊" == text :
33
33
try :
34
- chat_friend .remove (conversationer )
34
+ chat_friend .remove (conversation )
35
35
except Exception as e :
36
36
return
37
- await conversationer .ready ()
38
- await conversationer .say ('好的,有需要随时叫我' )
37
+ await conversation .ready ()
38
+ await conversation .say ('好的,有需要随时叫我' )
39
39
return
40
40
41
41
elif "#开启闲聊" == text :
42
- chat_friend .append (conversationer )
43
- await conversationer .ready ()
44
- await conversationer .say ('闲聊功能开启成功!现在你可以和我聊天啦!' )
42
+ chat_friend .append (conversation )
43
+ await conversation .ready ()
44
+ await conversation .say ('闲聊功能开启成功!现在你可以和我聊天啦!' )
45
45
return
46
46
47
- if conversationer in chat_friend :
47
+ if conversation in chat_friend :
48
48
data = TencentAI (text )
49
- await conversationer .ready ()
50
- await conversationer .say (data )
49
+ await conversation .ready ()
50
+ await conversation .say (data )
51
51
return
52
52
53
53
if text == '#ding' :
54
- await conversationer .ready ()
55
- await conversationer .say ('dong' )
54
+ await conversation .ready ()
55
+ await conversation .say ('dong' )
56
56
57
57
file_box = FileBox .from_url (
58
58
'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/'
59
59
'u=1116676390,2305043183&fm=26&gp=0.jpg' ,
60
60
name = 'ding-dong.jpg' )
61
- await conversationer .say (file_box )
61
+ await conversation .say (file_box )
62
62
63
63
64
64
bot : Optional [Wechaty ] = None
65
65
66
66
67
67
async def main ():
68
68
"""doc"""
69
- # you can replace it with your own token str
70
- token = open ('token.txt' ).readlines ()[0 ]
71
- token = token .replace ('\n ' , '' )
72
-
73
- hostie_puppet = HostiePuppet (PuppetOptions (token ))
74
69
# pylint: disable=W0603
75
70
global bot
76
- bot = Wechaty (hostie_puppet ).on ('message' , message )
71
+ bot = Wechaty ().on ('message' , message )
77
72
await bot .start ()
78
73
79
74
0 commit comments