91 lines
3.0 KiB
Python
91 lines
3.0 KiB
Python
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"""
|
|
<?xml version="1.0"?>
|
|
<msg>
|
|
<appmsg appid="" sdkver="1">
|
|
<title>👏欢迎 {nick_name} 加入群聊!🎉</title>
|
|
<des>⌚时间:{now_time}</des>
|
|
<action>view</action>
|
|
<type>5</type>
|
|
<showtype>0</showtype>
|
|
<content />
|
|
<url>{url}</url>
|
|
<dataurl />
|
|
<lowurl />
|
|
<lowdataurl />
|
|
<recorditem />
|
|
<thumburl>{BigHeadImgUrl}</thumburl>
|
|
<messageaction />
|
|
<laninfo />
|
|
<extinfo />
|
|
<sourceusername />
|
|
<sourcedisplayname />
|
|
<commenturl />
|
|
<appattach>
|
|
<totallen>0</totallen>
|
|
<attachid />
|
|
<emoticonmd5 />
|
|
<fileext />
|
|
<aeskey />
|
|
</appattach>
|
|
<webviewshared>
|
|
<publisherId />
|
|
<publisherReqId>0</publisherReqId>
|
|
</webviewshared>
|
|
<weappinfo>
|
|
<pagepath />
|
|
<username />
|
|
<appid />
|
|
<appservicetype>0</appservicetype>
|
|
</weappinfo>
|
|
<websearch />
|
|
</appmsg>
|
|
<fromusername>Jyunere</fromusername>
|
|
<scene>0</scene>
|
|
<appinfo>
|
|
<version>1</version>
|
|
<appname></appname>
|
|
</appinfo>
|
|
<commenturl></commenturl>
|
|
</msg>
|
|
|
|
"""
|