Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/LSTM-Kirigaya/LBot --skill history-message명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
SKILL.md 표시 중
SOC 직업 분류 기준
| name | history-message |
| description | 历史消息搜索功能。支持关键词搜索群聊和好友的历史消息记录。 |
提供类似于搜索引擎的历史消息搜索功能,可根据关键词查找包含该关键词的历史消息及发送者信息。
搜索群聊历史消息(推荐 AI 使用此方法)。
参数:
groupId: number - 群组 IDkeywords: string - 搜索关键词(支持多个,空格分隔)limit: number - 返回结果数量,默认 20返回: JSON 字符串,需 JSON.parse 解析
{ success: true, message: string, results: [{ sender, time, content }] }{ success: false, error: string }底层函数,搜索群聊历史消息。
参数:
context: LagrangeContext - 上下文对象options:
keywords: string - 搜索关键词groupId: number - 群组 IDmaxMessages: number - 最大搜索消息数,默认 500limit: number - 返回结果数量,默认 20caseSensitive: boolean - 是否区分大小写,默认 falsematchWholeWord: boolean - 是否匹配完整单词,默认 false返回: HistoryMessageResult[] 数组
底层函数,搜索好友历史消息。
参数:
context: LagrangeContext - 上下文对象options:
keywords: string - 搜索关键词userId: number - 好友 QQ 号maxMessages: number - 最大搜索消息数,默认 500limit: number - 返回结果数量,默认 20返回: HistoryMessageResult[] 数组
获取历史消息时,必须对 message 字段进行类型检查:
const res = await context.getGroupMsgHistory({ group_id: groupId, count: 20 });
const messages = res?.data?.messages ?? [];
// 正确解析消息段数组
for (const msg of messages) {
let content = '';
if (typeof msg.message === 'string') {
content = msg.message;
} else if (Array.isArray(msg.message)) {
content = msg.message
.filter(s => s.type === 'text')
.map(s => s.data?.text || '')
.join('');
}
}
// 搜索群聊中包含"放假"关键词的历史消息
const searchResult = await util.searchHistoryMessages(groupId, "放假", 10);
const result = JSON.parse(searchResult);
if (result.success && result.results.length > 0) {
// 格式化输出搜索结果
const summary = result.results
.slice(0, 5)
.map(r => `${r.sender} 在 ${r.time}: ${r.content}`)
.join('\n');
await context.sendGroupMsg(groupId, `找到 ${result.results.length} 条相关消息:\n${summary}`);
} else {
await context.sendGroupMsg(groupId, result.message || "未找到相关消息");
}
// 搜索同时包含"明天"和"会议"的消息(所有关键词必须同时匹配)
const result = await util.searchHistoryMessages(groupId, "明天 会议", 20);
import { searchGroupMsgHistory } from './util/message-search';
const results = await searchGroupMsgHistory(context, {
keywords: "活动",
groupId: groupId,
maxMessages: 300,
limit: 10,
caseSensitive: false,
});
// results 是 HistoryMessageResult[] 数组
// 每项包含:senderId, senderName, time, content, messageId