Impl auto accept new friend request

This commit is contained in:
Changhua
2022-09-25 21:38:40 +08:00
parent b8d1e3bafb
commit fc9da9538a
2 changed files with 23 additions and 0 deletions

12
main.py
View File

@@ -1,6 +1,7 @@
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
import re
import time
import robot.sdk.wcferry as WxSDK
@@ -17,12 +18,23 @@ class Robot(BaseRobot):
"""
self.printRawMsg(msg) # 打印信息
# 如果在群里被 @,回复发信人:“收到你的消息了!” 并 @他
if self.isGroupChat(msg): # 是群消息
if self.isAt(msg): # 被@
if msg.roomId in self.config.GROUPS: # 在配置的响应的群列表里
self.sendTextMsg(msg.roomId, "收到你的消息了!", msg.wxId)
# 非群聊信息
elif msg.type == 37: # 好友请求
self.autoAcceptFriendRequest(msg)
elif msg.type == 10000: # 系统信息
nickName = re.findall(r"你已添加了(.*),现在可以开始聊天了。", msg.content)
if nickName:
# 添加了好友,更新好友列表
self.allContacts[msg.wxId] = nickName
def main():
robot = Robot(WxSDK, Config())