import logging from datetime import datetime import mysql.connector.pooling import tomllib import redis from wcferry import Wcf, WxMsg from robot_cmd.robot_command import GroupBotManager class GroupAdd: def __init__(self, wcf: Wcf, gbm: GroupBotManager, all_contacts: dict): # 读取配置文件 with open("group_video_man/config.toml", "rb") as f: plugin_config = tomllib.load(f) config = plugin_config["GroupAdd"] self.LOG = logging.getLogger(__name__) self.enable = config["enable"] self.wcf = wcf self.gbm = gbm self.all_contacts = all_contacts self.LOG.info(f"[加群提醒] 组件初始化完成") def handle_message(self, message: WxMsg): if not self.enable: return now_time = str(datetime.now().strftime("%Y-%m-%d %H:%M:%S")) nick_name = self.all_contacts.get(message.sender, message.sender) user_info = self.wcf.query_sql("MicroMsg.db", f"SELECT * FROM Contact WHERE UserName = '{message.sender}';") self.LOG.info(f"GroupAdd contact:{user_info}") BigHeadImgUrl = "" url = "https://hot.imsyy.top/#/" outxml = f""" 👏欢迎 {nick_name} 加入群聊!🎉 ⌚时间:{now_time} view 5 0 {url} {BigHeadImgUrl} 0 0 0 Jyunere 0 1 """