This commit is contained in:
hackrobot
2024-04-11 09:37:40 +08:00
parent 121fcc094b
commit c664d276cf

View File

@@ -140,15 +140,16 @@ def h5group(nickname, db: Session = Depends(get_db)):
pattern = r'收到(\w+)的在看' pattern = r'收到(\w+)的在看'
print(newtext) print(newtext)
matches = re.findall(pattern, newtext) matches = re.findall(pattern, newtext)
matchesString=matches[0]
if matches: if matches:
print("匹配到的结果:", matches) print("匹配到的结果:", matchesString)
# 判断是否在群中 # 判断是否在群中
inGroup = False inGroup = False
groupList = WXBotService.get_group_members_list( groupList = WXBotService.get_group_members_list(
robot_wxid=config.account_wxid, from_wxid=config.chatroomId) robot_wxid=config.account_wxid, from_wxid=config.chatroomId)
# print('groupList', groupList) # print('groupList', groupList)
for groupItem in groupList['data']: for groupItem in groupList['data']:
if groupItem['nickname'] == matches: if groupItem['nickname'] == matchesString:
inGroup = True inGroup = True
if inGroup: if inGroup:
return {"code": 200, "success": "fail", "message": "已经在群聊中"} return {"code": 200, "success": "fail", "message": "已经在群聊中"}
@@ -156,7 +157,7 @@ def h5group(nickname, db: Session = Depends(get_db)):
new_wxid = None new_wxid = None
allFriend = WXBotService.get_address_list(config.account_wxid) allFriend = WXBotService.get_address_list(config.account_wxid)
for friendItem in allFriend['data']["contactList"]: for friendItem in allFriend['data']["contactList"]:
if friendItem['nickname'] == matches: if friendItem['nickname'] == matchesString:
new_wxid = friendItem['wxid'] new_wxid = friendItem['wxid']
else: else:
# print('通过nickname查不到wxid') # print('通过nickname查不到wxid')