131 lines
5.0 KiB
Python
131 lines
5.0 KiB
Python
from fastapi import FastAPI
|
||
from pydantic import BaseModel
|
||
import requests
|
||
import json
|
||
|
||
|
||
class Item(BaseModel):
|
||
event: str
|
||
EventGroupMsg: None = None
|
||
prirobot_wxidce: None = None
|
||
type: None = None
|
||
|
||
|
||
# event
|
||
# "":"EventGroupMsg",//事件标示(当前值为群消息事件)
|
||
# "robot_wxid":"wxid_5hxa04j4z6pg22",//机器人wxid
|
||
# "robot_name":"",//机器人昵称,一般为空
|
||
# "type":1,//1/文本消息 3/图片消息 34/语音消息 42/名片消息 43/视频 47/动态表情 48/地理位置 49/分享链接 2000/转账 2001/红包 2002/小程序 2003/群邀请
|
||
# "from_wxid":"18900134932@chatroom",//群id,群消息事件才有
|
||
# "from_name":"微群测",//群名字
|
||
# "final_from_wxid":"sundreamer",//发该消息的用户微信id
|
||
# "final_from_name":"遗忘悠剑o",//微信昵称
|
||
# "to_wxid":"wxid_5hxa04j4z6pg22",//接收消息的人id,(一般是机器人收到了,也有可能是机器人发出的消息,别人收到了,那就是别人)
|
||
# "msg":"图片https://b3logfile.com/bing/20201024.jpg",//消息内容(string/array) 使用时候根据不同的事件标示来定义这个值,字符串类型或者数据类型
|
||
# "money":0.01 //金额,只有"EventReceivedTransfer"事件才有该参数
|
||
|
||
app = FastAPI()
|
||
|
||
|
||
@app.get("/")
|
||
async def root():
|
||
|
||
payload2 = {
|
||
'event': 'SendTextMsg',
|
||
'robot_wxid': 'wxid_haqoszjheyuz22',
|
||
'robot_name': '',
|
||
'type': 1,
|
||
'from_wxid': 'wxid_haqoszjheyuz22',
|
||
'from_name': '',
|
||
'final_from_wxid': 'wxid_haqoszjheyuz22',
|
||
'final_from_name': '',
|
||
'to_wxid': 'wxid_4413224132412',
|
||
'msgid': '1284190763721151116',
|
||
'msg': '1111111'
|
||
}
|
||
|
||
# 网址返回wxid以及时间戳
|
||
mag = {
|
||
"title:":
|
||
'标题',
|
||
"text":
|
||
'活动小助手',
|
||
"target_url":
|
||
'https://hackrobot.cn',
|
||
"pic_url":
|
||
"https://aiimg.hackrobot.cn/1698288150.2901459.png",
|
||
"icon_url":
|
||
"https://www.hackrobot.cn/wp-content/uploads/2023/05/cropped-Screenshot-2023-05-22-at-17.26.38-32x32.png"
|
||
}
|
||
link = {
|
||
'event': 'SendLinkMsg',
|
||
'robot_wxid': 'wxid_haqoszjheyuz22',
|
||
'robot_name': '',
|
||
'from_wxid': 'wxid_haqoszjheyuz22',
|
||
'from_name': '',
|
||
'final_from_wxid': 'wxid_haqoszjheyuz22',
|
||
'final_from_name': '',
|
||
'to_wxid': 'wxid_4413224132412',
|
||
'msg': mag
|
||
}
|
||
# r = requests.post("http://192.168.31.25:8090", data=payload)
|
||
# r = requests.post("http://192.168.31.25:8090", json=payload)
|
||
|
||
# 获取好友列表
|
||
getinfo = {'event': 'GetFriendList', 'robot_wxid': 'wxid_haqoszjheyuz22'}
|
||
xmllink = {
|
||
'event':
|
||
'SendTextMsg',
|
||
'robot_wxid':
|
||
'wxid_haqoszjheyuz22',
|
||
'robot_name':
|
||
'',
|
||
'type':
|
||
49,
|
||
'from_wxid':
|
||
'wxid_haqoszjheyuz22',
|
||
'from_name':
|
||
'',
|
||
'final_from_wxid':
|
||
'wxid_haqoszjheyuz22',
|
||
'final_from_name':
|
||
'',
|
||
'to_wxid':
|
||
'wxid_4413224132412',
|
||
'msgid':
|
||
'894964783959555477',
|
||
'msg':
|
||
'''<msg>\r\n <fromusername>wxid_haqoszjheyuz22</fromusername>\r\n <scene>0</scene>\r\n <commenturl></commenturl>\r\n <appmsg appid="" sdkver="0">\r\n <title></title>\r\n <des>活动小助手</des>\r\n <action>view</action>\r\n <type>5</type>\r\n <showtype
|
||
>0</showtype>\r\n <content></content>\r\n <url>https://hackrobot.cn</url>\r\n <dataurl></dataurl>\r\n <lowurl></lowurl>\r\n <lowdataurl></lowdataurl>\r\n <recorditem>\r\n <![CDATA[]]>\r\n </recorditem>\r\n <thumburl>https://aiimg.hackrobot.cn/1698288150.2901459.png</thumburl>\r\n
|
||
<messageaction></messageaction>\r\n <extinfo></extinfo>\r\n <sourceusername></sourceusername>\r\n
|
||
<sourcedisplayname></sourcedisplayname>\r\n <commenturl></commenturl>\r\n <appattach>\r\n
|
||
<totallen>0</totallen>\r\n <attachid></attachid>\r\n <emoticonmd5></emoticonmd5>\r\n
|
||
<fileext></fileext>\r\n <aeskey></aeskey>\r\n </appattach>\r\n <weappinfo>\r\n
|
||
<pagepath></pagepath>\r\n <username></username>\r\n <appid></appid>\r\n <appservicetype>0</appservicetype>\r\n </weappinfo>\r\n <websearch />\r\n </appmsg>\r\n <appinfo>\r\n
|
||
<version>1</version>\r\n <appname>Window wechat</appname>\r\n </appinfo>\r\n</msg>\r\n'''
|
||
}
|
||
|
||
file = {
|
||
'event': 'SendFileMsg',
|
||
'robot_wxid': 'wxid_haqoszjheyuz22',
|
||
'to_wxid': 'wxid_4413224132412',
|
||
'msg': 'C:\\Users\\Administrator\\Documents\\Applet\\static\\.mp3'
|
||
}
|
||
|
||
r = requests.post("http://192.168.31.42:8090", data=json.dumps(link))
|
||
|
||
print('item')
|
||
return "item"
|
||
|
||
|
||
@app.post("/")
|
||
async def create_item(item: dict):
|
||
print('item', item)
|
||
return "item1"
|
||
|
||
|
||
@app.post("/friend")
|
||
async def friend(item: dict):
|
||
print('friend', item)
|
||
return "item1"
|