# #-*-coding:utf-8-*-
# from wxpy import *
# bot = Bot(cache_path=True)
# print(bot.groups())
# company_group = bot.groups().search('aaa')[0]
# boss = company_group.search('a_飘逝')[0]
# # bot.file_helper.send("hello")
#
# friends_stat = bot.friends().stats()
#
# friend_loc = [] # 每一个元素是一个二元列表,分别存储地区和人数信息
# print(friends_stat["province"].elements())
# for province, count in friends_stat["province"].most_common():
# if province != "":
# friend_loc.append([province, count])
#
# friend_loc.sort(key=lambda x: x[1], reverse=True)
#
# for item in friend_loc[:10]:
# print (item[0], item[1])
#
# for sex, count in friends_stat["sex"].most_common():
# # 1代表MALE, 2代表FEMALE
# if sex == 1:
# print ("MALE %d" % count)
# elif sex == 2:
# print ("FEMALE %d" % count)
#
# @bot.register(company_group)
# def print_message(msg):
# print(0)
#
# if msg.member==boss:
#
# # return msg.text
# print(1)
# return msg.forward(bot.file_helper, prefix='老板发言')
# # print(0)
#
#
# embed()
# -*- coding: utf-8 -*-
import json
import requests
from wxpy import *
# 调用图灵机器人API,发送消息并获得机器人的回复
def auto_reply(text):
url = "http://www.tuling123.com/openapi/api"
api_key = "45f74b3e399e484990bd9c7716e1d4f6"
payload = {
"key": api_key,
"info": text,
"userid": "123456"
}
print(0)
r = requests.post(url, data=json.dumps(payload))
result = json.loads(r.content)
print(result["text"])
return result["text"]
bot = Bot(console_qr=True, cache_path=True)
@bot.register()
def forward_message(msg):
if msg.member == 'a_飘逝':
return auto_reply(msg.text)
embed()