300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > python图灵机器人_python与图灵机器人交互(WXPY版本)

python图灵机器人_python与图灵机器人交互(WXPY版本)

时间:2020-02-12 23:47:35

相关推荐

python图灵机器人_python与图灵机器人交互(WXPY版本)

开发者账号:wujunfeng , 开发者key:官网申请

#!/usr/bin/env python

#-*- coding:utf-8 -*- @Author : wujf @Time:/9/4 15:21

from wxpy import *

# 扫码登陆

bot = Bot(cache_path=False)

# 初始化图灵机器人 (API key 申请: )

tuling = Tuling(api_key='3b802c35c40510414bb6d77b4f563661')

myfriend = bot.friends().search(u'邹唯')[0]

# 自动回复所有文字消息

# @bot.register(msg_types=TEXT)

# def auto_reply_all(msg):

# tuling.do_reply(msg)

#

#

# # 开始运行

# bot.join()

#回复指定好友

@bot.register(myfriend)

def auto_reply_all(msg):

tuling.do_reply(msg)

# 开始运行

bot.join()

缺点:机器人比较弱智。想要聪明的机器人可以看我其他关于机器人的介绍

#############################################给指定好友发送消息#####################################

或者

'''itchat'''

import itchat

itchat.auto_login(hotReload=True)

#friends_list = itchat.get_friends(update=True)

name = itchat.search_friends(name=u'王林')

Wanglin = name[0]["UserName"]

itchat.send('1',toUserName=Wanglin)

使用itchat也可以指定给某人发送消息。

'''wxpy'''

from wxpy import *

bot = Bot(cache_path=True)

my_frends = bot.friends().search(u'王林')[0]

my_frends.send('11') #给朋友发消息

bot.file_helper.send('Hello World!') #给文件助手发消息

bot.self.send('Hello World!') #给机器人自己发消息

print(my_frends)

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。