aff
This commit is contained in:
15
main.py
15
main.py
@@ -138,7 +138,7 @@ def convert_special_chars_to_emoji(input_string):
|
||||
def transOldemoji(oldEmoji=None):
|
||||
# oldEmoji = "异度世界🤖"
|
||||
original_string = WXBotService.emoji_to_unicode(oldEmoji)
|
||||
print("original_string", original_string)
|
||||
# print("original_string", original_string)
|
||||
# # 全局替换 \\u 为 @emoji=
|
||||
# converted_string = original_string.replace('\\\\u', '@emoji=')
|
||||
# # 在 Unicode 编码后添加 ']'
|
||||
@@ -157,7 +157,7 @@ def transOldemoji(oldEmoji=None):
|
||||
converted_string)
|
||||
converted_string = converted_string.replace('[\\@', '[@')
|
||||
# 输出转换后的字符串
|
||||
print(converted_string)
|
||||
# print(converted_string)
|
||||
return converted_string
|
||||
|
||||
|
||||
@@ -268,17 +268,17 @@ def h5group(nickname, db: Session = Depends(get_db)):
|
||||
# pattern = r'收到([\w\[\]@=\u4e00-\u9fff-]+)的在看'
|
||||
# 处理空白符
|
||||
pattern = r'收到((?:[\w\s\[\]@=\u4e00-\u9fff-]|@\w+)+?)的在看'
|
||||
print("newtext", newtext)
|
||||
print("newtext===>", newtext)
|
||||
|
||||
# 处理emoji转为[@emoji=1f916] 格式
|
||||
newtext = transOldemoji(newtext)
|
||||
print("newtextemoji", newtext)
|
||||
# print("newtextemoji", newtext)
|
||||
|
||||
# 不是 ASCII 字符,则获取该字符的 Unicode 代码点
|
||||
newtext = convert_special_chars_to_emoji(newtext)
|
||||
print("newtextASI", newtext)
|
||||
# print("newtextASI", newtext)
|
||||
matches = re.findall(pattern, newtext)
|
||||
print("matches", matches)
|
||||
# print("matches", matches)
|
||||
matchesString = None
|
||||
if len(matches) > 0:
|
||||
matchesString = matches[0]
|
||||
@@ -297,6 +297,7 @@ def h5group(nickname, db: Session = Depends(get_db)):
|
||||
if groupItem['nickname'] == matchesString:
|
||||
inGroup = True
|
||||
if inGroup:
|
||||
print('已经在群聊中')
|
||||
return {"code": 200, "success": "fail", "message": "已经在群聊中"}
|
||||
else:
|
||||
new_wxid = None
|
||||
@@ -309,7 +310,6 @@ def h5group(nickname, db: Session = Depends(get_db)):
|
||||
# print('通过nickname查不到wxid')
|
||||
pass
|
||||
if new_wxid:
|
||||
|
||||
WXBotService.add_group_members_40_more(
|
||||
robot_wxid=config.account_wxid,
|
||||
from_wxid=config.chatroomId, #异度星球群
|
||||
@@ -326,6 +326,7 @@ def h5group(nickname, db: Session = Depends(get_db)):
|
||||
# msg=f'已收到-[在看]支持,谢谢,请从小程序,点击"立即加入"\n[本消息是机器人自动回复]')
|
||||
return {"code": 200, "success": "ok", "message": "群聊邀请已发送"}
|
||||
else:
|
||||
print('通过nickname查不到wxid')
|
||||
return {
|
||||
"code": 200,
|
||||
"success": "ok",
|
||||
|
||||
Reference in New Issue
Block a user