Skip to content

Commit a5a0290

Browse files
committed
change tencentaiplat dic
1 parent 00a24f1 commit a5a0290

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

examples/professional/tencentaiplat/tencentai_bot.py

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,56 +24,51 @@ async def message(msg: Message):
2424
from_contact = msg.talker()
2525
text = msg.text()
2626
room = msg.room()
27-
conversationer: Union[
27+
conversation: Union[
2828
Room, Contact] = from_contact if room is None else room
2929

3030
global chat_friend
3131

3232
if "#关闭闲聊" == text:
3333
try:
34-
chat_friend.remove(conversationer)
34+
chat_friend.remove(conversation)
3535
except Exception as e:
3636
return
37-
await conversationer.ready()
38-
await conversationer.say('好的,有需要随时叫我')
37+
await conversation.ready()
38+
await conversation.say('好的,有需要随时叫我')
3939
return
4040

4141
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('闲聊功能开启成功!现在你可以和我聊天啦!')
4545
return
4646

47-
if conversationer in chat_friend:
47+
if conversation in chat_friend:
4848
data = TencentAI(text)
49-
await conversationer.ready()
50-
await conversationer.say(data)
49+
await conversation.ready()
50+
await conversation.say(data)
5151
return
5252

5353
if text == '#ding':
54-
await conversationer.ready()
55-
await conversationer.say('dong')
54+
await conversation.ready()
55+
await conversation.say('dong')
5656

5757
file_box = FileBox.from_url(
5858
'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/'
5959
'u=1116676390,2305043183&fm=26&gp=0.jpg',
6060
name='ding-dong.jpg')
61-
await conversationer.say(file_box)
61+
await conversation.say(file_box)
6262

6363

6464
bot: Optional[Wechaty] = None
6565

6666

6767
async def main():
6868
"""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))
7469
# pylint: disable=W0603
7570
global bot
76-
bot = Wechaty(hostie_puppet).on('message', message)
71+
bot = Wechaty().on('message', message)
7772
await bot.start()
7873

7974

0 commit comments

Comments
 (0)