Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/AI/AI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ export interface UserInfo {
export type SessionInfo = GroupInfo | UserInfo;

export class Setting {
static validKeys: (keyof Setting)[] = ['priv', 'standby', 'counter', 'timer', 'prob', 'activeTimeInfo'];
static validKeys: (keyof Setting)[] = ['priv', 'standby', 'counter', 'timer', 'prob', 'activeTimeInfo', 'regexTrigger'];
priv: number;
standby: boolean;
counter: number;
timer: number;
prob: number;
regexTrigger: boolean;
activeTimeInfo: {
start: number;
end: number;
Expand All @@ -43,6 +44,7 @@ export class Setting {
this.counter = -1;
this.timer = -1;
this.prob = -1;
this.regexTrigger = true;
this.activeTimeInfo = {
start: 0,
end: 0,
Expand Down
2 changes: 2 additions & 0 deletions src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ export const aliasMap = {
"rm": "remove",
"lst": "list",
"tk": "token",
"rgx": "regex",
"re": "regex",
"y": "year",
"m": "month",
"lcl": "local",
Expand Down
28 changes: 27 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function main() {
【.ai on】开启AI
【.ai sb】开启待机模式,此时AI将记录聊天内容
【.ai off】关闭AI,此时仍能用正则匹配触发
【.ai rgx】非指令正则触发开关
【.ai fgt】遗忘上下文
【.ai role】角色设定相关
【.ai img】图片相关
Expand Down Expand Up @@ -222,6 +223,7 @@ ${HELPMAP["权限限制"]}`);
计数器模式(c): ${setting.counter > -1 ? `${setting.counter}条` : '关闭'}
计时器模式(t): ${setting.timer > -1 ? `${setting.timer}秒` : '关闭'}
概率模式(p): ${setting.prob > -1 ? `${setting.prob}%` : '关闭'}
非指令正则触发: ${setting.regexTrigger ? '开启' : '关闭'}
活跃时间段: ${(start !== 0 || end !== 0) ? `${Math.floor(start / 60).toString().padStart(2, '0')}:${(start % 60).toString().padStart(2, '0')}至${Math.floor(end / 60).toString().padStart(2, '0')}:${(end % 60).toString().padStart(2, '0')}` : '未设置'}
活跃次数: ${segs > 0 ? segs : '未设置'}
待机模式: ${setting.standby ? '开启' : '关闭'}`);
Expand Down Expand Up @@ -296,6 +298,30 @@ ${HELPMAP["权限限制"]}`);
}
}
}
case 'regex': {
const setting = ai.setting;
const val2 = aliasToCmd(cmdArgs.getArgN(2));
switch (val2) {
case 'on': {
setting.regexTrigger = true;
seal.replyToSender(ctx, msg, '非指令正则触发已开启');
AIManager.saveAI(sid);
return ret;
}
case 'off': {
setting.regexTrigger = false;
seal.replyToSender(ctx, msg, '非指令正则触发已关闭');
AIManager.saveAI(sid);
return ret;
}
default: {
seal.replyToSender(ctx, msg, `非指令正则触发状态:${setting.regexTrigger ? '开启' : '关闭'}
【.ai rgx on】开启非指令正则触发
【.ai rgx off】关闭非指令正则触发`);
return ret;
}
}
}
case 'on': {
const setting = ai.setting;

Expand Down Expand Up @@ -1469,7 +1495,7 @@ ${images.map(img => img.CQCode).join('\n')}`));
ai.context.timer = null;

// 非指令消息触发
if (triggerRegex.test(message)) {
if (ai.setting.regexTrigger && triggerRegex.test(message)) {
const fmtCondition = parseInt(seal.format(ctx, `{${triggerCondition}}`));
if (fmtCondition === 1) {
return ai.handleReceipt(ctx, msg, ai, messageArray)
Expand Down
6 changes: 6 additions & 0 deletions src/privilege.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ export const defaultCmdPriv: CmdPriv = {
clear: { priv: I }
}
},
regex: {
priv: I, args: {
on: { priv: I },
off: { priv: I }
}
},
on: { priv: S },
standby: { priv: I },
off: { priv: I },
Expand Down