H5邀请
This commit is contained in:
44
main.py
44
main.py
@@ -108,6 +108,37 @@ def read_users(wxid, db: Session = Depends(get_db)):
|
||||
return {"code": 200, "success": "ok", "message": "群聊邀请已发送"}
|
||||
|
||||
|
||||
# 加入微信群
|
||||
@app.get("/h5group")
|
||||
# 群-异度星球 49187487591@chatroom chatroom
|
||||
def h5group(nickname, 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['nickname'] == nickname:
|
||||
inGroup = True
|
||||
if inGroup:
|
||||
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'] == nickname:
|
||||
new_wxid = friendItem['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)
|
||||
return {"code": 200, "success": "ok", "message": "群聊邀请已发送"}
|
||||
|
||||
|
||||
# 创建用户
|
||||
@app.post("/users")
|
||||
# schemas.UserCreate决定了swagger文档
|
||||
@@ -277,10 +308,17 @@ def kp(event_data):
|
||||
# new_wxid='wxid_4413224132412')
|
||||
|
||||
# 发送小程序
|
||||
utils.sendminiProgram(data, account_wxid, wxid, planetXml)
|
||||
# utils.sendminiProgram(data, account_wxid, wxid, planetXml)
|
||||
# H5链接
|
||||
WXBotService.send_link_message(account_wxid, wxid, title="欢迎加入微信群", desc="请查看规则", url="https://link.hackrobot.cn/", pic= "https://www.hackrobot.cn/wp-content/uploads/2023/05/cropped-cropped-Screenshot-2023-05-22-at-17.26.38.png")
|
||||
|
||||
WXBotService.send_link_message(
|
||||
account_wxid,
|
||||
wxid,
|
||||
title="欢迎加入微信群",
|
||||
desc="请查看规则",
|
||||
url=f'https://link.hackrobot.cn?wxid={wxid}',
|
||||
pic=
|
||||
"https://www.hackrobot.cn/wp-content/uploads/2023/05/cropped-cropped-Screenshot-2023-05-22-at-17.26.38.png"
|
||||
)
|
||||
|
||||
# if msg in ['腾讯云']:
|
||||
# # 发送小程序
|
||||
|
||||
Reference in New Issue
Block a user