feat
This commit is contained in:
25
main.py
25
main.py
@@ -44,7 +44,7 @@ def is_chinese(char):
|
||||
return '\u4e00' <= char <= '\u9fff'
|
||||
|
||||
|
||||
def chatglmApi(msg, data, group, account_wxid, wxid, wx_name):
|
||||
def chatglmApi(msg, data, group, account_wxid, wxid, wx_name, newFriendDict):
|
||||
# 不是自己发的消息
|
||||
if data.get('isSender') != 1:
|
||||
# chaglm api在本地8000端口
|
||||
@@ -108,6 +108,11 @@ def chatglmApi(msg, data, group, account_wxid, wxid, wx_name):
|
||||
from_wxid=wxid,
|
||||
msg=newanswer)
|
||||
else:
|
||||
# 女性不回复
|
||||
if newFriendDict['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,
|
||||
@@ -512,15 +517,14 @@ def kp(event_data):
|
||||
|
||||
kp_log = f'{type_str} 文本消息 内容:{msg}'
|
||||
# 将好友信息=>保存到数据库
|
||||
newFriendDict = WXBotService.get_friend_info(
|
||||
account_wxid, wxid)
|
||||
print('newFriendDict==>',newFriendDict)
|
||||
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)
|
||||
print('newFriendDict222==>', newFriendDict)
|
||||
else:
|
||||
# print('通过nickname查不到wxid')
|
||||
pass
|
||||
@@ -528,7 +532,8 @@ def kp(event_data):
|
||||
# 收到群聊消息
|
||||
if group:
|
||||
# 异度世界交流群2 48357370389@chatroom | 小号群18507867712@chatroom
|
||||
chatglmApi(msg, data, group, account_wxid, wxid, wx_name)
|
||||
chatglmApi(msg, data, group, account_wxid, wxid, wx_name,
|
||||
newFriendDict)
|
||||
else:
|
||||
# pass
|
||||
if msg in ['工具箱']:
|
||||
@@ -536,7 +541,7 @@ def kp(event_data):
|
||||
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))
|
||||
@@ -567,7 +572,11 @@ def kp(event_data):
|
||||
)
|
||||
else:
|
||||
# 回复ai消息
|
||||
chatglmApi(msg, data, group, account_wxid, wxid, wx_name)
|
||||
if newFriendDict['sex'] == "女":
|
||||
pass
|
||||
else:
|
||||
chatglmApi(msg, data, group, account_wxid, wxid,
|
||||
wx_name, newFriendDict)
|
||||
|
||||
# if msg in ['腾讯云']:
|
||||
# # 发送小程序
|
||||
|
||||
Reference in New Issue
Block a user