開發者賬號:wujunfeng , 開發者key:官網申請
#!/usr/bin/env python
#-*- coding:utf-8 -*- @Author : wujf @Time:2018/9/4 15:21
from wxpy import *
# 掃碼登陸
bot = Bot(cache_path=False)
# 初始化圖靈機器人 (API key 申請: http://tuling123.com)
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)