chore: sync current WechatHookBot workspace
This commit is contained in:
32
plugins/DeerCheckin/config.toml
Normal file
32
plugins/DeerCheckin/config.toml
Normal file
@@ -0,0 +1,32 @@
|
||||
# 鹿打卡插件配置
|
||||
|
||||
[behavior]
|
||||
# 功能配置
|
||||
enabled = true # 是否启用插件
|
||||
enable_group = true # 是否在群聊中启用
|
||||
enable_private = true # 是否在私聊中启用
|
||||
|
||||
# 群聊过滤配置(可选)
|
||||
enabled_groups = [ # 启用的群聊列表(留空表示所有群可用)
|
||||
# "48712602520@chatroom", # 示例群聊ID
|
||||
]
|
||||
disabled_groups = [ # 禁用的群聊列表
|
||||
# "disabled_group@chatroom", # 示例禁用群聊
|
||||
]
|
||||
|
||||
[display]
|
||||
# 显示配置
|
||||
calendar_width = 700 # 日历图片宽度
|
||||
calendar_height = 620 # 日历图片高度
|
||||
use_custom_font = true # 是否使用自定义字体
|
||||
font_file = "font.ttf" # 字体文件名(放在resources目录下)
|
||||
|
||||
[colors]
|
||||
# 颜色配置(RGB值)
|
||||
background = [255, 255, 255] # 背景色
|
||||
header = [50, 50, 50] # 标题颜色
|
||||
weekday = [100, 100, 100] # 星期标题颜色
|
||||
day = [80, 80, 80] # 日期颜色
|
||||
today_bg = [240, 240, 255] # 今天的背景色
|
||||
checkin_mark = [0, 150, 50] # 打卡标记颜色
|
||||
deer_count = [139, 69, 19] # 鹿数量颜色
|
||||
@@ -24,6 +24,7 @@ except ImportError:
|
||||
|
||||
from utils.plugin_base import PluginBase
|
||||
from utils.decorators import on_text_message
|
||||
from utils.member_info_service import get_member_service
|
||||
from WechatHook import WechatHookClient
|
||||
|
||||
|
||||
@@ -189,14 +190,15 @@ class DeerCheckin(PluginBase):
|
||||
|
||||
async def _handle_checkin(self, bot: WechatHookClient, from_wxid: str, user_id: str, nickname: str, content: str):
|
||||
"""处理打卡"""
|
||||
# 获取真实昵称
|
||||
# 获取真实昵称(使用 MemberSync 数据库)
|
||||
if from_wxid.endswith("@chatroom"):
|
||||
try:
|
||||
user_info = await bot.get_user_info_in_chatroom(from_wxid, user_id)
|
||||
if user_info and user_info.get("nickName", {}).get("string"):
|
||||
nickname = user_info["nickName"]["string"]
|
||||
except:
|
||||
pass
|
||||
member_service = get_member_service()
|
||||
member_nickname = await member_service.get_chatroom_member_nickname(from_wxid, user_id)
|
||||
if member_nickname:
|
||||
nickname = member_nickname
|
||||
except Exception as e:
|
||||
logger.debug(f"[DeerCheckin] 获取昵称失败: {e}")
|
||||
|
||||
deer_count = content.count("🦌")
|
||||
today_str = date.today().strftime("%Y-%m-%d")
|
||||
@@ -350,9 +352,8 @@ class DeerCheckin(PluginBase):
|
||||
)
|
||||
|
||||
if image_path:
|
||||
# 发送图片
|
||||
data = {"to_wxid": from_wxid, "file": str(image_path)}
|
||||
await bot._send_data_async(11040, data)
|
||||
# 发送图片 - 使用新的 HTTP API
|
||||
await bot.send_image(from_wxid, str(image_path))
|
||||
|
||||
# 不删除临时文件
|
||||
else:
|
||||
@@ -481,60 +482,9 @@ class DeerCheckin(PluginBase):
|
||||
|
||||
def get_llm_tools(self) -> List[dict]:
|
||||
"""返回LLM工具定义,供AIChat插件调用"""
|
||||
return [
|
||||
{
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "deer_checkin",
|
||||
"description": "仅当用户明确要求“鹿打卡/鹿签到/记录今天的鹿数量”时调用;不要在闲聊、绘图或其他问题中调用。",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"count": {
|
||||
"type": "integer",
|
||||
"description": "鹿的数量,默认为1",
|
||||
"default": 1
|
||||
}
|
||||
},
|
||||
"required": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "view_calendar",
|
||||
"description": "仅当用户明确要求“查看鹿打卡日历/本月打卡记录/打卡日历”时调用。",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {},
|
||||
"required": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "makeup_checkin",
|
||||
"description": "仅当用户明确要求“补签/补打卡某日期”时调用,不要自动触发。",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"day": {
|
||||
"type": "integer",
|
||||
"description": "要补签的日期(1-31)"
|
||||
},
|
||||
"count": {
|
||||
"type": "integer",
|
||||
"description": "补签的鹿数量",
|
||||
"default": 1
|
||||
}
|
||||
},
|
||||
"required": ["day"]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
# 所有工具已移除,因为太容易误触发
|
||||
# 用户可以直接发送🦌表情来触发打卡功能
|
||||
return []
|
||||
|
||||
async def execute_llm_tool(self, tool_name: str, arguments: dict, bot, from_wxid: str) -> dict:
|
||||
"""执行LLM工具调用,供AIChat插件调用"""
|
||||
|
||||
Reference in New Issue
Block a user