koishi-plugin-chat-patch 5.5.0 → 5.6.0
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/client/vue/index.vue +8 -1
- package/client/web/dist/assets/{Chat-DTEsebnY.css → Chat-BXVWj5Bd.css} +1 -1
- package/client/web/dist/assets/{Chat-Clqxn7CB.js → Chat-m4-U5uHa.js} +4 -4
- package/client/web/dist/assets/{MsgBody-C0TKsXhC.js → MsgBody-CzrxyiFO.js} +1 -1
- package/client/web/dist/assets/MsgBody.vue_vue_type_script_setup_true_lang-BBF1uxm6.js +67 -0
- package/client/web/dist/assets/{index-BA37EQGa.js → index-EJ2CcODr.js} +72 -78
- package/client/web/dist/assets/index-X9hFOAza.css +1 -0
- package/client/web/dist/index.html +2 -2
- package/client/web/src/App.vue +7 -0
- package/client/web/src/assets/css/chat.css +6 -4
- package/client/web/src/assets/l10n/zh-CN.po +0 -6
- package/client/web/src/components/History.vue +27 -0
- package/client/web/src/components/MsgBody.vue +18 -9
- package/client/web/src/function/connect.ts +208 -46
- package/client/web/src/function/msg.ts +8 -6
- package/client/web/src/function/option.ts +1 -1
- package/client/web/src/function/satori-model.ts +20 -2
- package/client/web/src/function/satori.ts +64 -0
- package/client/web/src/pages/Chat.vue +0 -4
- package/client/web/src/pages/Friends.vue +7 -9
- package/client/web/src/pages/Messages.vue +6 -7
- package/client/web/src/pages/options/OptDev.vue +1 -25
- package/client/web/src/pages/options/OptFunction.vue +23 -0
- package/client/web/tsconfig.tsbuildinfo +1 -1
- package/dist/index.js +1 -1
- package/dist/style.css +1 -1
- package/lib/bootstrap.d.ts +6 -0
- package/lib/database.d.ts +5 -2
- package/lib/gateway.d.ts +46 -0
- package/lib/index.js +1468 -131
- package/lib/recorder.d.ts +3 -5
- package/lib/satori.d.ts +3 -0
- package/lib/types.d.ts +17 -0
- package/package.json +4 -1
- package/src/bootstrap.ts +5 -10
- package/src/database.ts +745 -662
- package/src/gateway.ts +259 -0
- package/src/index.ts +63 -53
- package/src/recorder.ts +97 -77
- package/src/satori.ts +19 -0
- package/src/server.d.ts +26 -26
- package/src/types.ts +19 -0
- package/client/web/dist/assets/MsgBody.vue_vue_type_script_setup_true_lang-CCdBwlN_.js +0 -67
- package/client/web/dist/assets/index-B71pPwae.css +0 -1
package/lib/recorder.d.ts
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import { Context } from 'koishi';
|
|
2
1
|
import { Config } from './config';
|
|
3
2
|
import { ContactCacheService } from './cache';
|
|
4
3
|
import { ChatDatabase } from './database';
|
|
5
4
|
import { MediaManager } from './media';
|
|
6
5
|
import { PluginLogger } from './logger';
|
|
7
6
|
export declare class Recorder {
|
|
8
|
-
private ctx;
|
|
9
7
|
private config;
|
|
10
8
|
private database;
|
|
11
9
|
private media;
|
|
12
10
|
private contactCache;
|
|
13
11
|
private logger;
|
|
14
|
-
constructor(
|
|
15
|
-
|
|
12
|
+
constructor(config: Config, database: ChatDatabase, media: MediaManager, contactCache: ContactCacheService, logger: PluginLogger);
|
|
13
|
+
handleEvent(body: Record<string, unknown>): Promise<boolean>;
|
|
16
14
|
private isBlocked;
|
|
17
|
-
private
|
|
15
|
+
private handleMessageCreated;
|
|
18
16
|
private handleMessageDeleted;
|
|
19
17
|
private cacheMessageContacts;
|
|
20
18
|
private cacheMessageMedia;
|
package/lib/satori.d.ts
ADDED
package/lib/types.d.ts
CHANGED
|
@@ -3,11 +3,28 @@ export interface SatoriBootstrap {
|
|
|
3
3
|
endpoint: string;
|
|
4
4
|
token: string;
|
|
5
5
|
basePath: string;
|
|
6
|
+
logins: SatoriLoginInfo[];
|
|
6
7
|
blockedPlatforms: Array<{
|
|
7
8
|
platformName: string;
|
|
8
9
|
exactMatch: boolean;
|
|
9
10
|
}>;
|
|
10
11
|
}
|
|
12
|
+
export interface SatoriLoginInfo {
|
|
13
|
+
platform: string;
|
|
14
|
+
selfId: string;
|
|
15
|
+
name: string;
|
|
16
|
+
avatar?: string;
|
|
17
|
+
status: number;
|
|
18
|
+
features?: string[];
|
|
19
|
+
}
|
|
20
|
+
export interface SatoriEventPayload {
|
|
21
|
+
type: string;
|
|
22
|
+
platform: string;
|
|
23
|
+
selfId: string;
|
|
24
|
+
timestamp: number;
|
|
25
|
+
sn: number;
|
|
26
|
+
body: Record<string, unknown>;
|
|
27
|
+
}
|
|
11
28
|
export interface MessageRecord {
|
|
12
29
|
id?: string;
|
|
13
30
|
sequence?: number;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-chat-patch",
|
|
3
3
|
"description": "[<ruby>chat-patch<rp>(</rp><rt>点我预览效果</rt><rp>)</rp></ruby>](https://i0.hdslb.com/bfs/openplatform/71074dfc9e5256fc3333d8bd8478bec1af874046.png) 视奸小插件((bushi( (低性能警告)。手机端适配。灵感来自 chat 插件。",
|
|
4
|
-
"version": "5.
|
|
4
|
+
"version": "5.6.0",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build:web": "npm --prefix client/web run build",
|
|
7
7
|
"prepack": "npm run build:web",
|
|
@@ -49,8 +49,11 @@
|
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@element-plus/icons-vue": "^2.3.2",
|
|
51
51
|
"@koishijs/client": "^5.11.0",
|
|
52
|
+
"@satorijs/element": "^3.1.8",
|
|
53
|
+
"@satorijs/protocol": "^1.6.1",
|
|
52
54
|
"@types/mime-types": "^3.0.1",
|
|
53
55
|
"autoprefixer": "^10.4.23",
|
|
56
|
+
"cosmokit": "^1.0.0",
|
|
54
57
|
"element-plus": "^2.13.0",
|
|
55
58
|
"koishi": "^4.16.0",
|
|
56
59
|
"postcss": "^8.5.6",
|
package/src/bootstrap.ts
CHANGED
|
@@ -6,31 +6,26 @@ import {} from '@satorijs/plugin-server'
|
|
|
6
6
|
import { Config } from './config'
|
|
7
7
|
import { ChatDatabase } from './database'
|
|
8
8
|
import { PluginLogger } from './logger'
|
|
9
|
+
import { resolveSatoriEndpoint } from './satori'
|
|
9
10
|
import { ContactCacheQuery, ContactCacheResult, HistoryQuery, HistoryResult, PluginConfigPayload, SatoriBootstrap } from './types'
|
|
10
11
|
|
|
11
|
-
function resolveEndpoint(ctx: Context, config: Config): string {
|
|
12
|
-
const url = ctx.satori?.server?.url ?? '/satori'
|
|
13
|
-
const clean = url.startsWith('undefined') ? url.slice(9) : url
|
|
14
|
-
if (/^https?:\/\//i.test(clean)) return clean
|
|
15
|
-
const base = ctx.server?.selfUrl ?? ctx.server?.config?.selfUrl ?? ''
|
|
16
|
-
return `${base}${clean.startsWith('/') ? clean : `/${clean}`}`
|
|
17
|
-
}
|
|
18
|
-
|
|
19
12
|
export function registerBootstrap(
|
|
20
13
|
ctx: Context,
|
|
21
14
|
config: Config,
|
|
22
15
|
database: ChatDatabase,
|
|
23
16
|
logger: PluginLogger,
|
|
17
|
+
getLogins: () => SatoriBootstrap['logins'],
|
|
24
18
|
) {
|
|
25
19
|
ctx.console.addListener('chat-patch/bootstrap', (): SatoriBootstrap => {
|
|
26
20
|
logger.logInfo('返回 Satori bootstrap:', {
|
|
27
|
-
endpoint:
|
|
21
|
+
endpoint: resolveSatoriEndpoint(ctx),
|
|
28
22
|
basePath: config.basePath,
|
|
29
23
|
})
|
|
30
24
|
return {
|
|
31
|
-
endpoint:
|
|
25
|
+
endpoint: resolveSatoriEndpoint(ctx),
|
|
32
26
|
token: ctx.satori?.server?.config?.token ?? '',
|
|
33
27
|
basePath: config.basePath,
|
|
28
|
+
logins: getLogins(),
|
|
34
29
|
blockedPlatforms: config.blockedPlatforms ?? [],
|
|
35
30
|
}
|
|
36
31
|
}, { authority: 4 })
|