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

View File

@@ -2,6 +2,7 @@
import re
import logging
import xml.etree.ElementTree as ET
class BaseRobot(object):
@@ -72,5 +73,15 @@ class BaseRobot(object):
contacts = self.sdk.WxExecDbQuery("MicroMsg.db", "SELECT UserName, NickName FROM Contact;")
return {contact["UserName"]: contact["NickName"] for contact in contacts}
def autoAcceptFriendRequest(self, msg):
try:
xml = ET.fromstring(msg.content)
v3 = xml.attrib["encryptusername"]
v4 = xml.attrib["ticket"]
self.sdk.WxAcceptNewFriend(v3, v4)
except Exception as e:
self.LOG.error(f"同意好友出错:{e}")
def processMsg(self, msg) -> None:
raise NotImplementedError("Method [processMsg] should be implemented.")