koishi-plugin-chatluna-affinity 0.3.0-alpha.2 → 0.3.0-alpha.3
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/index.d.ts +1 -1
- package/lib/index.js +42 -26
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -1764,6 +1764,6 @@ declare function callOneBotAPI(internal: OneBotInternal, action: string, params:
|
|
|
1764
1764
|
* 导出插件元信息和 apply 函数
|
|
1765
1765
|
*/
|
|
1766
1766
|
|
|
1767
|
-
declare const usage = "\n## \u66F4\u65B0\u65E5\u5FD7\n\n0.3.0-alpha
|
|
1767
|
+
declare const usage = "\n## \u66F4\u65B0\u65E5\u5FD7\n\n0.3.0-alpha\n\n### \u91CD\u6784\n- \u5F15\u5165 `scopeId` \u4F5C\u4E3A\u65B0\u7684\u6838\u5FC3\u4F5C\u7528\u57DF\u8BED\u4E49\uFF1B\u6570\u636E\u9694\u79BB\u4ECE\u65E7\u7248\u6309 bot / \u65E7\u4E3B\u952E\u5207\u6362\u4E3A\u6309 `scopeId` \u9694\u79BB\u3002\n- \u5355\u4E2A\u5B9E\u4F8B\u5185\u7684\u591A\u4E2A bot \u73B0\u5728\u5171\u4EAB\u540C\u4E00\u4EFD `scopeId` \u6570\u636E\uFF1B\u5171\u4EAB\u8303\u56F4\u8986\u76D6\u597D\u611F\u5EA6\u3001\u9ED1\u540D\u5355\u3001\u7279\u6B8A\u5173\u7CFB\u4E0E\u6635\u79F0\u3002\n- \u6570\u636E\u5E93\u6A21\u578B\u5347\u7EA7\u4E3A v2\uFF1A\n - `chatluna_affinity` -> `chatluna_affinity_v2`\n - `chatluna_blacklist` -> `chatluna_blacklist_v2`\n - `chatluna_user_alias` -> `chatluna_user_alias_v2`\n- \u65B0\u589E\u6570\u636E\u5E93\u8FC1\u79FB\u670D\u52A1\u4E0E\u8FC1\u79FB\u8BB0\u5F55\u8868\uFF0C\u542F\u52A8\u65F6\u4F1A\u81EA\u52A8\u5C06\u65E7\u8868\u8FC1\u79FB\u5230 v2 \u7ED3\u6784\u3002\n- \u597D\u611F\u5EA6\u3001\u9ED1\u540D\u5355\u4E0E\u6A21\u578B\u54CD\u5E94\u5904\u7406\u94FE\u8DEF\u91CD\u6784\u4E3A\u66F4\u6E05\u6670\u7684\u670D\u52A1\u5316\u7ED3\u6784\u3002\n\n### \u65B0\u589E\n- \u65B0\u589E `scopeId` \u914D\u7F6E\uFF1B\u5F53\u524D\u7248\u672C\u6309 `scopeId` \u533A\u5206\u6570\u636E\uFF0C\u4E0D\u540C\u5B9E\u4F8B\u4E4B\u95F4\u5B8C\u5168\u9694\u79BB\u3002\n- \u65B0\u589E `botSelfIds` \u914D\u7F6E\uFF0C\u7528\u4E8E\u58F0\u660E\u54EA\u4E9B bot \u5F52\u5C5E\u5F53\u524D `scopeId`\uFF1B\u540C\u4E00 `scopeId` \u4E0B\u591A\u4E2A bot \u5171\u4EAB\u6570\u636E\uFF0C\u7528\u4E8E\u9996\u6B21\u4E92\u52A8\u521D\u59CB\u5316\u597D\u611F\u5EA6\u3002\n- \u65B0\u589E\u4F5C\u7528\u57DF\u5316\u547D\u4EE4\u524D\u7F00\uFF0C\u547D\u4EE4\u7531\u56FA\u5B9A `affinity.*` \u6539\u4E3A `${scopeId}.*`\u3002\n- \u65B0\u589E\u6C38\u4E45\u9ED1\u540D\u5355\u89E3\u9664\u540E\u7684\u597D\u611F\u5EA6\u91CD\u7F6E\u903B\u8F91\uFF1B\u89E3\u9664\u540E\u4F1A\u540C\u65F6\u91CD\u7F6E\u597D\u611F\u5EA6\u76F8\u5173\u72B6\u6001\u3002\n- \u65B0\u589E\u4F5C\u7528\u57DF\u5316\u53D8\u91CF\u8C03\u7528\u8981\u6C42\uFF0C\u53D8\u91CF\u73B0\u5728\u9700\u8981\u663E\u5F0F\u4F20\u5165 `scopeId`\u3002\n\n### \u4FEE\u6539\n- \u597D\u611F\u5EA6\u3001\u9ED1\u540D\u5355\u3001\u6635\u79F0\u6570\u636E\u7684\u5199\u5165\u4E0E\u8BFB\u53D6\u4E3B\u952E\u8BED\u4E49\u6539\u4E3A\u4EE5 `scopeId` \u4E3A\u6838\u5FC3\uFF1A\n - \u597D\u611F\u5EA6\uFF1A`scopeId + userId`\n - \u9ED1\u540D\u5355\uFF1A`scopeId + userId + mode`\n - \u7528\u6237\u6635\u79F0\uFF1A`scopeId + userId`\n- \u591A bot \u5171\u4EAB\u65B9\u6848\u4ECE\u65E7\u7248\u5206\u7EC4\u914D\u7F6E\u6539\u4E3A\u7EDF\u4E00\u7684 `scopeId` \u8BED\u4E49\u3002\n- \u597D\u611F\u5EA6\u521D\u59CB\u5316\u65F6\u673A\u6539\u4E3A\u201C\u4E0E bot \u9996\u6B21\u6709\u6548\u4EA4\u4E92\u65F6\u5165\u5E93\u201D\uFF0C\u4E0D\u518D\u5728\u6536\u5230\u6D88\u606F\u65F6\u63D0\u524D\u521D\u59CB\u5316\u3002\n- \u968F\u673A\u521D\u59CB\u597D\u611F\u5EA6\u6539\u4E3A\u56FA\u5B9A\u521D\u59CB\u597D\u611F\u5EA6\uFF0C\u9ED8\u8BA4\u503C\u4E3A `30`\u3002\n- `userAlias` \u7684\u6635\u79F0\u4FE1\u606F\u5DF2\u878D\u5165 `affinity` \u53D8\u91CF\u8F93\u51FA\uFF1B\u5F53\u524D\u8F93\u51FA\u5F62\u6001\u4E3A `id name nickname affinity relationship`\u3002\n- \u5BF9\u4E8E\u5C1A\u672A\u4E0E bot \u4EA7\u751F\u6709\u6548\u4E92\u52A8\u7684\u7528\u6237\uFF0C`affinity` \u53D8\u91CF\u73B0\u5728\u4F1A\u76F4\u63A5\u663E\u793A\u9ED8\u8BA4\u597D\u611F\u5EA6\uFF0C\u4EE5\u53CA\u8BE5\u9ED8\u8BA4\u503C\u5BF9\u5E94\u7684\u5173\u7CFB\u3002\n- \u5173\u7CFB\u533A\u95F4\u53D8\u91CF\u540D\u7531 `relationshipAffinityLevel` \u7B80\u5316\u4E3A `relationshipLevel`\u3002\n- \u6240\u6709\u53D8\u91CF\u73B0\u5728\u90FD\u9700\u8981\u663E\u5F0F\u4F20\u5165 `scopeId`\uFF0C\u4F8B\u5982\uFF1A\n - `relationshipLevel(scopeId)`\n - `affinity(scopeId)`\n - `blacklistList(scopeId)`\n- XML \u5DE5\u5177\u8C03\u7528\u53C2\u6570\u6539\u4E3A\u663E\u5F0F\u4F5C\u7528\u57DF\u98CE\u683C\uFF0C\u6838\u5FC3\u5B57\u6BB5\u7EDF\u4E00\u4E3A `scopeId + userId`\u3002\n- `scopeId` \u4F1A\u76F4\u63A5\u4F5C\u4E3A\u6307\u4EE4\u524D\u7F00\uFF1B\u4E0D\u8981\u4F7F\u7528\u4E0E bot \u540D\u79F0\u76F8\u540C\u7684 `scopeId`\uFF0C\u5EFA\u8BAE\u4F18\u5148\u4F7F\u7528\u82F1\u6587\u3002\n- \u65E5\u7A0B\u3001\u5929\u6C14\u80FD\u529B\u62C6\u5206\u81F3 `koishi-plugin-chatluna-schedule`\u3002\n- \u66F4\u591A\u53D8\u91CF\u4E0E XML \u5DE5\u5177\u80FD\u529B\u62C6\u5206\u81F3 `koishi-plugin-chatluna-toolbox`\u3002\n\n### \u5220\u9664\n- \u5220\u9664 ChatLuna \u539F\u751F\u5DE5\u5177\u6CE8\u518C\u80FD\u529B\uFF0C\u5F53\u524D\u7248\u672C\u4E0D\u518D\u63D0\u4F9B\u539F\u751F\u5DE5\u5177\u3002\n- \u5220\u9664\u65E7\u7248 `affinityGroups` \u5171\u4EAB\u5206\u7EC4\u914D\u7F6E\u3002\n- \u5220\u9664\u56FA\u5B9A\u547D\u4EE4\u524D\u7F00 `affinity.*` \u7684\u547D\u540D\u65B9\u5F0F\u3002\n- \u5220\u9664 `relationshipAffinityLevel` \u65E7\u547D\u540D\u3002\n- \u5220\u9664\u4EE5\u4E0B\u52A8\u6001\u914D\u7F6E\u9879\uFF1A\n - \u5355\u6B21\u589E\u52A0\u7684\u77ED\u671F\u597D\u611F\u6700\u5927\u5E45\u5EA6\n - \u5355\u6B21\u51CF\u5C11\u7684\u77ED\u671F\u597D\u611F\u6700\u5927\u5E45\u5EA6\n - \u5141\u8BB8\u989D\u5916\u589E\u51CF\u7A81\u7834\u5355\u6B21\u4E0A\u9650\n- `userAlias` \u4E0D\u518D\u4F5C\u4E3A\u72EC\u7ACB\u53D8\u91CF\u66B4\u9732\uFF1B\u6635\u79F0\u80FD\u529B\u4FDD\u7559\u5728 XML \u4E0E `affinity` \u53D8\u91CF\u8F93\u51FA\u4E2D\u3002\n\n### \u517C\u5BB9\u6027\u63D0\u9192\n- \u8FD9\u662F\u4E00\u6B21\u5E26\u6709\u7834\u574F\u6027\u517C\u5BB9\u53D8\u66F4\u7684\u91CD\u6784\u5347\u7EA7\uFF1B\u65E7\u547D\u4EE4\u3001\u65E7 XML \u53C2\u6570\u548C\u65E7\u53D8\u91CF\u8C03\u7528\u65B9\u5F0F\u90FD\u9700\u8981\u540C\u6B65\u8C03\u6574\u3002\n- \u8FC1\u79FB\u4F1A\u628A\u65E7\u6570\u636E\u6574\u4F53\u5F52\u5165\u5F53\u524D\u5B9E\u4F8B\u7684 `scopeId`\uFF0C\u4E0D\u4F1A\u81EA\u52A8\u62C6\u5206\u4E3A\u591A\u4E2A\u4F5C\u7528\u57DF\u3002\n";
|
|
1768
1768
|
|
|
1769
1769
|
export { ACTION_WINDOW_DEFAULTS, AFFINITY_DEFAULTS, ALL_MEMBER_INFO_ITEMS, type ActionCounts, type ActionEntry, type ActionStats, type ActionType, type ActionWindowConfig, type AffinityCache, type AffinityDynamicsConfig, type AffinityProvider, type AffinityProviderDeps, type AffinityRecord, AffinitySchema, type AffinityState, type AffinityStore, type AffinityStoreOptions, type ApplyAffinityDeltaParams, type ApplyAffinityDeltaResult, BASE_AFFINITY_DEFAULTS, BLACKLIST_MODEL_NAME, BLACKLIST_MODEL_NAME_V2, BLACKLIST_REPLY_TEMPLATE, type BlacklistCommandDeps, type BlacklistDetail, type BlacklistEnrichedItem, type BlacklistEntry, type BlacklistGuard, type BlacklistGuardOptions, type BlacklistItem, type BlacklistListProvider, type BlacklistListProviderDeps, type BlacklistMode, type BlacklistRecord, type BlacklistRenderer, BlacklistSchema, type BlacklistService, type BlacklistServiceOptions, type BlockCommandDeps, CLOUD_TYPES, COEFFICIENT_DEFAULTS, COMMON_STYLE, type CharacterTempModelResponseRuntime, type CharacterTempModelResponseRuntimeParams, type ClampFn, type CoefficientConfig, type CoefficientResult, type CoefficientState, type CombinedState, type CommandDependencies, ConfigSchema as Config, ConfigSchema, DEFAULT_MEMBER_INFO_ITEMS, type Element, FETCH_CONSTANTS, type HistoryEntry, type InMemoryTemporaryEntry, type InitialRange, type InspectData, type InspectRenderer, type LegacyAffinityRecord, type LegacyBlacklistRecord, type LegacyUserAliasRecord, type LevelResolver, type LogFn, type LogLevel, MIGRATION_MODEL_NAME, MODEL_NAME, MODEL_NAME_V2, type ManualConfigOptions, type ManualRelationship, type ManualRelationshipManager, type MemberInfo, type MemberInfoField, type MessageHistory, type MessageHistoryOptions, type MessageStore, type MessageStoreOptions, type MigrationOptions, type MigrationRecord, type ModelResponseContext, type ModelResponseProcessorParams, type OneBotInternal, type OneBotProtocol, OtherSettingsSchema, type Page, type Puppeteer, RENDER_CONSTANTS, ROLE_MAPPING, type RankItem, type RankLineItem, type RankListRenderer, type RelationshipLevel, type RelationshipLevelProvider, type RelationshipLevelProviderDeps, RelationshipSchema, type RenderMemberInfoOptions, type RenderOptions, type RenderService, type RenderServiceOptions, type ResolvedActionWindowConfig, type ResolvedCoefficientConfig, type ResolvedShortTermConfig, type RoleMapping, type RoleTranslation, SHORT_TERM_DEFAULTS, type SaveExtra, type SessionSeed, type ShortTermConfig, type StoredMessage, type SummarizedActions, THRESHOLDS, TIME_CONSTANTS, TIMING_CONSTANTS, type TableRenderOptions, type TableRenderer, type TempBlockCommandDeps, type TemporaryBlacklistEntry, USER_ALIAS_MODEL_NAME, USER_ALIAS_MODEL_NAME_V2, type UnblockPermanentDeps, type UnblockPermanentInput, type UnblockPermanentResult, type UserAliasRecord, type UserAliasService, type UserAliasServiceOptions, type VariableSettings, type XmlToolSettings, appendActionEntry, apply, applyAffinityDelta, assertScopeId, buildScopedCommandName, callOneBotAPI, clamp, clampFloat, collectNicknameCandidates, collectRoleCandidates, composeState, computeCoefficientValue, computeDailyStreak, computeShortTermReset, createAffinityCache, createAffinityProvider, createAffinityStore, createBlacklistGuard, createBlacklistListProvider, createBlacklistRenderer, createBlacklistService, createCharacterTempModelResponseRuntime, createInspectRenderer, createLevelResolver, createLogger, createManualRelationshipManager, createMessageHistory, createMessageStore, createMigrationService, createModelResponseProcessor, createPermanentUnblockHandler, createRankListRenderer, createRelationshipLevelProvider, createRenderService, createTableRenderer, createUserAliasService, dayNumber, ensureOneBotSession, escapeHtml, escapeHtmlForRender, extendAffinityModel, extendBlacklistModel, extendMigrationModel, extendUserAliasModel, fetchGroupMemberIds, fetchMember, findMemberByName, formatActionCounts, formatBeijingTimestamp, formatDateOnly, formatDateTime, formatTimestamp, getChannelId, getDateString, getGuildId, getPlatform, getPuppeteer, getRoleDisplay, getSelfId, getTimeString, getUserId, inject, isFiniteNumber, isValidScopeId, makeUserKey, name, normalizeScopeId, normalizeTimestamp, parseSelfClosingXmlTags, pickFirst, registerAdjustCommand, registerBlacklistCommand, registerBlockCommand, registerClearAllCommand, registerInspectCommand, registerModels, registerRankCommand, registerTempBlockCommand, renderHtml, renderInfoField, renderMemberInfo, renderTemplate, resolveActionWindowConfig, resolveBotInfo, resolveCoefficientConfig, resolveGroupId, resolveRoleLabel, resolveScopedVariableArgs, resolveShortTermConfig, resolveUserIdentity, resolveUserInfo, resolveXmlScopeId, roundTo, sanitizeChannel, stripAtPrefix, summarizeActionEntries, toDate, translateGender, translateRole, truncate, usage };
|
package/lib/index.js
CHANGED
|
@@ -3142,42 +3142,58 @@ function createMigrationService(options) {
|
|
|
3142
3142
|
const markSkipped = async () => {
|
|
3143
3143
|
await markMigration("skipped");
|
|
3144
3144
|
};
|
|
3145
|
-
const
|
|
3145
|
+
const filterMissingRows = async (params) => {
|
|
3146
3146
|
const legacyRows = await ctx.database.get(
|
|
3147
|
-
|
|
3147
|
+
params.legacyModel,
|
|
3148
3148
|
{}
|
|
3149
3149
|
);
|
|
3150
|
-
if (legacyRows.length === 0) return
|
|
3151
|
-
const
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
})
|
|
3150
|
+
if (legacyRows.length === 0) return [];
|
|
3151
|
+
const nextRows = legacyRows.map(params.toNextRow);
|
|
3152
|
+
const existingRows = await ctx.database.get(params.nextModel, {
|
|
3153
|
+
scopeId
|
|
3154
|
+
});
|
|
3155
|
+
const existingKeys = new Set(existingRows.map(params.getKey));
|
|
3156
|
+
return nextRows.filter((row) => !existingKeys.has(params.getKey(row)));
|
|
3157
|
+
};
|
|
3158
|
+
const migrateAffinity = async () => {
|
|
3159
|
+
const rows = await filterMissingRows({
|
|
3160
|
+
legacyModel: MODEL_NAME,
|
|
3161
|
+
nextModel: MODEL_NAME_V2,
|
|
3162
|
+
toNextRow: (row) => ({
|
|
3163
|
+
scopeId,
|
|
3164
|
+
...row
|
|
3165
|
+
}),
|
|
3166
|
+
getKey: (row) => `${row.scopeId}:${row.userId}`
|
|
3167
|
+
});
|
|
3168
|
+
if (rows.length === 0) return 0;
|
|
3155
3169
|
await ctx.database.upsert(MODEL_NAME_V2, rows);
|
|
3156
3170
|
return rows.length;
|
|
3157
3171
|
};
|
|
3158
3172
|
const migrateBlacklist = async () => {
|
|
3159
|
-
const
|
|
3160
|
-
BLACKLIST_MODEL_NAME,
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
})
|
|
3173
|
+
const rows = await filterMissingRows({
|
|
3174
|
+
legacyModel: BLACKLIST_MODEL_NAME,
|
|
3175
|
+
nextModel: BLACKLIST_MODEL_NAME_V2,
|
|
3176
|
+
toNextRow: (row) => ({
|
|
3177
|
+
scopeId,
|
|
3178
|
+
...row
|
|
3179
|
+
}),
|
|
3180
|
+
getKey: (row) => `${row.scopeId}:${row.userId}:${row.mode}`
|
|
3181
|
+
});
|
|
3182
|
+
if (rows.length === 0) return 0;
|
|
3168
3183
|
await ctx.database.upsert(BLACKLIST_MODEL_NAME_V2, rows);
|
|
3169
3184
|
return rows.length;
|
|
3170
3185
|
};
|
|
3171
3186
|
const migrateUserAlias = async () => {
|
|
3172
|
-
const
|
|
3173
|
-
USER_ALIAS_MODEL_NAME,
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
})
|
|
3187
|
+
const rows = await filterMissingRows({
|
|
3188
|
+
legacyModel: USER_ALIAS_MODEL_NAME,
|
|
3189
|
+
nextModel: USER_ALIAS_MODEL_NAME_V2,
|
|
3190
|
+
toNextRow: (row) => ({
|
|
3191
|
+
scopeId,
|
|
3192
|
+
...row
|
|
3193
|
+
}),
|
|
3194
|
+
getKey: (row) => `${row.scopeId}:${row.userId}`
|
|
3195
|
+
});
|
|
3196
|
+
if (rows.length === 0) return 0;
|
|
3181
3197
|
await ctx.database.upsert(USER_ALIAS_MODEL_NAME_V2, rows);
|
|
3182
3198
|
return rows.length;
|
|
3183
3199
|
};
|
|
@@ -5038,7 +5054,7 @@ async function callOneBotAPI(internal, action, params, fallbacks = []) {
|
|
|
5038
5054
|
var usage = `
|
|
5039
5055
|
## \u66F4\u65B0\u65E5\u5FD7
|
|
5040
5056
|
|
|
5041
|
-
0.3.0-alpha
|
|
5057
|
+
0.3.0-alpha
|
|
5042
5058
|
|
|
5043
5059
|
### \u91CD\u6784
|
|
5044
5060
|
- \u5F15\u5165 \`scopeId\` \u4F5C\u4E3A\u65B0\u7684\u6838\u5FC3\u4F5C\u7528\u57DF\u8BED\u4E49\uFF1B\u6570\u636E\u9694\u79BB\u4ECE\u65E7\u7248\u6309 bot / \u65E7\u4E3B\u952E\u5207\u6362\u4E3A\u6309 \`scopeId\` \u9694\u79BB\u3002
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-chatluna-affinity",
|
|
3
3
|
"description": "ChatLuna Character 好感度系统,提供 {好感度}、{关系}、{黑名单} 变量与工具,并支持 XML 工具调用,仅支持 onebot 平台。",
|
|
4
|
-
"version": "0.3.0-alpha.
|
|
4
|
+
"version": "0.3.0-alpha.3",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|