开发者账号: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)