Compare commits
163 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
779c619400 | ||
|
|
f8ed1763d3 | ||
|
|
8fc462254f | ||
|
|
5586e25ce6 | ||
|
|
71f949917e | ||
|
|
c18e4b0917 | ||
|
|
f184e92d31 | ||
|
|
8a1c4bbf1a | ||
|
|
1e15e5b980 | ||
|
|
c375dbf356 | ||
|
|
55681445f4 | ||
|
|
d1f5e33233 | ||
|
|
a3b48cd045 | ||
|
|
c7fd05fa91 | ||
|
|
9371fdd8a2 | ||
|
|
4c531f150c | ||
|
|
da45c2017d | ||
|
|
df985db399 | ||
|
|
19326e4e78 | ||
|
|
ad99b0d016 | ||
|
|
68f5fbc10a | ||
|
|
57b2281581 | ||
|
|
f00849f497 | ||
|
|
b095d009d2 | ||
|
|
062b8b1731 | ||
|
|
54d16a1702 | ||
|
|
1e99cc7ca1 | ||
|
|
b51f8c5439 | ||
|
|
73db19edcf | ||
|
|
d4c51c909e | ||
|
|
2e4dfffdab | ||
|
|
1de456530e | ||
|
|
1dd0d143e6 | ||
|
|
b00ac14818 | ||
|
|
8c96aefca0 | ||
|
|
170f1d6dc5 | ||
|
|
bfa67f9b12 | ||
|
|
e27dd46778 | ||
|
|
f3d623e8be | ||
|
|
325378d16e | ||
|
|
02196c74f6 | ||
|
|
4764474e4a | ||
|
|
b3169eb8b7 | ||
|
|
05fd7d676b | ||
|
|
e4db7eecdb | ||
|
|
9f33571832 | ||
|
|
62df800054 | ||
|
|
f402cbad50 | ||
|
|
d5885e91c7 | ||
|
|
85cc4fbab1 | ||
|
|
6b38b93863 | ||
|
|
980825292f | ||
|
|
225b3175c8 | ||
|
|
b2f6ead459 | ||
|
|
2a45fcbad5 | ||
|
|
9a3a1bac18 | ||
|
|
3ba96e0a4e | ||
|
|
3d0e67eaeb | ||
|
|
56e5a883e5 | ||
|
|
5a8db37be3 | ||
|
|
3d293b7f57 | ||
|
|
ce0efaae72 | ||
|
|
aad20bc2b0 | ||
|
|
09fab5beca | ||
|
|
8179f16e57 | ||
|
|
2ca139d4c7 | ||
|
|
80546a75e5 | ||
|
|
298afa7142 | ||
|
|
7bade2d633 | ||
|
|
f10ada4e79 | ||
|
|
89289a6ddb | ||
|
|
ab2c9cb78a | ||
|
|
36f64e8c77 | ||
|
|
b296b2f871 | ||
|
|
0a28cb46ee | ||
|
|
5f15f6fb26 | ||
|
|
fbfde8f44e | ||
|
|
a6308c77c1 | ||
|
|
c9c51e4580 | ||
|
|
3a27564ed2 | ||
|
|
e385a05456 | ||
|
|
7c37d92bdb | ||
|
|
47c4788b55 | ||
|
|
8c3aac2e75 | ||
|
|
c9dab725a8 | ||
|
|
4b966844bd | ||
|
|
18c9f9d54c | ||
|
|
2849922338 | ||
|
|
3c77b48106 | ||
|
|
e3b996e3e2 | ||
|
|
67c3119b80 | ||
|
|
72d04e7fb0 | ||
|
|
1e90c52553 | ||
|
|
c7d105591f | ||
|
|
fd22b872f2 | ||
|
|
6342c50285 | ||
|
|
c664d276cf | ||
|
|
121fcc094b | ||
|
|
ad5e65de9f | ||
|
|
d5a5cf151b | ||
|
|
1c4aad647c | ||
|
|
8f096e1852 | ||
|
|
6888cf405d | ||
|
|
1d316a5e1a | ||
|
|
5050d19928 | ||
|
|
898a1dd672 | ||
|
|
cd36fd281a | ||
|
|
90b8506f6a | ||
|
|
6954770fd6 | ||
|
|
3345dbdec2 | ||
|
|
f7d2176475 | ||
|
|
3869107c64 | ||
|
|
402e47e5d0 | ||
|
|
0434f76377 | ||
|
|
0e6a1d2d7c | ||
|
|
01afa3aa71 | ||
|
|
7c15f0bea1 | ||
|
|
638dc5d2a0 | ||
|
|
729af26e98 | ||
|
|
bf16cc0ee4 | ||
|
|
8cba361aaa | ||
|
|
296e475361 | ||
|
|
eff8ed2759 | ||
|
|
2ae60c4e47 | ||
|
|
6b8cb42a74 | ||
|
|
07feea9180 | ||
|
|
cc258bb1a5 | ||
|
|
0b145625bc | ||
|
|
2ba3b8a93a | ||
|
|
a93d5333fa | ||
|
|
781a0c9fcd | ||
|
|
80bbda789d | ||
|
|
c8375b0187 | ||
|
|
2947b539cd | ||
|
|
7e1911bdd0 | ||
|
|
8403a793a6 | ||
|
|
e0678bc4d8 | ||
|
|
d99f770216 | ||
|
|
b4631d87b3 | ||
|
|
45fabe4b1b | ||
|
|
7a176bf931 | ||
|
|
3979b76df4 | ||
|
|
8f49a28dab | ||
|
|
d363c656de | ||
|
|
dd001aa0e1 | ||
|
|
080f136698 | ||
|
|
b766052dcb | ||
|
|
e0e0e7eb57 | ||
|
|
e40688816d | ||
|
|
f819a5457c | ||
|
|
e1acbb3ab6 | ||
|
|
5e7767f80a | ||
|
|
011d80e316 | ||
|
|
902213ae9f | ||
|
|
9550dd83c6 | ||
|
|
5a254b1e3f | ||
|
|
31a546dabb | ||
|
|
e4ddd6d277 | ||
|
|
8968cc7c87 | ||
|
|
16e7de9453 | ||
|
|
9ec5ffc0f1 | ||
|
|
0cce9b9a2c | ||
|
|
d90c70f6ff |
0
.gitignore
vendored
Normal file
0
.gitignore
vendored
Normal file
15
README.md
15
README.md
@@ -1,19 +1,20 @@
|
||||
#bhrs_KPWXBotDemo
|
||||
# bhrs_KPWXBotDemo
|
||||
|
||||
##安装依赖
|
||||
## 安装依赖
|
||||
pip install -r requirements.txt
|
||||
|
||||
## 28369
|
||||
|
||||
##项目说明
|
||||
## 项目说明
|
||||
|
||||
1.基于 flask 框架 ,直观易懂,上手成本低
|
||||
|
||||
2.目前仅支持 http 通信方式
|
||||
|
||||
|
||||
##项目文件说明
|
||||
## 项目文件说明
|
||||
|
||||
###WXBotService.py
|
||||
### WXBotService.py
|
||||
1.封装了全部httpapi
|
||||
|
||||
2.提供了unicode转emoji方法
|
||||
@@ -31,7 +32,7 @@ pip install -r requirements.txt
|
||||
|
||||
4.自动解密图片
|
||||
|
||||
##提供的api列表
|
||||
## 提供的api列表
|
||||
|
||||
| HTTPAPI接口 | WXBotService方法 |
|
||||
|--------------------|-------------------------------------|
|
||||
@@ -89,7 +90,7 @@ pip install -r requirements.txt
|
||||
| 朋友圈点赞[K10052] | moments_like |
|
||||
| 朋友圈取消点赞[K10053] | moments_cancel_like |
|
||||
|
||||
##新增方法
|
||||
## 新增方法
|
||||
|
||||
| 说明 | WXBotService方法 |
|
||||
|-------------------|----------------------|
|
||||
|
||||
245
WXBotDemo.py
245
WXBotDemo.py
@@ -1,245 +0,0 @@
|
||||
import json
|
||||
import os
|
||||
import threading
|
||||
import time
|
||||
|
||||
from flask import request, Flask
|
||||
try:
|
||||
import xml.etree.cElementTree as ET
|
||||
except ImportError:
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
import WXBotService
|
||||
from planet import planetXml
|
||||
from lxml import etree
|
||||
import xml.etree.ElementTree as ETree
|
||||
|
||||
wxbot = Flask(__name__)
|
||||
|
||||
|
||||
@wxbot.route("/wxbot", methods=['get', 'post'])
|
||||
def hello():
|
||||
data = request.get_json()
|
||||
t = threading.Thread(target=kp, args=(data, )) # 通过当前线程开启新的线程去执行
|
||||
t.start()
|
||||
return json.dumps({"Code": 0})
|
||||
|
||||
|
||||
def kp(event_data):
|
||||
# unicode [\\uxxxxx] 转 emoji 表情
|
||||
event_data = json.loads(
|
||||
WXBotService.unicode_to_emoji(
|
||||
json.dumps(event_data, ensure_ascii=False), 'json'))
|
||||
|
||||
kp_log = '' # 定义鲲鹏日志消息
|
||||
event_type = event_data.get('event_type')
|
||||
account_wxid = event_data.get('account_wxid')
|
||||
data = event_data.get('data')
|
||||
msg_type = data.get('msgtype')
|
||||
msg = data.get('content')
|
||||
to_wxid = data.get('to_wxid')
|
||||
to_name = data.get('to_name')
|
||||
filepath = data.get("filepath")
|
||||
subtype = data.get('subtype')
|
||||
|
||||
wxid = data.get('final_from_wxid')
|
||||
wx_name = data.get('final_from_name')
|
||||
group = None if data.get('from_wxid') == wxid else data.get('from_wxid')
|
||||
group_name = None if data.get('from_name') == wx_name else data.get(
|
||||
'from_name')
|
||||
'''event类型判断'''
|
||||
if event_type == 1001: # 1001 创建WeChat进程成功,通讯连接成功
|
||||
kp_log = f'创建WeChat进程成功,通讯连接成功'
|
||||
elif event_type == 1002: # 1002 登录成功
|
||||
kp_log = f'登录成功 {data.get("nickname")}({data.get("wxid")})'
|
||||
elif event_type == 1003: # 1003 账号注销登录
|
||||
kp_log = f'账号注销登录 {data.get("wxid")} {data.get("reason")}'
|
||||
elif event_type == 1004: # 1004 切换聊天对象事件
|
||||
kp_log = f'切换聊天对象事件 {data.get("nickname")}({data.get("wxid")})'
|
||||
elif event_type == 1005: # 1005 切换联系人事件
|
||||
kp_log = f'切换联系人事件 {data.get("nickname")}({data.get("wxid")})'
|
||||
elif event_type == 1007: # 1005 二维码刷新事件
|
||||
kp_log = f'二维码刷新事件 {data.get("qrcode")}'
|
||||
elif event_type == 1008: # 1008 连接断开
|
||||
kp_log = f'连接断开'
|
||||
elif event_type == 1009: # 1009 群员退群通知
|
||||
member_list = []
|
||||
for member in data.get('memberlist'):
|
||||
member_list.append(
|
||||
f'{member.get("nickname")}({member.get("wxid")})')
|
||||
kp_log = f'群员退群通知 {",".join(member_list)} 退出了群聊 {data.get("roomname")}({data.get("roomid")}) ' \
|
||||
f'人数:{data.get("membercount")}'
|
||||
elif event_type == 1010: # 1010 群员进群通知
|
||||
member_list = []
|
||||
for member in data.get('memberlist'):
|
||||
member_list.append(
|
||||
f'{member.get("nickName")}({member.get("userName")})')
|
||||
kp_log = f'群员进群通知 {",".join(member_list)} 加入了群聊 {data.get("roomname")}({data.get("roomid")})'
|
||||
elif event_type == 1011: # 1011 收款消息
|
||||
pay_msg = ET.fromstring(msg).find('paymsg')
|
||||
pay_msg_type = pay_msg.findtext('PayMsgType')
|
||||
if pay_msg_type == '9': # 二维码收款
|
||||
status = pay_msg.findtext('status')
|
||||
username = pay_msg.findtext('username')
|
||||
display_name = pay_msg.findtext('displayname')
|
||||
fee = pay_msg.findtext('fee')
|
||||
if status == '0':
|
||||
kp_log = f'收款消息 {display_name}({username}) 扫描收款二维码'
|
||||
elif status == '1':
|
||||
kp_log = f'收款消息 {display_name}({username}) 付款成功 {int(fee) / 100} 元'
|
||||
elif status == '2':
|
||||
kp_log = f'收款消息 {display_name}({username}) 取消付款'
|
||||
elif pay_msg_type == '45': # 貌似有未收款转账或转账红包过期会触发 42 和 45 类型
|
||||
pass # kp_log = f'收款消息 {pay_msg.findtext("fromusername")} {pay_msg.findtext("content")}'
|
||||
elif event_type == 1040: # 1040 撤回消息事件
|
||||
if not group:
|
||||
kp_log = f'撤回消息事件 {wx_name}({wxid}) 撤回了 {msg}'
|
||||
else:
|
||||
kp_log = f'撤回消息事件 {wx_name}({wxid}) 从群 {group_name}({group}) 撤回了 {msg}'
|
||||
elif event_type == 1100: # 1100 同步消息
|
||||
if group:
|
||||
type_str = f'同步消息 群聊消息 群聊:{group_name}({group}) 发送者:{wx_name}({wxid})'
|
||||
elif 'gh_' in wxid:
|
||||
type_str = f'同步消息 公众号消息 {wx_name}({wxid})'
|
||||
elif '@openim' in wxid:
|
||||
type_str = f'同步消息 企业微信消息 {wx_name}({wxid})'
|
||||
else:
|
||||
type_str = f'同步消息 私聊消息 {wx_name}({wxid})'
|
||||
|
||||
if data.get('isSender') == 1:
|
||||
# 手机发送还是电脑发送这里判断不是很准确
|
||||
if to_wxid == account_wxid:
|
||||
type_str = f'机器人手机端 发送的 ' + type_str
|
||||
else:
|
||||
type_str = f'机器人电脑端 发送的 ' + type_str
|
||||
|
||||
if msg_type == 1: # 1 文本消息/自带表情
|
||||
kp_log = f'{type_str} 文本消息 内容:{msg}'
|
||||
elif msg_type == 3: # 3 图片消息
|
||||
kp_log = f'{type_str} 图片消息 内容:{filepath}'
|
||||
# 本地dat图片解密
|
||||
decrypt_path = WXBotService.local_decrypt_image(
|
||||
filepath, os.path.join(os.getcwd(), '解密图片'))
|
||||
print(f'{type_str} 图片消息 解密路径:{decrypt_path}')
|
||||
elif msg_type == 34: # 34 语言消息(需要在设置中打开语言自动转文字)
|
||||
xml_msg = ET.fromstring(msg)
|
||||
kp_log = f'{type_str} 语音消息 内容:{xml_msg.find("voicetrans").get("transtext")}'
|
||||
elif msg_type == 37: # 37 好友请求
|
||||
xml_msg = ET.fromstring(msg)
|
||||
kp_log = f'同步消息 好友请求 {xml_msg.get("fromnickname")}({xml_msg.get("fromusername")}) ' \
|
||||
f'验证内容:{xml_msg.get("content")}'
|
||||
# 同意好友请求
|
||||
WXBotService.agree_friend_request(account_wxid,
|
||||
xml_msg.get('alias'),
|
||||
xml_msg.get('encryptusername'),
|
||||
xml_msg.get('ticket'),
|
||||
xml_msg.get('scene'))
|
||||
elif msg_type == 42: # 42 名片消息
|
||||
xml_msg = ET.fromstring(msg)
|
||||
kp_log = f'{type_str} 企业微信名片消息 {xml_msg.get("nickname")}({xml_msg.get("username")})'
|
||||
elif msg_type == 43: # 43 视频消息
|
||||
kp_log = f'{type_str} 视频消息 内容:{filepath}'
|
||||
elif msg_type == 47: # 47 表情包
|
||||
kp_log = f'{type_str} 表情包消息 网址:{ET.fromstring(msg).find("emoji").get("cdnurl".replace("amp;", ""))}'
|
||||
# 本地下载图片
|
||||
down_path = WXBotService.local_download_image(
|
||||
msg, os.path.join(os.getcwd(), '下载图片'))
|
||||
print(f'{type_str} 表情包消息 下载路径:{down_path}')
|
||||
elif msg_type == 48: # 48 地理位置
|
||||
kp_log = f'{type_str} 地理位置 内容:{msg}'
|
||||
|
||||
|
||||
elif msg_type == 49: # 49 xml消息
|
||||
# 获取根节点
|
||||
root=ET.fromstring(msg)
|
||||
|
||||
# 微信好友的wxid
|
||||
wxid='111'
|
||||
for pagepath in xml_appmsg.iter('pagepath'):
|
||||
print (pagepath.text) # 打印名字
|
||||
pagepath.text =pagepath.text +f'/?wxid={wxid}'
|
||||
print ('修改path',pagepath.text) # 打印名字
|
||||
|
||||
|
||||
|
||||
xml_appmsg = root.find('appmsg')
|
||||
xml_title = xml_appmsg.findtext('title')
|
||||
xml_type = xml_appmsg.findtext('type')
|
||||
xml_des = xml_appmsg.findtext('des')
|
||||
xml_url = xml_appmsg.findtext('url')
|
||||
|
||||
if xml_type == '1': # 1 文本
|
||||
kp_log = f'收到 {wxid} xml文本消息'
|
||||
elif xml_type == '3': # 3 歌曲
|
||||
kp_log = f'{type_str} 音乐消息 歌曲:{xml_title} 歌手:{xml_des} 网址:{xml_url}'
|
||||
elif xml_type == '5': # 5 链接
|
||||
kp_log = f'{type_str} 链接消息 标题:{xml_title} 内容:{xml_des} 网址:{xml_url}'
|
||||
print("kp_log--------------------------------",msg)
|
||||
# 本身也是系统消息-link,会无线循环
|
||||
# 判断是不是自己发的消息
|
||||
if data.get('isSender') != 1:
|
||||
WXBotService.send_link_message(
|
||||
account_wxid, "wxid_w2imh7ki5s4q12", "title", "dec",
|
||||
"https://www.baidu.com",
|
||||
"https://p1-q.mafengwo.net/s17/M00/E3/9C/CoUBXl_cawCAQWMcAAGGhEoBcRU77.jpeg")
|
||||
|
||||
|
||||
elif xml_type == '6': # 6 文件
|
||||
kp_log = f'{type_str} 文件消息 文件名:{xml_title} 文件大小:{xml_des} 文件路径:{filepath}'
|
||||
elif xml_type == '19': # 19 合并转发聊天记录
|
||||
kp_log = f'{type_str} 合并转发聊天记录 文件名:{xml_title} 文件大小:{xml_des} 文件路径:{filepath}'
|
||||
elif xml_type == '33': # 33 小程序
|
||||
kp_log = f'{type_str} 小程序消息 小程序名:{xml_appmsg.findtext("sourcedisplayname")} 标题:{xml_title} ' \
|
||||
f'appid:{xml_appmsg.findtext("weappinfo/appid")} ' \
|
||||
f'pagepath:{xml_appmsg.findtext("weappinfo/pagepath")}'
|
||||
print("---------------------------kp_log",msg)
|
||||
# print("---------------------------kp_log",planetXml)
|
||||
# print('msg---', msg)
|
||||
# 发送小程序
|
||||
if data.get('isSender') != 1:
|
||||
WXBotService.send_xml_message(
|
||||
account_wxid, "wxid_w2imh7ki5s4q12", msg
|
||||
# account_wxid, "wxid_w2imh7ki5s4q12", planetXml
|
||||
|
||||
)
|
||||
|
||||
|
||||
elif xml_type == '57': # 引用消息
|
||||
kp_log = f'{type_str} 引用消息 内容:{msg}'
|
||||
elif xml_type == '2000': # 2000 转账消息
|
||||
money = xml_appmsg.findtext('wcpayinfo/feedesc').replace(
|
||||
'¥', '')
|
||||
pay_subtype = xml_appmsg.findtext('wcpayinfo/paysubtype')
|
||||
transfer_id = xml_appmsg.findtext('wcpayinfo/transferid')
|
||||
if pay_subtype == '1':
|
||||
kp_log = f'{type_str} 转账消息 {money} 元'
|
||||
# 自动接收转账
|
||||
WXBotService.transfer_receipt(account_wxid, wxid,
|
||||
transfer_id)
|
||||
elif pay_subtype == '3':
|
||||
kp_log = f'{type_str} 已收款 {money} 元 转账'
|
||||
elif msg_type == 66: # 66 企业微信名片消息
|
||||
xml_msg = ET.fromstring(msg)
|
||||
kp_log = f'企业微信名片消息 {xml_msg.get("nickname")}({xml_msg.get("username")})'
|
||||
elif msg_type == 10000: # 10000 系统消息
|
||||
kp_log = f'系统消息 {wx_name}({wxid}) {msg}'
|
||||
|
||||
#获取通讯录
|
||||
# allFriends=WXBotService.get_address_list(account_wxid)
|
||||
# print('allFriends',allFriends)
|
||||
# 发送H5链接
|
||||
|
||||
if not kp_log:
|
||||
print(
|
||||
'===================================================================================='
|
||||
)
|
||||
print(event_data)
|
||||
print(
|
||||
'===================================================================================='
|
||||
)
|
||||
else:
|
||||
print(kp_log)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
wxbot.run('127.0.0.1', 28369)
|
||||
0
__init__.py
Normal file
0
__init__.py
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
__pycache__/crud.cpython-310.pyc
Normal file
BIN
__pycache__/crud.cpython-310.pyc
Normal file
Binary file not shown.
BIN
__pycache__/crud.cpython-312.pyc
Normal file
BIN
__pycache__/crud.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/database.cpython-310.pyc
Normal file
BIN
__pycache__/database.cpython-310.pyc
Normal file
Binary file not shown.
BIN
__pycache__/database.cpython-312.pyc
Normal file
BIN
__pycache__/database.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/main.cpython-310.pyc
Normal file
BIN
__pycache__/main.cpython-310.pyc
Normal file
Binary file not shown.
BIN
__pycache__/main.cpython-312.pyc
Normal file
BIN
__pycache__/main.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/models.cpython-310.pyc
Normal file
BIN
__pycache__/models.cpython-310.pyc
Normal file
Binary file not shown.
BIN
__pycache__/models.cpython-312.pyc
Normal file
BIN
__pycache__/models.cpython-312.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
__pycache__/planet.cpython-312.pyc
Normal file
BIN
__pycache__/planet.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/schemas.cpython-310.pyc
Normal file
BIN
__pycache__/schemas.cpython-310.pyc
Normal file
Binary file not shown.
BIN
__pycache__/schemas.cpython-312.pyc
Normal file
BIN
__pycache__/schemas.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/tengxunyun.cpython-310.pyc
Normal file
BIN
__pycache__/tengxunyun.cpython-310.pyc
Normal file
Binary file not shown.
BIN
__pycache__/utils.cpython-310.pyc
Normal file
BIN
__pycache__/utils.cpython-310.pyc
Normal file
Binary file not shown.
14
config.py
14
config.py
@@ -3,3 +3,17 @@ import os
|
||||
work_path = os.getcwd()
|
||||
wxbot_url = "http://127.0.0.1:2022/KP" # api地址
|
||||
SECRET_KEY = '鉴权秘钥' # 鉴权秘钥
|
||||
|
||||
# 异度空间 wxid_sfvsru738v3122
|
||||
# 异度星球 wxid_haqoszjheyuz22
|
||||
# 异度世界 wxid_w2imh7ki5s4q12
|
||||
# cady wxid_x1iv6qhlut4x22
|
||||
account_wxid = "wxid_w2imh7ki5s4q12"
|
||||
# chatroomId = '49187487591@chatroom' #异度星球
|
||||
chatroomId = '48357370389@chatroom' #异度世界交流群2
|
||||
|
||||
# 48357370389@chatroom
|
||||
|
||||
appid = 'wxa55815dd741a540d',
|
||||
secret = '82ce78719cc6b6e4a8ff738704d5b6cc',
|
||||
tokenUrl = 'https://api.weixin.qq.com/sns/jscode2session'
|
||||
|
||||
80
crud.py
Normal file
80
crud.py
Normal file
@@ -0,0 +1,80 @@
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
# from . import models, schemas
|
||||
import models, schemas
|
||||
import json
|
||||
import time
|
||||
|
||||
|
||||
# 通过id获取用户
|
||||
def get_user(db: Session, user_id: int):
|
||||
return db.query(models.User).filter(models.User.id == user_id).first()
|
||||
|
||||
|
||||
# 通过openId岔村用户
|
||||
def get_user_by_openId(db: Session, openId: str):
|
||||
return db.query(models.User).filter(models.User.openId == openId).first()
|
||||
|
||||
|
||||
# 通过openId岔村用户
|
||||
def get_user_by_h5openid(db: Session, h5openid: str):
|
||||
return db.query(
|
||||
models.User).filter(models.User.h5openid == h5openid).first()
|
||||
|
||||
|
||||
# 通过wxid岔村用户
|
||||
def get_user_by_wxid(db: Session, wxid: str):
|
||||
return db.query(models.User).filter(models.User.wxid == wxid).first()
|
||||
|
||||
|
||||
# 分页查询-用户all
|
||||
def get_users(db: Session, skip: int = 0, limit: int = 100):
|
||||
return db.query(models.User).offset(skip).limit(limit).all()
|
||||
|
||||
|
||||
# 创建用户
|
||||
# user:schemas.UserCreate
|
||||
# **user
|
||||
def create_user(db: Session, user: schemas.User):
|
||||
# def create_user(db: Session, user):
|
||||
db_user = models.User(wxid=user.wxid,
|
||||
openId=user.openId,
|
||||
h5openid=user.h5openid,
|
||||
sex=user.sex,
|
||||
country=user.country,
|
||||
province=user.province,
|
||||
sourceStr=user.sourceStr,
|
||||
usertype=user.usertype,
|
||||
nickname=user.nickname,
|
||||
wxaccount=user.wxaccount,
|
||||
remark=user.remark,
|
||||
smallhead=user.smallhead,
|
||||
bighead=user.bighead,
|
||||
labels=user.labels,
|
||||
source=user.source,
|
||||
v1=user.v1)
|
||||
|
||||
db.add(db_user)
|
||||
db.commit()
|
||||
db.refresh(db_user)
|
||||
return db_user
|
||||
|
||||
|
||||
# 更新用户字段
|
||||
def update_user_field(db: Session, wxid: str, openId=None, h5openid=None):
|
||||
user = get_user_by_wxid(db, wxid)
|
||||
if user:
|
||||
# 更新字段值
|
||||
# 存储小程序openid
|
||||
if openId:
|
||||
user.openId = openId
|
||||
if h5openid:
|
||||
user.h5openid = h5openid
|
||||
|
||||
# 提交更改
|
||||
db.commit()
|
||||
db.refresh(user)
|
||||
print('用户数据更新')
|
||||
return user
|
||||
print('用户数据查询失败')
|
||||
return False
|
||||
13
database.py
Normal file
13
database.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
|
||||
SQLALCHEMY_DATABASE_URL = "sqlite:///./kunpeng.db"
|
||||
# SQLALCHEMY_DATABASE_URL = "postgresql://user:password@postgresserver/db"
|
||||
|
||||
engine = create_engine(
|
||||
SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False}
|
||||
)
|
||||
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
||||
|
||||
Base = declarative_base()
|
||||
19
fstring.py
Normal file
19
fstring.py
Normal file
@@ -0,0 +1,19 @@
|
||||
neWmsg = f'''我是机器人🤖助理,智能gpt对话''' \
|
||||
f'''“/img 英语描述” 可以文生图''' \
|
||||
f'''.................................................''' \
|
||||
f'''参与交流,请回复关键词 "加群"''' \
|
||||
f''' ……………………………………''' \
|
||||
f'''一名开发者''' \
|
||||
f'''副业:跨境电商''' \
|
||||
f'''爱折腾homelab ''' \
|
||||
f'''#公众号:异度世界'''
|
||||
|
||||
msg = '我是机器人🤖助理,智能gpt对话 \
|
||||
“/img 英语描述” 可以文生图 \
|
||||
…………………………………… \
|
||||
参与交流,请回复关键词 "加群" \
|
||||
…………………………………… \
|
||||
一名开发者🧑💻 \
|
||||
副业:跨境电商\
|
||||
爱折腾homelab \
|
||||
#公众号:异度世界'
|
||||
BIN
kunpeng.db
Normal file
BIN
kunpeng.db
Normal file
Binary file not shown.
1
kunpeng.sh
Normal file
1
kunpeng.sh
Normal file
@@ -0,0 +1 @@
|
||||
uvicorn main:app --host 0.0.0.0 --reload --port 28369
|
||||
696
main.py
Normal file
696
main.py
Normal file
@@ -0,0 +1,696 @@
|
||||
from fastapi import Depends, FastAPI, HTTPException
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
# from . import crud, models, schemas
|
||||
import crud, models, schemas
|
||||
from database import SessionLocal, engine
|
||||
# from .database import SessionLocal, engine
|
||||
|
||||
import json
|
||||
import os
|
||||
import threading
|
||||
import time
|
||||
from pydantic import BaseModel
|
||||
from flask import request, Flask
|
||||
try:
|
||||
import xml.etree.cElementTree as ET
|
||||
except ImportError:
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
import WXBotService
|
||||
from planet import planetXml
|
||||
from tengxunyun import tengxunyunXml
|
||||
|
||||
from lxml import etree
|
||||
import xml.dom.minidom
|
||||
from pydantic import BaseModel
|
||||
import utils
|
||||
import requests
|
||||
import config
|
||||
from urllib.parse import quote, unquote
|
||||
import re
|
||||
import emoji
|
||||
|
||||
models.Base.metadata.create_all(bind=engine)
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
# 全局消息变量
|
||||
globalMsgData = None
|
||||
|
||||
|
||||
def is_chinese(char):
|
||||
"""检查字符是否为中文字符。"""
|
||||
return '\u4e00' <= char <= '\u9fff'
|
||||
|
||||
|
||||
def chatglmApi(msg, data, group, account_wxid, wxid, wx_name, newFriendDict):
|
||||
# 不是自己发的消息
|
||||
if data.get('isSender') != 1:
|
||||
# chaglm api在本地8000端口
|
||||
# winHookUrl='http://192.168.31.184:8000/img'
|
||||
winHookUrl = 'http://chatbot.hackrobot.cn/img'
|
||||
|
||||
if "@异度世界" in msg:
|
||||
newmsg = re.sub(r"@异度世界\[@emoji=\d+\]", "", msg)
|
||||
else:
|
||||
newmsg = msg
|
||||
|
||||
print("newmsg=====>", newmsg)
|
||||
payload = {'query': newmsg}
|
||||
newPayload = json.loads(json.dumps(payload))
|
||||
# res = requests.post(winHookUrl, json=newPayload)
|
||||
# r = res.json()
|
||||
# answer = r.get("answer", "No answer provided")
|
||||
# 收到群聊消息
|
||||
if group:
|
||||
# 异度世界交流群2 48357370389@chatroom | 小号群18507867712@chatroom
|
||||
if group == "18507867712@chatroom" or group == "48357370389@chatroom":
|
||||
|
||||
# 群聊被@
|
||||
if "@异度世界" in msg:
|
||||
|
||||
res = requests.post(winHookUrl, json=newPayload)
|
||||
rgroup = res.json()
|
||||
answer = rgroup.get("answer", "No answer provided")
|
||||
groupanswer = f'@{wx_name} ,{answer} \n [本消息是机器人bot自动回复]'
|
||||
if "/img" in msg:
|
||||
newanswer = re.sub(r'#web_img\s+', '', answer)
|
||||
# 发送 @ 消息
|
||||
WXBotService.send_at_message(
|
||||
robot_wxid=account_wxid,
|
||||
from_wxid=group,
|
||||
msg=
|
||||
f'@{wx_name} ,{newmsg}=>图片已生成 \n [本消息是机器人bot自动回复]',
|
||||
wx_list=wxid)
|
||||
WXBotService.send_image_message(
|
||||
robot_wxid=account_wxid,
|
||||
# from_wxid=wxid,
|
||||
from_wxid=group,
|
||||
msg=newanswer)
|
||||
else:
|
||||
# 发送 @ 消息
|
||||
WXBotService.send_at_message(robot_wxid=account_wxid,
|
||||
from_wxid=group,
|
||||
msg=groupanswer,
|
||||
wx_list=wxid)
|
||||
else:
|
||||
# 其他群组消息,不做响应
|
||||
pass
|
||||
else:
|
||||
res = requests.post(winHookUrl, json=newPayload)
|
||||
r = res.json()
|
||||
answer = r.get("answer", "No answer provided")
|
||||
# newanswer="@"+wx_name+", "+answer
|
||||
if "/img" in msg:
|
||||
newanswer = re.sub(r'#web_img\s+', '', answer)
|
||||
WXBotService.send_image_message(robot_wxid=account_wxid,
|
||||
from_wxid=wxid,
|
||||
msg=newanswer)
|
||||
else:
|
||||
# 女性不回复
|
||||
# if newFriendDict['sex'] == "女":
|
||||
if newFriendDict.get('sex') == "女":
|
||||
return False
|
||||
# if '/gpt' in msg:
|
||||
# result = re.sub(r'^/gpt ', '', msg)
|
||||
newanswer = f'@{wx_name} ,{answer} \n [本消息是机器人bot自动回复]'
|
||||
print(newanswer)
|
||||
WXBotService.send_text_message(robot_wxid=account_wxid,
|
||||
from_wxid=wxid,
|
||||
msg=newanswer)
|
||||
|
||||
|
||||
def convert_special_chars_to_emoji(input_string):
|
||||
output = []
|
||||
for char in input_string:
|
||||
# 检查字符是否为 ASCII 字符或中文字符
|
||||
if ord(char) <= 127 or is_chinese(char):
|
||||
# ASCII 字符或中文字符直接添加
|
||||
output.append(char)
|
||||
else:
|
||||
# 获取 Unicode 代码点
|
||||
code_point = f"{ord(char):X}"
|
||||
# 将代码点转换为 emoji 代码点形式
|
||||
emoji_representation = f"[@emoji={code_point}]"
|
||||
# 将非中文且非 ASCII 字符替换为 emoji 代码点形式
|
||||
output.append(emoji_representation)
|
||||
|
||||
# 将列表中的字符组合成一个字符串
|
||||
return ''.join(output)
|
||||
|
||||
|
||||
# 转换emoji字符串为[]
|
||||
def transOldemoji(oldEmoji=None):
|
||||
# oldEmoji = "异度世界🤖"
|
||||
original_string = WXBotService.emoji_to_unicode(oldEmoji)
|
||||
# print("original_string", original_string)
|
||||
# # 全局替换 \\u 为 @emoji=
|
||||
# converted_string = original_string.replace('\\\\u', '@emoji=')
|
||||
# # 在 Unicode 编码后添加 ']'
|
||||
# converted_string = converted_string[:-1] + ']'
|
||||
# # 输出转换后的字符串
|
||||
# print(converted_string)
|
||||
# return converted_string
|
||||
# 全局替换 \\u 为 @emoji=
|
||||
converted_string = original_string.replace('\\u', '@emoji=')
|
||||
|
||||
# 在 Unicode 编码后添加 ']'
|
||||
# 如果原始字符串中的 \\uXXX 是在方括号中,需要保留方括号
|
||||
# 替换后,如果需要,可以调整这一步骤,根据特定需求
|
||||
converted_string = re.sub(r'\[@emoji=[0-9a-fA-F]{4}\]',
|
||||
lambda match: f'{match.group()}]',
|
||||
converted_string)
|
||||
converted_string = converted_string.replace('[\\@', '[@')
|
||||
# 输出转换后的字符串
|
||||
# print(converted_string)
|
||||
return converted_string
|
||||
|
||||
|
||||
# Dependency
|
||||
def get_db():
|
||||
db = SessionLocal()
|
||||
try:
|
||||
yield db
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
|
||||
# 默认首页
|
||||
@app.get("/")
|
||||
async def root():
|
||||
return {"message": "Hello World"}
|
||||
|
||||
|
||||
# 微信登录
|
||||
@app.get("/login")
|
||||
def read_users(code, wxid, db: Session = Depends(get_db)):
|
||||
print('code--', code)
|
||||
new_user = {}
|
||||
# 异度星球-小程序
|
||||
payload = {
|
||||
'appid': config.appid,
|
||||
'secret': config.secret,
|
||||
'js_code': code,
|
||||
'grant_type': 'authorization_code'
|
||||
}
|
||||
res = requests.get(config.tokenUrl, params=payload)
|
||||
r = res.json()
|
||||
# 返回参数 session_key/unionid/errmsg/openid/errcode
|
||||
print('r----', r)
|
||||
openId = r['openid']
|
||||
print('openId----', openId)
|
||||
db_user = crud.get_user_by_openId(db, openId=openId)
|
||||
print('db_user----', db_user)
|
||||
|
||||
if db_user:
|
||||
# 返回用户完整数据
|
||||
new_user = db_user
|
||||
else:
|
||||
if wxid:
|
||||
# 机器人id
|
||||
account_wxid = config.account_wxid
|
||||
# 新增用户
|
||||
new_user = utils.saveWxidInfo(account_wxid, wxid, openId)
|
||||
# "errmsg":r['errmsg'],,"errcode":r['errcode']
|
||||
# return {"session_key":r['session_key'],"unionid":r['unionid'],"openid":r['openid']}
|
||||
return new_user
|
||||
|
||||
|
||||
# H5保存用户h5openid与wxid
|
||||
@app.get("/addH5openid")
|
||||
def addH5openid(h5openid, wxid, db: Session = Depends(get_db)):
|
||||
db_user = crud.get_user_by_h5openid(db, h5openid=h5openid)
|
||||
print('db_user----', db_user)
|
||||
|
||||
if db_user:
|
||||
# 返回用户完整数据
|
||||
new_user = db_user
|
||||
else:
|
||||
if wxid:
|
||||
# 机器人id
|
||||
account_wxid = config.account_wxid
|
||||
# 新增用户
|
||||
new_user = utils.saveWxidInfo(account_wxid=config.account_wxid,
|
||||
wxid=wxid,
|
||||
h5openid=h5openid)
|
||||
# "errmsg":r['errmsg'],,"errcode":r['errcode']
|
||||
# return {"session_key":r['session_key'],"unionid":r['unionid'],"openid":r['openid']}
|
||||
return new_user
|
||||
|
||||
|
||||
# 加入微信群
|
||||
@app.get("/joingroup")
|
||||
# 群-异度星球 49187487591@chatroom chatroom
|
||||
def read_users(wxid, db: Session = Depends(get_db)):
|
||||
# debug
|
||||
# chatroomId = '49187487591@chatroom'
|
||||
# 判断是否在群中
|
||||
inGroup = False
|
||||
groupList = WXBotService.get_group_members_list(
|
||||
robot_wxid=config.account_wxid, from_wxid=config.chatroomId)
|
||||
print('groupList', groupList)
|
||||
for groupItem in groupList['data']:
|
||||
if groupItem['wxid'] == wxid:
|
||||
inGroup = True
|
||||
if inGroup:
|
||||
return {"code": 200, "success": "fail", "message": "已经在群聊中"}
|
||||
else:
|
||||
WXBotService.add_group_members_40_more(
|
||||
robot_wxid=config.account_wxid,
|
||||
from_wxid=config.chatroomId, #异度星球群
|
||||
new_wxid=wxid)
|
||||
print('wxid--', wxid)
|
||||
return {"code": 200, "success": "ok", "message": "群聊邀请已发送"}
|
||||
|
||||
|
||||
# 加入微信群
|
||||
@app.get("/h5group")
|
||||
# 群-异度星球 49187487591@chatroom chatroom
|
||||
def h5group(nickname, db: Session = Depends(get_db)):
|
||||
newtext = unquote(nickname, 'utf-8')
|
||||
# pattern = r'收到(\w+)的在看'
|
||||
# pattern = r'收到([\w\[\]@=]+)的在看'
|
||||
# pattern = r'收到([\w\[\]@=\u4e00-\u9fff-]+)的在看'
|
||||
# 处理空白符
|
||||
pattern = r'收到((?:[\w\s\[\]@=\u4e00-\u9fff-]|@\w+)+?)的在看'
|
||||
print("newtext===>", newtext)
|
||||
|
||||
# 处理emoji转为[@emoji=1f916] 格式
|
||||
newtext = transOldemoji(newtext)
|
||||
# print("newtextemoji", newtext)
|
||||
|
||||
# 不是 ASCII 字符,则获取该字符的 Unicode 代码点
|
||||
newtext = convert_special_chars_to_emoji(newtext)
|
||||
# print("newtextASI", newtext)
|
||||
matches = re.findall(pattern, newtext)
|
||||
# print("matches", matches)
|
||||
matchesString = None
|
||||
if len(matches) > 0:
|
||||
matchesString = matches[0]
|
||||
print("matchesString", matchesString)
|
||||
|
||||
if matchesString:
|
||||
# matchesString = remove_emojis(matchesString) #删除emoji字符串
|
||||
print("匹配到的结果:", matchesString)
|
||||
# 判断是否在群中
|
||||
inGroup = False
|
||||
groupList = WXBotService.get_group_members_list(
|
||||
robot_wxid=config.account_wxid, from_wxid=config.chatroomId)
|
||||
# print('groupList', groupList)
|
||||
if groupList['data'] is not None:
|
||||
for groupItem in groupList['data']:
|
||||
if groupItem['nickname'] == matchesString:
|
||||
inGroup = True
|
||||
if inGroup:
|
||||
print('已经在群聊中')
|
||||
return {"code": 200, "success": "fail", "message": "已经在群聊中"}
|
||||
else:
|
||||
new_wxid = None
|
||||
allFriend = WXBotService.get_address_list(config.account_wxid)
|
||||
for friendItem in allFriend['data']["contactList"]:
|
||||
if friendItem['nickname'] == matchesString:
|
||||
# if matchesString in friendItem['nickname']:
|
||||
new_wxid = friendItem['wxid']
|
||||
else:
|
||||
# print('通过nickname查不到wxid')
|
||||
pass
|
||||
if new_wxid:
|
||||
WXBotService.add_group_members_40_more(
|
||||
robot_wxid=config.account_wxid,
|
||||
from_wxid=config.chatroomId, #异度星球群
|
||||
new_wxid=new_wxid)
|
||||
print('new_wxid--', new_wxid)
|
||||
# 发送小程序
|
||||
# utils.sendminiProgram(data=None,
|
||||
# account_wxid=config.account_wxid,
|
||||
# wxid=new_wxid,
|
||||
# msgXml=planetXml)
|
||||
# WXBotService.send_text_message(
|
||||
# robot_wxid=config.account_wxid,
|
||||
# from_wxid=new_wxid,
|
||||
# msg=f'已收到-[在看]支持,谢谢,请从小程序,点击"立即加入"\n[本消息是机器人自动回复]')
|
||||
return {"code": 200, "success": "ok", "message": "群聊邀请已发送"}
|
||||
else:
|
||||
print('通过nickname查不到wxid')
|
||||
return {
|
||||
"code": 200,
|
||||
"success": "ok",
|
||||
"message": "查不到nickname"
|
||||
}
|
||||
else:
|
||||
print("Error: 'data' is None.")
|
||||
|
||||
else:
|
||||
print("未找到匹配项,或者有特殊字符")
|
||||
return {"code": 200, "success": "ok", "message": "未找到匹配项,或者有特殊字符"}
|
||||
|
||||
|
||||
# 创建用户
|
||||
@app.post("/users")
|
||||
# schemas.UserCreate决定了swagger文档
|
||||
def create_user(user: schemas.User, db: Session = Depends(get_db)):
|
||||
print('user', user)
|
||||
print('typeuser', type(user))
|
||||
# 检测是否存在wxid
|
||||
db_user = crud.get_user_by_wxid(db, user.wxid)
|
||||
print('db_user', db_user)
|
||||
if db_user:
|
||||
raise HTTPException(status_code=400, detail="wxid already registered")
|
||||
return crud.create_user(db=db, user=user)
|
||||
|
||||
|
||||
# 分页查询-用户
|
||||
@app.get("/users")
|
||||
def read_users(skip: int = 0, limit: int = 100, db: Session = Depends(get_db)):
|
||||
users = crud.get_users(db, skip=skip, limit=limit)
|
||||
return users
|
||||
|
||||
|
||||
# 根据openId查询用户
|
||||
@app.post("/openId")
|
||||
def read_user(user: schemas.User, db: Session = Depends(get_db)):
|
||||
db_user = crud.get_user_by_openId(db, openId=user.openId)
|
||||
if db_user is None:
|
||||
raise HTTPException(status_code=404, detail="openId not found")
|
||||
return db_user
|
||||
|
||||
|
||||
# 根据wxid查询用户
|
||||
@app.get("/users")
|
||||
def read_user(wxid, db: Session = Depends(get_db)):
|
||||
db_user = crud.get_user_by_wxid(db, wxid=wxid)
|
||||
if db_user is None:
|
||||
raise HTTPException(status_code=404, detail="User-wxid not found")
|
||||
return db_user
|
||||
|
||||
|
||||
# 监听机器人http-get消息
|
||||
@app.get("/wxbot")
|
||||
def helloget(q: dict):
|
||||
data = q
|
||||
t = threading.Thread(target=kp, args=(data, )) # 通过当前线程开启新的线程去执行
|
||||
t.start()
|
||||
return json.dumps({"Code": 0})
|
||||
|
||||
|
||||
def remove_emojis(text):
|
||||
return ''.join(c for c in text if c not in emoji.UNICODE_EMOJI)
|
||||
|
||||
|
||||
# 监听机器人post日志消息
|
||||
@app.post("/wxbot")
|
||||
# def hellopost(requestData:schemas.User):
|
||||
def hellopost(requestData: dict):
|
||||
try:
|
||||
print('requestData---', requestData)
|
||||
data = requestData
|
||||
t = threading.Thread(target=kp, args=(data, )) # 通过当前线程开启新的线程去执行
|
||||
t.start()
|
||||
return json.dumps({"Code": 0})
|
||||
except:
|
||||
print('日志异常---请检查--------------------')
|
||||
return json.dumps({"Code": 0})
|
||||
|
||||
|
||||
def kp(event_data):
|
||||
# unicode [\\uxxxxx] 转 emoji 表情
|
||||
try:
|
||||
event_data = json.loads(
|
||||
WXBotService.unicode_to_emoji(
|
||||
json.dumps(event_data, ensure_ascii=False), 'json'))
|
||||
except:
|
||||
print('字符串处理失败=>请检查--------------------')
|
||||
return
|
||||
|
||||
kp_log = '' # 定义鲲鹏日志消息
|
||||
event_type = event_data.get('event_type') #事件类型
|
||||
account_wxid = event_data.get('account_wxid') #机器人id
|
||||
data = event_data.get('data')
|
||||
print('data===>', data)
|
||||
# global globalMsgData
|
||||
# globalMsgData=event_data.get('data')
|
||||
msg_type = data.get('msgtype') #消息类型
|
||||
msg = data.get('content')
|
||||
to_wxid = data.get('to_wxid') #发送给
|
||||
to_name = data.get('to_name')
|
||||
filepath = data.get("filepath")
|
||||
subtype = data.get('subtype') #类型
|
||||
thumbpath = data.get('thumbpath') #图片,存在电脑绝对路径
|
||||
|
||||
wxid = data.get('final_from_wxid') #消息来源-用户wxid
|
||||
wx_name = data.get('final_from_name') #消息来源-用户名字
|
||||
|
||||
# 群聊id
|
||||
group = None if data.get('from_wxid') == wxid else data.get('from_wxid')
|
||||
# 群聊名称
|
||||
group_name = None if data.get('from_name') == wx_name else data.get(
|
||||
'from_name')
|
||||
'''event类型判断'''
|
||||
if event_type == 1001: # 1001 创建WeChat进程成功,通讯连接成功
|
||||
kp_log = f'创建WeChat进程成功,通讯连接成功'
|
||||
elif event_type == 1002: # 1002 登录成功
|
||||
kp_log = f'登录成功 {data.get("nickname")}({data.get("wxid")})'
|
||||
elif event_type == 1003: # 1003 账号注销登录
|
||||
kp_log = f'账号注销登录 {data.get("wxid")} {data.get("reason")}'
|
||||
elif event_type == 1004: # 1004 切换聊天对象事件
|
||||
kp_log = f'切换聊天对象事件 {data.get("nickname")}({data.get("wxid")})'
|
||||
elif event_type == 1005: # 1005 切换联系人事件
|
||||
kp_log = f'切换联系人事件 {data.get("nickname")}({data.get("wxid")})'
|
||||
elif event_type == 1007: # 1005 二维码刷新事件
|
||||
kp_log = f'二维码刷新事件 {data.get("qrcode")}'
|
||||
elif event_type == 1008: # 1008 连接断开
|
||||
kp_log = f'连接断开'
|
||||
elif event_type == 1009: # 1009 群员退群通知
|
||||
member_list = []
|
||||
for member in data.get('memberlist'):
|
||||
member_list.append(
|
||||
f'{member.get("nickname")}({member.get("wxid")})')
|
||||
kp_log = f'群员退群通知 {",".join(member_list)} 退出了群聊 {data.get("roomname")}({data.get("roomid")}) ' \
|
||||
f'人数:{data.get("membercount")}'
|
||||
elif event_type == 1010: # 1010 群员进群通知
|
||||
member_list = []
|
||||
for member in data.get('memberlist'):
|
||||
member_list.append(
|
||||
f'{member.get("nickName")}({member.get("userName")})')
|
||||
kp_log = f'群员进群通知 {",".join(member_list)} 加入了群聊 {data.get("roomname")}({data.get("roomid")})'
|
||||
elif event_type == 1011: # 1011 收款消息
|
||||
pay_msg = ET.fromstring(msg).find('paymsg')
|
||||
pay_msg_type = pay_msg.findtext('PayMsgType')
|
||||
if pay_msg_type == '9': # 二维码收款
|
||||
status = pay_msg.findtext('status')
|
||||
username = pay_msg.findtext('username')
|
||||
display_name = pay_msg.findtext('displayname')
|
||||
fee = pay_msg.findtext('fee')
|
||||
if status == '0':
|
||||
kp_log = f'收款消息 {display_name}({username}) 扫描收款二维码'
|
||||
elif status == '1':
|
||||
kp_log = f'收款消息 {display_name}({username}) 付款成功 {int(fee) / 100} 元'
|
||||
elif status == '2':
|
||||
kp_log = f'收款消息 {display_name}({username}) 取消付款'
|
||||
elif pay_msg_type == '45': # 貌似有未收款转账或转账红包过期会触发 42 和 45 类型
|
||||
pass # kp_log = f'收款消息 {pay_msg.findtext("fromusername")} {pay_msg.findtext("content")}'
|
||||
elif event_type == 1040: # 1040 撤回消息事件
|
||||
if not group:
|
||||
kp_log = f'撤回消息事件 {wx_name}({wxid}) 撤回了 {msg}'
|
||||
else:
|
||||
kp_log = f'撤回消息事件 {wx_name}({wxid}) 从群 {group_name}({group}) 撤回了 {msg}'
|
||||
elif event_type == 1100: # 1100 同步消息
|
||||
if group:
|
||||
type_str = f'同步消息 群聊消息 群聊:{group_name}({group}) 发送者:{wx_name}({wxid})'
|
||||
elif 'gh_' in wxid:
|
||||
type_str = f'同步消息 公众号消息 {wx_name}({wxid})'
|
||||
elif '@openim' in wxid:
|
||||
type_str = f'同步消息 企业微信消息 {wx_name}({wxid})'
|
||||
else:
|
||||
type_str = f'同步消息 私聊消息 {wx_name}({wxid})'
|
||||
|
||||
if data.get('isSender') == 1:
|
||||
# 手机发送还是电脑发送这里判断不是很准确
|
||||
if to_wxid == account_wxid:
|
||||
type_str = f'机器人手机端 发送的 ' + type_str
|
||||
else:
|
||||
type_str = f'机器人电脑端 发送的 ' + type_str
|
||||
|
||||
|
||||
# from_wxid': '18507867712@chatroom'
|
||||
if msg_type == 1: # 1 文本消息/自带表情
|
||||
|
||||
kp_log = f'{type_str} 文本消息 内容:{msg}'
|
||||
# 将好友信息=>保存到数据库
|
||||
newFriendDict = WXBotService.get_friend_info(account_wxid, wxid)
|
||||
print('newFriendDict==>', newFriendDict)
|
||||
allFriend = WXBotService.get_address_list(config.account_wxid)
|
||||
for friendItem in allFriend['data']["contactList"]:
|
||||
if friendItem['wxid'] == wxid:
|
||||
# if matchesString in friendItem['nickname']:
|
||||
newFriendDict = friendItem
|
||||
print('newFriendDict222==>', newFriendDict)
|
||||
else:
|
||||
# print('通过nickname查不到wxid')
|
||||
pass
|
||||
|
||||
# 收到群聊消息
|
||||
if group:
|
||||
# 异度世界交流群2 48357370389@chatroom | 小号群18507867712@chatroom
|
||||
chatglmApi(msg, data, group, account_wxid, wxid, wx_name,
|
||||
newFriendDict)
|
||||
else:
|
||||
# pass
|
||||
if msg in ['工具箱']:
|
||||
# 发送小程序
|
||||
utils.sendminiProgram(data, account_wxid, wxid, planetXml)
|
||||
# if msg in ['加群']:
|
||||
if msg == '加群':
|
||||
|
||||
# print('newFriendDict[data]---',newFriendDict['data'])
|
||||
# userClass = models.User(**(newFriendDict['data']))
|
||||
|
||||
# print('userClass====',type(userClass))
|
||||
# crud.create_user(db=SessionLocal(),user=userClass)
|
||||
|
||||
# 保存好友信息
|
||||
# utils.saveWxidInfo(account_wxid, wxid)
|
||||
|
||||
# 直接邀请加群>40
|
||||
# WXBotService.add_group_members_40_more(robot_wxid='wxid_sfvsru738v3122',
|
||||
# from_wxid='49187487591@chatroom',
|
||||
# new_wxid='wxid_4413224132412')
|
||||
# print("data", data)
|
||||
# if "emoji" in wx_name:
|
||||
# # 发送小程序
|
||||
# utils.sendminiProgram(data, account_wxid, wxid, planetXml)
|
||||
# else:
|
||||
# H5链接
|
||||
WXBotService.send_link_message(
|
||||
account_wxid,
|
||||
wxid,
|
||||
title="欢迎加入微信群",
|
||||
desc="请查看规则",
|
||||
url=
|
||||
f'https://link.hackrobot.cn#/pages/index/index?wxid={wxid}',
|
||||
pic=
|
||||
"https://www.hackrobot.cn/wp-content/uploads/2023/05/cropped-cropped-Screenshot-2023-05-22-at-17.26.38.png"
|
||||
)
|
||||
else:
|
||||
# 回复ai消息
|
||||
chatglmApi(msg, data, group, account_wxid, wxid,
|
||||
wx_name, newFriendDict)
|
||||
|
||||
# if msg in ['腾讯云']:
|
||||
# # 发送小程序
|
||||
# utils.sendminiProgram(data, account_wxid, wxid, tengxunyunXml)
|
||||
|
||||
elif msg_type == 3: # 3 图片消息
|
||||
kp_log = f'{type_str} 图片消息 内容:{filepath}'
|
||||
# 本地dat图片解密
|
||||
decrypt_path = WXBotService.local_decrypt_image(
|
||||
filepath, os.path.join(os.getcwd(), '解密图片'))
|
||||
print(f'{type_str} 图片消息 解密路径:{decrypt_path}')
|
||||
elif msg_type == 34: # 34 语言消息(需要在设置中打开语言自动转文字)
|
||||
xml_msg = ET.fromstring(msg)
|
||||
kp_log = f'{type_str} 语音消息 内容:{xml_msg.find("voicetrans").get("transtext")}'
|
||||
# elif msg_type == 37: # 37 好友请求
|
||||
# xml_msg = ET.fromstring(msg)
|
||||
# kp_log = f'同步消息 好友请求 {xml_msg.get("fromnickname")}({xml_msg.get("fromusername")}) ' \
|
||||
# f'验证内容:{xml_msg.get("content")}'
|
||||
# # 同意好友请求
|
||||
# WXBotService.agree_friend_request(account_wxid,
|
||||
# xml_msg.get('alias'),
|
||||
# xml_msg.get('encryptusername'),
|
||||
# xml_msg.get('ticket'),
|
||||
# xml_msg.get('scene'))
|
||||
# newFriendWxid = xml_msg.get('alias')
|
||||
# # 将好友信息=>保存到数据库
|
||||
# # newFriendDict=WXBotService.get_friend_info(account_wxid, newFriendWxid)
|
||||
# # userClass=models.User(**(newFriendDict['data']))
|
||||
# # crud.create_user(db= SessionLocal(),user=userClass)
|
||||
# newMsg = f'''你好,本消息是bot回复,本人是一名开发者,副业跨境电商,爱折腾homelab,参与交流请回复: 加群'''
|
||||
# WXBotService.send_text_message(robot_wxid=account_wxid,
|
||||
# from_wxid=newFriendWxid,
|
||||
# msg=newMsg)
|
||||
|
||||
elif msg_type == 42: # 42 名片消息
|
||||
xml_msg = ET.fromstring(msg)
|
||||
kp_log = f'{type_str} 企业微信名片消息 {xml_msg.get("nickname")}({xml_msg.get("username")})'
|
||||
elif msg_type == 43: # 43 视频消息
|
||||
kp_log = f'{type_str} 视频消息 内容:{filepath}'
|
||||
elif msg_type == 47: # 47 表情包
|
||||
kp_log = f'{type_str} 表情包消息 网址:{ET.fromstring(msg).find("emoji").get("cdnurl".replace("amp;", ""))}'
|
||||
# 本地下载图片
|
||||
down_path = WXBotService.local_download_image(
|
||||
msg, os.path.join(os.getcwd(), '下载图片'))
|
||||
print(f'{type_str} 表情包消息 下载路径:{down_path}')
|
||||
elif msg_type == 48: # 48 地理位置
|
||||
kp_log = f'{type_str} 地理位置 内容:{msg}'
|
||||
|
||||
elif msg_type == 49: # 49 xml消息
|
||||
# 获取根节点
|
||||
root = ET.fromstring(msg)
|
||||
xml_appmsg = root.find('appmsg')
|
||||
|
||||
xml_title = xml_appmsg.findtext('title')
|
||||
xml_type = xml_appmsg.findtext('type')
|
||||
xml_des = xml_appmsg.findtext('des')
|
||||
xml_url = xml_appmsg.findtext('url')
|
||||
|
||||
if xml_type == '1': # 1 文本
|
||||
kp_log = f'收到 {wxid} xml文本消息'
|
||||
elif xml_type == '3': # 3 歌曲
|
||||
kp_log = f'{type_str} 音乐消息 歌曲:{xml_title} 歌手:{xml_des} 网址:{xml_url}'
|
||||
elif xml_type == '5': # 5 链接
|
||||
kp_log = f'{type_str} 链接消息 标题:{xml_title} 内容:{xml_des} 网址:{xml_url}'
|
||||
print("kp_log--------------------------------", msg)
|
||||
# 本身也是系统消息-link,会无线循环
|
||||
# 判断是不是自己发的消息
|
||||
# if data.get('isSender') != 1:
|
||||
# WXBotService.send_link_message(
|
||||
# account_wxid, "wxid_w2imh7ki5s4q12", "title", "dec",
|
||||
# "https://www.baidu.com",
|
||||
# "https://p1-q.mafengwo.net/s17/M00/E3/9C/CoUBXl_cawCAQWMcAAGGhEoBcRU77.jpeg")
|
||||
|
||||
elif xml_type == '6': # 6 文件
|
||||
kp_log = f'{type_str} 文件消息 文件名:{xml_title} 文件大小:{xml_des} 文件路径:{filepath}'
|
||||
elif xml_type == '19': # 19 合并转发聊天记录
|
||||
kp_log = f'{type_str} 合并转发聊天记录 文件名:{xml_title} 文件大小:{xml_des} 文件路径:{filepath}'
|
||||
elif xml_type == '33': # 33 小程序
|
||||
kp_log = f'{type_str} 小程序消息 小程序名:{xml_appmsg.findtext("sourcedisplayname")} 标题:{xml_title} ' \
|
||||
f'appid:{xml_appmsg.findtext("weappinfo/appid")} ' \
|
||||
f'pagepath:{xml_appmsg.findtext("weappinfo/pagepath")}'
|
||||
print("---------------------------kp_log", msg)
|
||||
|
||||
elif xml_type == '57': # 引用消息
|
||||
kp_log = f'{type_str} 引用消息 内容:{msg}'
|
||||
elif xml_type == '2000': # 2000 转账消息
|
||||
money = xml_appmsg.findtext('wcpayinfo/feedesc').replace(
|
||||
'¥', '')
|
||||
pay_subtype = xml_appmsg.findtext('wcpayinfo/paysubtype')
|
||||
transfer_id = xml_appmsg.findtext('wcpayinfo/transferid')
|
||||
if pay_subtype == '1':
|
||||
kp_log = f'{type_str} 转账消息 {money} 元'
|
||||
# 自动接收转账
|
||||
WXBotService.transfer_receipt(account_wxid, wxid,
|
||||
transfer_id)
|
||||
elif pay_subtype == '3':
|
||||
kp_log = f'{type_str} 已收款 {money} 元 转账'
|
||||
elif msg_type == 66: # 66 企业微信名片消息
|
||||
xml_msg = ET.fromstring(msg)
|
||||
kp_log = f'企业微信名片消息 {xml_msg.get("nickname")}({xml_msg.get("username")})'
|
||||
elif msg_type == 10000: # 10000 系统消息
|
||||
kp_log = f'系统消息 {wx_name}({wxid}) {msg}'
|
||||
|
||||
#获取通讯录
|
||||
# allFriends=WXBotService.get_address_list(account_wxid)
|
||||
# print('allFriends',allFriends)
|
||||
# 发送H5链接
|
||||
|
||||
if not kp_log:
|
||||
print(
|
||||
'===================================================================================='
|
||||
)
|
||||
print(event_data)
|
||||
print(
|
||||
'===================================================================================='
|
||||
)
|
||||
else:
|
||||
print(kp_log)
|
||||
35
models.py
Normal file
35
models.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from sqlalchemy import Boolean, Column, ForeignKey, Integer, String
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from database import Base
|
||||
# from .database import Base
|
||||
|
||||
class User(Base):
|
||||
__tablename__ = "users"
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
wxid = Column(String)
|
||||
openId = Column(String)
|
||||
h5openid = Column(String)
|
||||
sex = Column(String) #性别 男/女
|
||||
city = Column(String) #城市
|
||||
country = Column(String) #"CN"
|
||||
province = Column(String) #"Hubei"
|
||||
sourceStr = Column(String) #:"通过朋友验证消息添加"
|
||||
usertype = Column(String)
|
||||
nickname = Column(String) #昵称
|
||||
wxaccount = Column(String) #微信号
|
||||
remark = Column(String) #备注
|
||||
smallhead = Column(String) #头像
|
||||
bighead = Column(String) #头像-打
|
||||
labels = Column(String) #
|
||||
source = Column(String) #来源
|
||||
generator = Column(String)
|
||||
v1 = Column(String)
|
||||
|
||||
|
||||
# {'bighead': 'https://wx.qlogo.cn/mmhead/ver_1/sAOrfgticJnOSE39qcB2mtImUMyANI4NoumWzKbdf87yMYp89Jhszic3mYVgFomW45CSeBxTQK2eyiciakUr9njdvAMtZKHL8w9uIcF8feicZU9ama4xMaU1TlnT4VYam5WHN/0', 'city': 'Jingzhou', 'country': 'CN', 'labels': '', 'nickname': 'Eric', 'province': 'Hubei', 'remark': '', 'sex': '男', 'smallhead': 'https://wx.qlogo.cn/mmhead/ver_1/sAOrfgticJnOSE39qcB2mtImUMyA NI4NoumWzKbdf87yMYp89Jhszic3mYVgFomW45CSeBxTQK2eyiciakUr9njdvAMtZKHL8w9uIcF8feicZU9ama4xMaU1TlnT4VYam5WHN/132', 'source': 6, 'sourceStr': '通过朋友验证消息添加', 'usertype': 1, 'wxaccount': 'small
|
||||
# zhiyun', 'wxid': 'wxid_4413224132412'}
|
||||
|
||||
|
||||
|
||||
260
planet.py
260
planet.py
@@ -1,64 +1,252 @@
|
||||
planetXml='''<?xml version="1.0"? encoding="UTF-8"?>
|
||||
#第28行,cmder手动复制,会丢失信息, 可以写到text文件先
|
||||
# https://www.hackrobot.cn/wp-content/uploads/2023/05/cropped-cropped-Screenshot-2023-05-22-at-17.26.38.png
|
||||
# <url>https://mp.weixin.qq.com/mp/waerrpage?appid=wxa55815dd741a540d&type=upgrade&upgradetype=3#wechat_redirect</url>
|
||||
# <weappiconurl><![CDATA[http://mmbiz.qpic.cn/sz_mmbiz_png/43cSpHKSBGyHO7qHeuad8BJLUQ6W9ib7QLfgYicyvGTvpibvLicrS0MaTia3nplqDbWrLIXSfxQgpL3Aib1jGjHjOl9A/640?wx_fmt=png&wxfrom=200]]></weappiconurl>
|
||||
|
||||
|
||||
planetXml='''<?xml version="1.0"?>
|
||||
<msg>
|
||||
<appmsg appid="" sdkver="0">
|
||||
<title>异度世界的星球</title>127.0.0.1 - - [20/Mar/2024 09:10:30] "POST /wxbot HTTP/1.1" 200 -
|
||||
<des>异度世界的星球</des>
|
||||
<type>33</type>
|
||||
<title>异度世界的星球</title>
|
||||
<des />
|
||||
<username />
|
||||
<action>view</action>
|
||||
<url>https://mp.weixin.qq.com/mp/waerrpage?appid=wxa55815dd741a540d&type=upgrade&upgradetype=3#wechat_redirect</url>
|
||||
<type>33</type>
|
||||
<showtype>0</showtype>
|
||||
<content />
|
||||
<url>https://mp.weixin.qq.com/mp/waerrpage?appid=wxa55815dd741a540d&type=upgrade&upgradetype=3#wechat_redirect</url>
|
||||
<lowurl />
|
||||
<forwardflag>0</forwardflag>
|
||||
<dataurl />
|
||||
<lowdataurl />
|
||||
<contentattr>0</contentattr>
|
||||
<streamvideo>
|
||||
<streamvideourl />
|
||||
<streamvideototaltime>0</streamvideototaltime>
|
||||
<streamvideotitle />
|
||||
<streamvideowording />
|
||||
<streamvideoweburl />
|
||||
<streamvideothumburl />
|
||||
<streamvideoaduxinfo />
|
||||
<streamvideopublishid />
|
||||
</streamvideo>
|
||||
<canvasPageItem>
|
||||
<canvasPageXml><![CDATA[]]></canvasPageXml>
|
||||
</canvasPageItem>
|
||||
<appattach>
|
||||
<cdnthumburl>3057020100044b304902010002043866a09902032f591902044da90c79020465fa36d0042461316466393862632d656333632d346438302d623330652d3766613538653831613436340204051408030201000405004c537500</cdnthumburl>
|
||||
<cdnthumbmd5>dc2e218e5faf36dd4add4db1e0308cbe</cdnthumbmd5>
|
||||
<cdnthumblength>34873</cdnthumblength>
|
||||
<cdnthumbwidth>720</cdnthumbwidth>
|
||||
<attachid />
|
||||
<cdnthumburl>3057020100044b304902010002043866a09902032f5bd50204a0631f7402046621c738042434636230626137642d356265622d343330642d396665332d3633323836636138663337340204051408030201000405004c4d9900</cdnthumburl>
|
||||
<cdnthumbmd5>34a6517421dca3cba789b266362fe3ef</cdnthumbmd5>
|
||||
<cdnthumblength>33077</cdnthumblength>
|
||||
<cdnthumbheight>576</cdnthumbheight>
|
||||
<cdnthumbaeskey>712778198a86497a3495eed7256f1fd7</cdnthumbaeskey>
|
||||
<aeskey>712778198a86497a3495eed7256f1fd7</aeskey>
|
||||
<encryver>0</encryver>
|
||||
<filekey>wxid_haqoszjheyuz22_229_1710897030</filekey>
|
||||
<cdnthumbwidth>720</cdnthumbwidth>
|
||||
<cdnthumbaeskey>2bff5fd740318f4a38631c612187db0c</cdnthumbaeskey>
|
||||
<aeskey>2bff5fd740318f4a38631c612187db0c</aeskey>
|
||||
<encryver>1</encryver>
|
||||
<fileext />
|
||||
<islargefilemsg>0</islargefilemsg>
|
||||
</appattach>
|
||||
<extinfo />
|
||||
<androidsource>0</androidsource>
|
||||
<sourceusername>gh_735af7f13193@app</sourceusername>
|
||||
<sourcedisplayname>异度世界的星球</sourcedisplayname>
|
||||
<md5>dc2e218e5faf36dd4add4db1e0308cbe</md5>
|
||||
<commenturl />
|
||||
<thumburl />
|
||||
<mediatagname />
|
||||
<messageaction><![CDATA[]]></messageaction>
|
||||
<messageext><![CDATA[]]></messageext>
|
||||
<emoticongift>
|
||||
<packageflag>0</packageflag>
|
||||
<packageid />
|
||||
</emoticongift>
|
||||
<emoticonshared>
|
||||
<packageflag>0</packageflag>
|
||||
<packageid />
|
||||
</emoticonshared>
|
||||
<designershared>
|
||||
<designeruin>0</designeruin>
|
||||
<designername>null</designername>
|
||||
<designerrediretcturl><![CDATA[null]]></designerrediretcturl>
|
||||
</designershared>
|
||||
<emotionpageshared>
|
||||
<tid>0</tid>
|
||||
<title>null</title>
|
||||
<desc>null</desc>
|
||||
<iconUrl><![CDATA[null]]></iconUrl>
|
||||
<secondUrl>null</secondUrl>
|
||||
<pageType>0</pageType>
|
||||
<setKey>null</setKey>
|
||||
</emotionpageshared>
|
||||
<webviewshared>
|
||||
<jsAppId><![CDATA[]]></jsAppId>
|
||||
<shareUrlOriginal />
|
||||
<shareUrlOpen />
|
||||
<jsAppId />
|
||||
<publisherId>wxapp_wxa55815dd741a540dpages/index/index.html?wxid=wxid_4413224132412</publisherId>
|
||||
<publisherReqId />
|
||||
</webviewshared>
|
||||
<template_id />
|
||||
<md5>34a6517421dca3cba789b266362fe3ef</md5>
|
||||
<websearch>
|
||||
<rec_category>0</rec_category>
|
||||
<channelId>0</channelId>
|
||||
</websearch>
|
||||
<weappinfo>
|
||||
<username><![CDATA[gh_735af7f13193@app]]></username>
|
||||
<appid><![CDATA[wxa55815dd741a540d]]></appid>
|
||||
<pagepath><![CDATA[pages/index/index.html?wxid=wxid_4413224132412]]></pagepath>
|
||||
<username>gh_735af7f13193@app</username>
|
||||
<appid>wxa55815dd741a540d</appid>
|
||||
<version>12</version>
|
||||
<type>2</type>
|
||||
<version>3</version>
|
||||
<weappiconurl><![CDATA[http://mmbiz.qpic.cn/sz_mmbiz_png/43cSpHKSBGyHO7qHeuad8BJLUQ6W9ib7QLfgYicyvGTvpibvLicrS0MaTia3nplqDbWrLIXSfxQgpL3Aib1jGjHjOl9A/640?wx_fmt=png&wxfrom>
|
||||
<pagepath><![CDATA[pages/index/index.html]]></pagepath>
|
||||
<shareId><![CDATA[0_wxa55815dd741a540d_a96a890b27e8c43d18e2e75fda2a9215_1710896515_0]]></shareId>
|
||||
<pkginfo>
|
||||
<type>2</type>
|
||||
<md5><![CDATA[721c114bb969b9fdc4379396248cb6a3]]></md5>
|
||||
</pkginfo>
|
||||
<weappiconurl><![CDATA[http://wx.qlogo.cn/mmhead/dibCvqHg4Wndl2KSbgHaa7Kf6rL8K0hOrnTXmdXmmBnk96YyCtVcsjY21DZFSlXD2IZraZbqpibh4/132]]></weappiconurl>
|
||||
<shareId><![CDATA[1_wxa55815dd741a540d_a96a890b27e8c43d18e2e75fda2a9215_1713489719_1]]></shareId>
|
||||
<appservicetype>0</appservicetype>
|
||||
<brandofficialflag>0</brandofficialflag>
|
||||
<showRelievedBuyFlag>0</showRelievedBuyFlag>
|
||||
<hasRelievedBuyPlugin>0</hasRelievedBuyPlugin>
|
||||
<flagshipflag>0</flagshipflag>
|
||||
<subType>0</subType>
|
||||
<secflagforsinglepagemode>0</secflagforsinglepagemode>
|
||||
<videopageinfo>
|
||||
<thumbwidth>720</thumbwidth>
|
||||
<thumbheight>576</thumbheight>
|
||||
<videosource><![CDATA[]]></videosource>
|
||||
<fromopensdk>0</fromopensdk>
|
||||
<appthumburl><![CDATA[(null)]]></appthumburl>
|
||||
</videopageinfo>
|
||||
<isprivatemessage>0</isprivatemessage>
|
||||
</weappinfo>
|
||||
<statextstr />
|
||||
<musicShareItem>
|
||||
<musicDuration>0</musicDuration>
|
||||
</musicShareItem>
|
||||
<finderLiveProductShare>
|
||||
<finderLiveID><![CDATA[]]></finderLiveID>
|
||||
<finderUsername><![CDATA[]]></finderUsername>
|
||||
<finderObjectID><![CDATA[]]></finderObjectID>
|
||||
<finderNonceID><![CDATA[]]></finderNonceID>
|
||||
<liveStatus><![CDATA[]]></liveStatus>
|
||||
<appId><![CDATA[]]></appId>
|
||||
<pagePath><![CDATA[]]></pagePath>
|
||||
<productId><![CDATA[]]></productId>
|
||||
<coverUrl><![CDATA[]]></coverUrl>
|
||||
<productTitle><![CDATA[]]></productTitle>
|
||||
<marketPrice><![CDATA[0]]></marketPrice>
|
||||
<sellingPrice><![CDATA[0]]></sellingPrice>
|
||||
<platformHeadImg><![CDATA[]]></platformHeadImg>
|
||||
<platformName><![CDATA[]]></platformName>
|
||||
<shopWindowId><![CDATA[]]></shopWindowId>
|
||||
<flashSalePrice><![CDATA[0]]></flashSalePrice>
|
||||
<flashSaleEndTime><![CDATA[0]]></flashSaleEndTime>
|
||||
<ecSource><![CDATA[]]></ecSource>
|
||||
<sellingPriceWording><![CDATA[]]></sellingPriceWording>
|
||||
<platformIconURL><![CDATA[]]></platformIconURL>
|
||||
<firstProductTagURL><![CDATA[]]></firstProductTagURL>
|
||||
<firstProductTagAspectRatioString><![CDATA[0.0]]></firstProductTagAspectRatioString>
|
||||
<secondProductTagURL><![CDATA[]]></secondProductTagURL>
|
||||
<secondProductTagAspectRatioString><![CDATA[0.0]]></secondProductTagAspectRatioString>
|
||||
<firstGuaranteeWording><![CDATA[]]></firstGuaranteeWording>
|
||||
<secondGuaranteeWording><![CDATA[]]></secondGuaranteeWording>
|
||||
<thirdGuaranteeWording><![CDATA[]]></thirdGuaranteeWording>
|
||||
<isPriceBeginShow>false</isPriceBeginShow>
|
||||
<lastGMsgID><![CDATA[]]></lastGMsgID>
|
||||
<promoterKey><![CDATA[]]></promoterKey>
|
||||
<discountWording><![CDATA[]]></discountWording>
|
||||
<priceSuffixDescription><![CDATA[]]></priceSuffixDescription>
|
||||
<showBoxItemStringList />
|
||||
</finderLiveProductShare>
|
||||
<finderOrder>
|
||||
<appID><![CDATA[]]></appID>
|
||||
<orderID><![CDATA[]]></orderID>
|
||||
<path><![CDATA[]]></path>
|
||||
<priceWording><![CDATA[]]></priceWording>
|
||||
<stateWording><![CDATA[]]></stateWording>
|
||||
<productImageURL><![CDATA[]]></productImageURL>
|
||||
<products><![CDATA[]]></products>
|
||||
<productsCount><![CDATA[0]]></productsCount>
|
||||
</finderOrder>
|
||||
<finderShopWindowShare>
|
||||
<finderUsername><![CDATA[]]></finderUsername>
|
||||
<avatar><![CDATA[]]></avatar>
|
||||
<nickname><![CDATA[]]></nickname>
|
||||
<commodityInStockCount><![CDATA[]]></commodityInStockCount>
|
||||
<appId><![CDATA[]]></appId>
|
||||
<path><![CDATA[]]></path>
|
||||
<appUsername><![CDATA[]]></appUsername>
|
||||
<query><![CDATA[]]></query>
|
||||
<liteAppId><![CDATA[]]></liteAppId>
|
||||
<liteAppPath><![CDATA[]]></liteAppPath>
|
||||
<liteAppQuery><![CDATA[]]></liteAppQuery>
|
||||
<platformTagURL><![CDATA[]]></platformTagURL>
|
||||
<saleWording><![CDATA[]]></saleWording>
|
||||
<lastGMsgID><![CDATA[]]></lastGMsgID>
|
||||
<profileTypeWording><![CDATA[]]></profileTypeWording>
|
||||
<reputationInfo>
|
||||
<hasReputationInfo>0</hasReputationInfo>
|
||||
<reputationScore>0</reputationScore>
|
||||
<reputationWording />
|
||||
<reputationTextColor />
|
||||
<reputationLevelWording />
|
||||
<reputationBackgroundColor />
|
||||
</reputationInfo>
|
||||
<productImageURLList />
|
||||
</finderShopWindowShare>
|
||||
<findernamecard>
|
||||
<username />
|
||||
<avatar><![CDATA[]]></avatar>
|
||||
<nickname />
|
||||
<auth_job />
|
||||
<auth_icon>0</auth_icon>
|
||||
<auth_icon_url />
|
||||
<ecSource><![CDATA[]]></ecSource>
|
||||
<lastGMsgID><![CDATA[]]></lastGMsgID>
|
||||
</findernamecard>
|
||||
<finderGuarantee>
|
||||
<scene><![CDATA[0]]></scene>
|
||||
</finderGuarantee>
|
||||
<directshare>0</directshare>
|
||||
<gamecenter>
|
||||
<namecard>
|
||||
<iconUrl />
|
||||
<name />
|
||||
<desc />
|
||||
<tail />
|
||||
<jumpUrl />
|
||||
</namecard>
|
||||
</gamecenter>
|
||||
<patMsg>
|
||||
<chatUser />
|
||||
<records>
|
||||
<recordNum>0</recordNum>
|
||||
</records>
|
||||
</patMsg>
|
||||
<secretmsg>
|
||||
<isscrectmsg>0</isscrectmsg>
|
||||
<issecretmsg>0</issecretmsg>
|
||||
</secretmsg>
|
||||
<referfromscene>0</referfromscene>
|
||||
<gameshare>
|
||||
<liteappext>
|
||||
<liteappbizdata />
|
||||
<priority>0</priority>
|
||||
</liteappext>
|
||||
<appbrandext>
|
||||
<litegameinfo />
|
||||
<priority>-1</priority>
|
||||
</appbrandext>
|
||||
<gameshareid />
|
||||
<sharedata />
|
||||
<isvideo>0</isvideo>
|
||||
<duration>-1</duration>
|
||||
<isexposed>0</isexposed>
|
||||
<readtext />
|
||||
</gameshare>
|
||||
<mpsharetrace>
|
||||
<hasfinderelement>0</hasfinderelement>
|
||||
<lastgmsgid />
|
||||
</mpsharetrace>
|
||||
<wxgamecard>
|
||||
<framesetname />
|
||||
<mbcarddata />
|
||||
<minpkgversion />
|
||||
<mbcardheight>0</mbcardheight>
|
||||
<isoldversion>0</isoldversion>
|
||||
</wxgamecard>
|
||||
</appmsg>
|
||||
<fromusername>wxid_4413224132412</fromusername>
|
||||
<scene>0</scene>
|
||||
<appinfo>
|
||||
<version>1</version>
|
||||
<appname></appname>
|
||||
<appname />
|
||||
</appinfo>
|
||||
<commenturl></commenturl>
|
||||
<commenturl />
|
||||
</msg>'''
|
||||
64
planet.xml
64
planet.xml
@@ -1,64 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<msg>
|
||||
<appmsg appid="" sdkver="0">
|
||||
<title>异度世界的星球</title>127.0.0.1 - - [20/Mar/2024 09:10:30] "POST /wxbot HTTP/1.1" 200 -
|
||||
<des>异度世界的星球</des>
|
||||
<type>33</type>
|
||||
<action>view</action>
|
||||
<url>https://mp.weixin.qq.com/mp/waerrpage?appid=wxa55815dd741a540d&type=upgrade&upgradetype=3#wechat_redirect</url>
|
||||
<appattach>
|
||||
<cdnthumburl>3057020100044b304902010002043866a09902032f591902044da90c79020465fa36d0042461316466393862632d656333632d346438302d623330652d3766613538653831613436340204051408030201000405004c537500</cdnthumburl>
|
||||
<cdnthumbmd5>dc2e218e5faf36dd4add4db1e0308cbe</cdnthumbmd5>
|
||||
<cdnthumblength>34873</cdnthumblength>
|
||||
<cdnthumbwidth>720</cdnthumbwidth>
|
||||
<cdnthumbheight>576</cdnthumbheight>
|
||||
<cdnthumbaeskey>712778198a86497a3495eed7256f1fd7</cdnthumbaeskey>
|
||||
<aeskey>712778198a86497a3495eed7256f1fd7</aeskey>
|
||||
<encryver>0</encryver>
|
||||
<filekey>wxid_haqoszjheyuz22_229_1710897030</filekey>
|
||||
</appattach>
|
||||
<sourceusername>gh_735af7f13193@app</sourceusername>
|
||||
<sourcedisplayname>异度世界的星球</sourcedisplayname>
|
||||
<md5>dc2e218e5faf36dd4add4db1e0308cbe</md5>
|
||||
<webviewshared>
|
||||
<jsAppId><![CDATA[]]></jsAppId>
|
||||
</webviewshared>
|
||||
<weappinfo>
|
||||
<username><![CDATA[gh_735af7f13193@app]]></username>
|
||||
<appid><![CDATA[wxa55815dd741a540d]]></appid>
|
||||
<type>2</type>
|
||||
<version>3</version>
|
||||
<weappiconurl><![CDATA[http://mmbiz.qpic.cn/sz_mmbiz_png/43cSpHKSBGyHO7qHeuad8BJLUQ6W9ib7QLfgYicyvGTvpibvLicrS0MaTia3nplqDbWrLIXSfxQgpL3Aib1jGjHjOl9A/640?wx_fmt=png&wxfrom>
|
||||
<pagepath><![CDATA[pages/index/index.html?wxid=wxid_w2imh7ki5s4q12]]></pagepath>
|
||||
<shareId><![CDATA[0_wxa55815dd741a540d_a96a890b27e8c43d18e2e75fda2a9215_1710896515_0]]></shareId>
|
||||
<pkginfo>
|
||||
<type>2</type>
|
||||
<md5><![CDATA[721c114bb969b9fdc4379396248cb6a3]]></md5>
|
||||
</pkginfo>
|
||||
<appservicetype>0</appservicetype>
|
||||
<brandofficialflag>0</brandofficialflag>
|
||||
<showRelievedBuyFlag>0</showRelievedBuyFlag>
|
||||
<hasRelievedBuyPlugin>0</hasRelievedBuyPlugin>
|
||||
<flagshipflag>0</flagshipflag>
|
||||
<subType>0</subType>
|
||||
<videopageinfo>
|
||||
<thumbwidth>720</thumbwidth>
|
||||
<thumbheight>576</thumbheight>
|
||||
<videosource><![CDATA[]]></videosource>
|
||||
<fromopensdk>0</fromopensdk>
|
||||
<appthumburl><![CDATA[(null)]]></appthumburl>
|
||||
</videopageinfo>
|
||||
<isprivatemessage>0</isprivatemessage>
|
||||
</weappinfo>
|
||||
<secretmsg>
|
||||
<isscrectmsg>0</isscrectmsg>
|
||||
</secretmsg>
|
||||
</appmsg>
|
||||
<fromusername>wxid_4413224132412</fromusername>
|
||||
<scene>0</scene>
|
||||
<appinfo>
|
||||
<version>1</version>
|
||||
<appname></appname>
|
||||
</appinfo>
|
||||
<commenturl></commenturl>
|
||||
</msg>
|
||||
26
schemas.py
Normal file
26
schemas.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from pydantic import BaseModel
|
||||
|
||||
# 用户信息
|
||||
class UserCreate(BaseModel):
|
||||
wxid: str | None = None
|
||||
openId: str| None = None
|
||||
h5openid: str| None = None
|
||||
sex: str| None = None
|
||||
country: str| None = None
|
||||
province: str| None = None
|
||||
sourceStr: str| None = None
|
||||
usertype: str| None = None
|
||||
nickname: str| None = None
|
||||
wxaccount: str| None = None
|
||||
remark: str| None = None
|
||||
smallhead: str| None = None
|
||||
bighead: str| None = None
|
||||
labels: str| None = None
|
||||
source: str| None = None
|
||||
v1: str| None = None
|
||||
|
||||
class User(UserCreate):
|
||||
id: int| None = None
|
||||
class Config:
|
||||
orm_mode = True
|
||||
|
||||
250
tengxunyun.py
Normal file
250
tengxunyun.py
Normal file
@@ -0,0 +1,250 @@
|
||||
#第28行,cmder手动复制,会丢失信息, 可以写到text文件先
|
||||
|
||||
tengxunyunXml='''<?xml version="1.0"?>
|
||||
<msg>
|
||||
<appmsg appid="" sdkver="0">
|
||||
<title>CPS推广奖励-腾讯云</title>
|
||||
<des />
|
||||
<username />
|
||||
<action>view</action>
|
||||
<type>33</type>
|
||||
<showtype>0</showtype>
|
||||
<content />
|
||||
<url>https://mp.weixin.qq.com/mp/waerrpage?appid=wxe2039b83454e49ed&type=upgrade&upgradetype=3#wechat_redirect</url>
|
||||
<lowurl />
|
||||
<forwardflag>0</forwardflag>
|
||||
<dataurl />
|
||||
<lowdataurl />
|
||||
<contentattr>0</contentattr>
|
||||
<streamvideo>
|
||||
<streamvideourl />
|
||||
<streamvideototaltime>0</streamvideototaltime>
|
||||
<streamvideotitle />
|
||||
<streamvideowording />
|
||||
<streamvideoweburl />
|
||||
<streamvideothumburl />
|
||||
<streamvideoaduxinfo />
|
||||
<streamvideopublishid />
|
||||
</streamvideo>
|
||||
<canvasPageItem>
|
||||
<canvasPageXml><![CDATA[]]></canvasPageXml>
|
||||
</canvasPageItem>
|
||||
<appattach>
|
||||
<attachid />
|
||||
<cdnthumburl>3057020100044b304902010002043866a09902032f59190204dfa90c79020466000c68042430383662643330342d636636302d343365312d623334662d3463353465316630313230300204051808030201000405004c575d00</cdnthumburl>
|
||||
<cdnthumbmd5>10ae9b87932e4c0ddac8035ebc422877</cdnthumbmd5>
|
||||
<cdnthumblength>3656</cdnthumblength>
|
||||
<cdnthumbheight>117</cdnthumbheight>
|
||||
<cdnthumbwidth>147</cdnthumbwidth>
|
||||
<cdnthumbaeskey>b91836c3414767d59b3b0bd6dafef399</cdnthumbaeskey>
|
||||
<aeskey>b91836c3414767d59b3b0bd6dafef399</aeskey>
|
||||
<encryver>1</encryver>
|
||||
<fileext />
|
||||
<islargefilemsg>0</islargefilemsg>
|
||||
</appattach>
|
||||
<extinfo />
|
||||
<androidsource>0</androidsource>
|
||||
<sourceusername>gh_44fc2ced7f87@app</sourceusername>
|
||||
<sourcedisplayname>腾讯云助手</sourcedisplayname>
|
||||
<commenturl />
|
||||
<thumburl />
|
||||
<mediatagname />
|
||||
<messageaction><![CDATA[]]></messageaction>
|
||||
<messageext><![CDATA[]]></messageext>
|
||||
<emoticongift>
|
||||
<packageflag>0</packageflag>
|
||||
<packageid />
|
||||
</emoticongift>
|
||||
<emoticonshared>
|
||||
<packageflag>0</packageflag>
|
||||
<packageid />
|
||||
</emoticonshared>
|
||||
<designershared>
|
||||
<designeruin>0</designeruin>
|
||||
<designername>null</designername>
|
||||
<designerrediretcturl><![CDATA[null]]></designerrediretcturl>
|
||||
</designershared>
|
||||
<emotionpageshared>
|
||||
<tid>0</tid>
|
||||
<title>null</title>
|
||||
<desc>null</desc>
|
||||
<iconUrl><![CDATA[null]]></iconUrl>
|
||||
<secondUrl>null</secondUrl>
|
||||
<pageType>0</pageType>
|
||||
<setKey>null</setKey>
|
||||
</emotionpageshared>
|
||||
<webviewshared>
|
||||
<shareUrlOriginal />
|
||||
<shareUrlOpen />
|
||||
<jsAppId />
|
||||
<publisherId>wxapp_wxe2039b83454e49edpages/web-view/web-view.html?routerStartTime=1711279179185&__key_=171127902841813&viaPath=products%2Ftca-account_0.0.7%2Fpages%2Flogin%2Flogin-verify%2Flogin-verify&url=https%3A%2F%2Fcloud.tencent.com%2Fact%2Fpartner%2Fcps&sampshare=%7B%22i%22%3A%22100000605490%22%2C%22p%22%3A%22pages%2Fweb-view%2Fweb-view%22%2C%22d%22%3A0%2C%22m%22%3A%22%E8%BD%AC%E5%8F%91%E6%B6%88%E6%81%AF%E5%8D%A1%E7%89%87%22%7D</publisherId>
|
||||
<publisherReqId />
|
||||
</webviewshared>
|
||||
<template_id />
|
||||
<md5>10ae9b87932e4c0ddac8035ebc422877</md5>
|
||||
<websearch>
|
||||
<rec_category>0</rec_category>
|
||||
<channelId>0</channelId>
|
||||
</websearch>
|
||||
<weappinfo>
|
||||
<pagepath><![CDATA[pages/web-view/web-view.html?url=https://cloud.tencent.com/act/cps/redirect?redirect=2446&cps_key=d096044bdae9e70d7718918e22123113&from=console]]></pagepath>
|
||||
<username>gh_44fc2ced7f87@app</username>
|
||||
<appid>wxe2039b83454e49ed</appid>
|
||||
<version>613</version>
|
||||
<type>2</type>
|
||||
<weappiconurl><![CDATA[http://wx.qlogo.cn/mmhead/Q3auHgzwzM7Y1DaByoCRoeeCrIkoicgQa0ibQHLgJ8OcFMFXmmJRjibeQ/132]]></weappiconurl>
|
||||
<weapppagethumbrawurl><![CDATA[https://dscache.tencent-cloud.cn/upload/uploader/cloud-a5648ed4f076e66dbc61fc2c3f54e8ac89a54c28.webp]]></weapppagethumbrawurl>
|
||||
<shareId><![CDATA[1_wxe2039b83454e49ed_a96a890b27e8c43d18e2e75fda2a9215_1711279202_0]]></shareId>
|
||||
<appservicetype>0</appservicetype>
|
||||
<secflagforsinglepagemode>0</secflagforsinglepagemode>
|
||||
<videopageinfo>
|
||||
<thumbwidth>147</thumbwidth>
|
||||
<thumbheight>117</thumbheight>
|
||||
<fromopensdk>0</fromopensdk>
|
||||
</videopageinfo>
|
||||
<showRelievedBuyFlag>538</showRelievedBuyFlag>
|
||||
</weappinfo>
|
||||
<statextstr />
|
||||
<musicShareItem>
|
||||
<musicDuration>0</musicDuration>
|
||||
</musicShareItem>
|
||||
<finderLiveProductShare>
|
||||
<finderLiveID><![CDATA[]]></finderLiveID>
|
||||
<finderUsername><![CDATA[]]></finderUsername>
|
||||
<finderObjectID><![CDATA[]]></finderObjectID>
|
||||
<finderNonceID><![CDATA[]]></finderNonceID>
|
||||
<liveStatus><![CDATA[]]></liveStatus>
|
||||
<appId><![CDATA[]]></appId>
|
||||
<pagePath><![CDATA[]]></pagePath>
|
||||
<productId><![CDATA[]]></productId>
|
||||
<coverUrl><![CDATA[]]></coverUrl>
|
||||
<productTitle><![CDATA[]]></productTitle>
|
||||
<marketPrice><![CDATA[0]]></marketPrice>
|
||||
<sellingPrice><![CDATA[0]]></sellingPrice>
|
||||
<platformHeadImg><![CDATA[]]></platformHeadImg>
|
||||
<platformName><![CDATA[]]></platformName>
|
||||
<shopWindowId><![CDATA[]]></shopWindowId>
|
||||
<flashSalePrice><![CDATA[0]]></flashSalePrice>
|
||||
<flashSaleEndTime><![CDATA[0]]></flashSaleEndTime>
|
||||
<ecSource><![CDATA[]]></ecSource>
|
||||
<sellingPriceWording><![CDATA[]]></sellingPriceWording>
|
||||
<platformIconURL><![CDATA[]]></platformIconURL>
|
||||
<firstProductTagURL><![CDATA[]]></firstProductTagURL>
|
||||
<firstProductTagAspectRatioString><![CDATA[0.0]]></firstProductTagAspectRatioString>
|
||||
<secondProductTagURL><![CDATA[]]></secondProductTagURL>
|
||||
<secondProductTagAspectRatioString><![CDATA[0.0]]></secondProductTagAspectRatioString>
|
||||
<firstGuaranteeWording><![CDATA[]]></firstGuaranteeWording>
|
||||
<secondGuaranteeWording><![CDATA[]]></secondGuaranteeWording>
|
||||
<thirdGuaranteeWording><![CDATA[]]></thirdGuaranteeWording>
|
||||
<isPriceBeginShow>false</isPriceBeginShow>
|
||||
<lastGMsgID><![CDATA[]]></lastGMsgID>
|
||||
<promoterKey><![CDATA[]]></promoterKey>
|
||||
<discountWording><![CDATA[]]></discountWording>
|
||||
<priceSuffixDescription><![CDATA[]]></priceSuffixDescription>
|
||||
<showBoxItemStringList />
|
||||
</finderLiveProductShare>
|
||||
<finderOrder>
|
||||
<appID><![CDATA[]]></appID>
|
||||
<orderID><![CDATA[]]></orderID>
|
||||
<path><![CDATA[]]></path>
|
||||
<priceWording><![CDATA[]]></priceWording>
|
||||
<stateWording><![CDATA[]]></stateWording>
|
||||
<productImageURL><![CDATA[]]></productImageURL>
|
||||
<products><![CDATA[]]></products>
|
||||
<productsCount><![CDATA[0]]></productsCount>
|
||||
</finderOrder>
|
||||
<finderShopWindowShare>
|
||||
<finderUsername><![CDATA[]]></finderUsername>
|
||||
<avatar><![CDATA[]]></avatar>
|
||||
<nickname><![CDATA[]]></nickname>
|
||||
<commodityInStockCount><![CDATA[]]></commodityInStockCount>
|
||||
<appId><![CDATA[]]></appId>
|
||||
<path><![CDATA[]]></path>
|
||||
<appUsername><![CDATA[]]></appUsername>
|
||||
<query><![CDATA[]]></query>
|
||||
<liteAppId><![CDATA[]]></liteAppId>
|
||||
<liteAppPath><![CDATA[]]></liteAppPath>
|
||||
<liteAppQuery><![CDATA[]]></liteAppQuery>
|
||||
<platformTagURL><![CDATA[]]></platformTagURL>
|
||||
<saleWording><![CDATA[]]></saleWording>
|
||||
<lastGMsgID><![CDATA[]]></lastGMsgID>
|
||||
<profileTypeWording><![CDATA[]]></profileTypeWording>
|
||||
<reputationInfo>
|
||||
<hasReputationInfo>0</hasReputationInfo>
|
||||
<reputationScore>0</reputationScore>
|
||||
<reputationWording />
|
||||
<reputationTextColor />
|
||||
<reputationLevelWording />
|
||||
<reputationBackgroundColor />
|
||||
</reputationInfo>
|
||||
<productImageURLList />
|
||||
</finderShopWindowShare>
|
||||
<findernamecard>
|
||||
<username />
|
||||
<avatar><![CDATA[]]></avatar>
|
||||
<nickname />
|
||||
<auth_job />
|
||||
<auth_icon>0</auth_icon>
|
||||
<auth_icon_url />
|
||||
<ecSource><![CDATA[]]></ecSource>
|
||||
<lastGMsgID><![CDATA[]]></lastGMsgID>
|
||||
</findernamecard>
|
||||
<finderGuarantee>
|
||||
<scene><![CDATA[0]]></scene>
|
||||
</finderGuarantee>
|
||||
<directshare>0</directshare>
|
||||
<gamecenter>
|
||||
<namecard>
|
||||
<iconUrl />
|
||||
<name />
|
||||
<desc />
|
||||
<tail />
|
||||
<jumpUrl />
|
||||
</namecard>
|
||||
</gamecenter>
|
||||
<patMsg>
|
||||
<chatUser />
|
||||
<records>
|
||||
<recordNum>0</recordNum>
|
||||
</records>
|
||||
</patMsg>
|
||||
<secretmsg>
|
||||
<issecretmsg>0</issecretmsg>
|
||||
</secretmsg>
|
||||
<referfromscene>0</referfromscene>
|
||||
<gameshare>
|
||||
<liteappext>
|
||||
<liteappbizdata />
|
||||
<priority>0</priority>
|
||||
</liteappext>
|
||||
<appbrandext>
|
||||
<litegameinfo />
|
||||
<priority>-1</priority>
|
||||
</appbrandext>
|
||||
<gameshareid />
|
||||
<sharedata />
|
||||
<isvideo>0</isvideo>
|
||||
<duration>-1</duration>
|
||||
<isexposed>0</isexposed>
|
||||
<readtext />
|
||||
</gameshare>
|
||||
<mpsharetrace>
|
||||
<hasfinderelement>0</hasfinderelement>
|
||||
<lastgmsgid />
|
||||
</mpsharetrace>
|
||||
<wxgamecard>
|
||||
<framesetname />
|
||||
<mbcarddata />
|
||||
<minpkgversion />
|
||||
<mbcardheight>0</mbcardheight>
|
||||
<isoldversion>0</isoldversion>
|
||||
</wxgamecard>
|
||||
</appmsg>
|
||||
<fromusername>wxid_4413224132412</fromusername>
|
||||
<scene>0</scene>
|
||||
<appinfo>
|
||||
<version>1</version>
|
||||
<appname></appname>
|
||||
</appinfo>
|
||||
<commenturl></commenturl>
|
||||
</msg>'''
|
||||
46
text.xml
Normal file
46
text.xml
Normal file
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0"?>
|
||||
<msg>
|
||||
<appmsg appid="" sdkver="0">
|
||||
<title>异度世界的星球</title>
|
||||
<des>异度世界的星球</des>
|
||||
<type>33</type>
|
||||
<url>https://mp.weixin.qq.com/mp/waerrpage?appid=wxa55815dd741a540d&type=upgrade&upgradetype=3#wechat_redirect</url>
|
||||
<appattach>
|
||||
<cdnthumburl>3057020100044b304902010002043866a09902032f591902045ba90c79020465fffd3d042438353138636161662d636539352d346166322d393431632d6663393539646437383265390204051408030201000405004c55cd00</cdnthumburl>
|
||||
<cdnthumbmd5>6619aa9eb04a48f41b34375baa11261c</cdnthumbmd5>
|
||||
<cdnthumblength>74726</cdnthumblength>
|
||||
<cdnthumbwidth>720</cdnthumbwidth>
|
||||
<cdnthumbheight>576</cdnthumbheight>
|
||||
<cdnthumbaeskey>15c4f51dd6761513e0650fec1bed0373</cdnthumbaeskey>
|
||||
<aeskey>15c4f51dd6761513e0650fec1bed0373</aeskey>
|
||||
<encryver>0</encryver>
|
||||
<filekey>wxid_sfvsru738v3122_252_1711275446</filekey>
|
||||
</appattach>
|
||||
<sourceusername>gh_735af7f13193@app</sourceusername>
|
||||
<sourcedisplayname>异度世界的星球</sourcedisplayname>
|
||||
<md5>6619aa9eb04a48f41b34375baa11261c</md5>
|
||||
<weappinfo>
|
||||
<username><![CDATA[gh_735af7f13193@app]]></username>
|
||||
<appid><![CDATA[wxa55815dd741a540d]]></appid>
|
||||
<type>2</type>
|
||||
<version>8</version>
|
||||
<weappiconurl><![CDATA[http://mmbiz.qpic.cn/sz_mmbiz_png/43cSpHKSBGyHO7qHeuad8BJLUQ6W9ib7QLfgYicyvGTvpibvLicrS0MaTia3nplqDbWrLIXSfxQgpL3Aib1jGjHjOl9A/640?wx_fmt=png&wxfrom=200]]></weappiconurl>
|
||||
<pagepath><![CDATA[pages/index/index.html]]></pagepath>
|
||||
<shareId><![CDATA[0_wxa55815dd741a540d_a96a890b27e8c43d18e2e75fda2a9215_1711275445_0]]></shareId>
|
||||
<appservicetype>0</appservicetype>
|
||||
<brandofficialflag>0</brandofficialflag>
|
||||
<showRelievedBuyFlag>0</showRelievedBuyFlag>
|
||||
<hasRelievedBuyPlugin>0</hasRelievedBuyPlugin>
|
||||
<flagshipflag>0</flagshipflag>
|
||||
<subType>0</subType>
|
||||
<isprivatemessage>0</isprivatemessage>
|
||||
</weappinfo>
|
||||
</appmsg>
|
||||
<fromusername>wxid_4413224132412</fromusername>
|
||||
<scene>0</scene>
|
||||
<appinfo>
|
||||
<version>1</version>
|
||||
<appname></appname>
|
||||
</appinfo>
|
||||
<commenturl></commenturl>
|
||||
</msg>
|
||||
85
utils.py
Normal file
85
utils.py
Normal file
@@ -0,0 +1,85 @@
|
||||
from fastapi import Depends, FastAPI, HTTPException
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
# from . import crud, models, schemas
|
||||
import crud, models, schemas
|
||||
from database import SessionLocal, engine
|
||||
# from .database import SessionLocal, engine
|
||||
|
||||
import json
|
||||
import os
|
||||
import threading
|
||||
import time
|
||||
from pydantic import BaseModel
|
||||
from flask import request, Flask
|
||||
try:
|
||||
import xml.etree.cElementTree as ET
|
||||
except ImportError:
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
import WXBotService
|
||||
from planet import planetXml
|
||||
from lxml import etree
|
||||
import xml.dom.minidom
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
# 保存好友信息
|
||||
def saveWxidInfo(account_wxid, wxid, openId=None, h5openid=None):
|
||||
print('wxid', wxid)
|
||||
print('openId', openId)
|
||||
print('h5openid', h5openid)
|
||||
|
||||
allFriend = WXBotService.get_address_list(account_wxid)
|
||||
for friendItem in allFriend['data']["contactList"]:
|
||||
if friendItem['wxid'] == wxid:
|
||||
db_user = crud.get_user_by_wxid(db=SessionLocal(), wxid=wxid)
|
||||
print("db_user",db_user)
|
||||
if db_user:
|
||||
print("wxid already registered")
|
||||
if db_user.openId and db_user.h5openid:
|
||||
print('用户数据openid和h5id都存在,无需更新')
|
||||
else:
|
||||
print("开始更新数据表")
|
||||
crud.update_user_field(db=SessionLocal(),
|
||||
wxid=wxid,
|
||||
openId=openId,
|
||||
h5openid=h5openid)
|
||||
# 更新数据
|
||||
# return db_user
|
||||
else:
|
||||
# 存储小程序openid
|
||||
if openId:
|
||||
friendItem['openId'] = openId
|
||||
if h5openid:
|
||||
friendItem['h5openid'] = h5openid
|
||||
print("friendItem",friendItem)
|
||||
friendItemObj = models.User(**friendItem)
|
||||
new_user = crud.create_user(db=SessionLocal(),
|
||||
user=friendItemObj)
|
||||
return new_user
|
||||
|
||||
|
||||
# 发送小程序模版,建议远程更新
|
||||
def sendminiProgram(data=None, account_wxid=None, wxid=None, msgXml=None):
|
||||
# 发送小程序
|
||||
#不是自己发的消息
|
||||
# if data.get('isSender') != 1:
|
||||
root = ET.fromstring(msgXml) #xml-字符串形式
|
||||
|
||||
#打开xml文档
|
||||
# current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
# print('current_dir+/planet.xml',current_dir+'\planet.xml')
|
||||
# tree = ET.parse(current_dir+'\planet.xml')
|
||||
# root = tree.getroot()
|
||||
|
||||
# 微信好友的wxid
|
||||
# wxid='wxid_w2imh7ki5s4q12'
|
||||
for pagepath in root.iter('pagepath'):
|
||||
print(pagepath.text) # 打印名字
|
||||
pagepath.text = pagepath.text + f'?wxid={wxid}'
|
||||
print('修改path', pagepath.text) # 打印名字
|
||||
|
||||
# 修改后的xml转成string , method='xml'
|
||||
msgXml = ET.tostring(root, encoding='utf-8').decode('utf-8')
|
||||
WXBotService.send_xml_message(account_wxid, wxid, msgXml)
|
||||
Reference in New Issue
Block a user