koishi-plugin-satori-ai 1.2.7 → 1.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/game.d.ts +2 -1
- package/lib/gamegobang.d.ts +1 -0
- package/lib/index.js +13 -7
- package/package.json +1 -1
package/lib/game.d.ts
CHANGED
|
@@ -9,7 +9,8 @@ export declare class Game {
|
|
|
9
9
|
private availableGames;
|
|
10
10
|
private context;
|
|
11
11
|
private config;
|
|
12
|
-
|
|
12
|
+
private sat;
|
|
13
|
+
constructor(ctx: Context, cfg: Sat.Config, sat: Sat);
|
|
13
14
|
private registerCommands;
|
|
14
15
|
startGame(session: Session, gameName: string, args: string[]): Promise<"当前频道已经有游戏在进行中" | "没有这个游戏哦">;
|
|
15
16
|
endGame(session: Session): Promise<string>;
|
package/lib/gamegobang.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -135,8 +135,8 @@ function processPrompt(prompt) {
|
|
|
135
135
|
return "";
|
|
136
136
|
if (prompt.includes(":poke"))
|
|
137
137
|
return "戳戳";
|
|
138
|
+
prompt = prompt.replace(/<[^>]*?avatar[^>]*>/g, "。回复:");
|
|
138
139
|
prompt = prompt.replace(/<[^>]*?img[^>]*>/g, "[图片]");
|
|
139
|
-
prompt = prompt.replace(/<[^>]*?avatar[^>]*>/g, "");
|
|
140
140
|
prompt = prompt.replace(/<[^>]*?name="([^\"]*)"[^>]*>/g, (_, name) => `@${name}`);
|
|
141
141
|
return prompt;
|
|
142
142
|
}
|
|
@@ -498,7 +498,6 @@ var MemoryManager = class {
|
|
|
498
498
|
if (response.error)
|
|
499
499
|
return;
|
|
500
500
|
this.updateChannelMemory(session, prompt, config, response.content);
|
|
501
|
-
prompt = prompt.replace("我", session.username);
|
|
502
501
|
const date = ` (对话日期和时间:${(/* @__PURE__ */ new Date()).toLocaleString()})`;
|
|
503
502
|
const userFavourbility = (await getUser(this.ctx, session.userId)).favorability;
|
|
504
503
|
if (this.shouldRemember(prompt, userFavourbility)) {
|
|
@@ -1162,7 +1161,14 @@ var UserPortraitManager = class {
|
|
|
1162
1161
|
if (!fs5.existsSync(memoryPath))
|
|
1163
1162
|
return [];
|
|
1164
1163
|
const memoryContent = JSON.parse(fs5.readFileSync(memoryPath, "utf-8"));
|
|
1165
|
-
const
|
|
1164
|
+
const replacedContent = memoryContent.map((entry) => {
|
|
1165
|
+
return {
|
|
1166
|
+
...entry,
|
|
1167
|
+
content: entry.content.replace(user.usersname, "我")
|
|
1168
|
+
};
|
|
1169
|
+
});
|
|
1170
|
+
fs5.writeFileSync(memoryPath, JSON.stringify(replacedContent, null, 2));
|
|
1171
|
+
const validEntries = replacedContent.filter((entry) => entry.role !== "user").map((entry) => {
|
|
1166
1172
|
const timeMatch = entry.role.match(/对话日期和时间:(\d{4}\/\d{1,2}\/\d{1,2} \d{2}:\d{2}:\d{2})/);
|
|
1167
1173
|
if (!timeMatch)
|
|
1168
1174
|
return null;
|
|
@@ -1417,12 +1423,12 @@ var SAT = class extends Sat {
|
|
|
1417
1423
|
const favorabilityBlock = await this.checkFavorabilityBlock(session);
|
|
1418
1424
|
if (favorabilityBlock)
|
|
1419
1425
|
return favorabilityBlock;
|
|
1420
|
-
const preCheckResult = this.performPreChecks(session,
|
|
1426
|
+
const preCheckResult = this.performPreChecks(session, processedPrompt);
|
|
1421
1427
|
if (preCheckResult)
|
|
1422
1428
|
return preCheckResult;
|
|
1423
1429
|
const channelId = this.config.enable_self_memory ? session.userId : session.channelId;
|
|
1424
1430
|
const recentDialogues = this.memoryManager.getChannelMemory(channelId).slice(-10);
|
|
1425
|
-
const duplicateCheck = await this.checkDuplicateDialogue(session,
|
|
1431
|
+
const duplicateCheck = await this.checkDuplicateDialogue(session, processedPrompt, recentDialogues, user);
|
|
1426
1432
|
if (duplicateCheck)
|
|
1427
1433
|
return duplicateCheck;
|
|
1428
1434
|
const fixedResponse = await this.handleFixedDialoguesCheck(session, user, processedPrompt);
|
|
@@ -1579,7 +1585,7 @@ var SAT = class extends Sat {
|
|
|
1579
1585
|
}
|
|
1580
1586
|
const userMemory = this.memoryManager.getChannelContext(this.config.personal_memory ? session.userId : session.channelId);
|
|
1581
1587
|
messages.push(...userMemory);
|
|
1582
|
-
if (this.config.input_prompt && messages.length >
|
|
1588
|
+
if (this.config.input_prompt && messages.length > 1) {
|
|
1583
1589
|
messages.push({ role: "user", content: "system:" + this.config.input_prompt });
|
|
1584
1590
|
messages.push({ role: "assistant", content: "好的,我会按您的要求进行回复。" });
|
|
1585
1591
|
}
|
|
@@ -1679,7 +1685,7 @@ ${payload}`);
|
|
|
1679
1685
|
async handleUserLevel(session, options) {
|
|
1680
1686
|
const userId = options.id || session.userId;
|
|
1681
1687
|
const user = await ensureUserExists(this.ctx, userId, session.username);
|
|
1682
|
-
const level = options.level || user.userlevel > 1 ? user.userlevel : 1;
|
|
1688
|
+
const level = options.level || (user.userlevel > 1 ? user.userlevel : 1);
|
|
1683
1689
|
const enableUserKey = user?.items?.["地灵殿通行证"]?.description && user.items["地灵殿通行证"].description == "on";
|
|
1684
1690
|
if (enableUserKey || level > 3)
|
|
1685
1691
|
await this.portraitManager.generatePortrait(session, user, this.apiClient);
|