39 lines
1.2 KiB
Python
39 lines
1.2 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_add/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)
|
|
|
|
# 创建包含用户昵称、时间和Emoji表情的字符串
|
|
welcome_message = f"🎉 欢迎用户 {nick_name} \n👋 在 {now_time} 🕒 加入群聊!😊"
|
|
|
|
self.wcf.send_text(welcome_message, (message.roomid if message.from_group() else message.sender),
|
|
message.sender)
|