fix: 修复Bilibili插件seed运行态
This commit is contained in:
parent
414136a7bd
commit
98b6dfa432
@ -272,18 +272,68 @@ INSERT INTO qqbot_plugin_version (
|
||||
1000000000000001105,
|
||||
1000000000000000105,
|
||||
'1.0.0',
|
||||
'builtin-bilibili-card-1.0.0',
|
||||
'bilibili-card:1.0.0',
|
||||
JSON_OBJECT(
|
||||
'key', 'bilibili-card',
|
||||
'pluginKey', 'bilibili-card',
|
||||
'name', 'Bilibili Card',
|
||||
'version', '1.0.0',
|
||||
'minApiSdkVersion', '1.0.0',
|
||||
'description', '解析 QQ 中的 Bilibili 视频链接卡片并回复视频摘要。',
|
||||
'author', 'KT',
|
||||
'entry', 'src/index.ts',
|
||||
'permissions', JSON_ARRAY(
|
||||
'qqbot.event.receive',
|
||||
'qqbot.send',
|
||||
'runtime.http',
|
||||
'plugin.config.read'
|
||||
),
|
||||
'runtime', JSON_OBJECT(
|
||||
'workerType', 'thread',
|
||||
'timeoutMs', 10000,
|
||||
'memoryMb', 128,
|
||||
'maxConcurrency', 1,
|
||||
'configKeys', JSON_ARRAY(
|
||||
'QQBOT_BILIBILI_CARD_HTTP_TIMEOUT_MS',
|
||||
'QQBOT_BILIBILI_CARD_MAX_REDIRECTS',
|
||||
'QQBOT_BILIBILI_CARD_DEDUPE_TTL_MS',
|
||||
'QQBOT_BILIBILI_CARD_DESC_MAX_LENGTH'
|
||||
)
|
||||
),
|
||||
'configSchema', JSON_OBJECT(
|
||||
'type', 'object',
|
||||
'properties', JSON_OBJECT(
|
||||
'QQBOT_BILIBILI_CARD_HTTP_TIMEOUT_MS', JSON_OBJECT(
|
||||
'type', 'number',
|
||||
'title', 'HTTP 超时毫秒',
|
||||
'default', 6000
|
||||
),
|
||||
'QQBOT_BILIBILI_CARD_MAX_REDIRECTS', JSON_OBJECT(
|
||||
'type', 'number',
|
||||
'title', '短链最大跳转次数',
|
||||
'default', 5
|
||||
),
|
||||
'QQBOT_BILIBILI_CARD_DEDUPE_TTL_MS', JSON_OBJECT(
|
||||
'type', 'number',
|
||||
'title', '同视频去重毫秒',
|
||||
'default', 600000
|
||||
),
|
||||
'QQBOT_BILIBILI_CARD_DESC_MAX_LENGTH', JSON_OBJECT(
|
||||
'type', 'number',
|
||||
'title', '简介最大长度',
|
||||
'default', 80
|
||||
)
|
||||
)
|
||||
),
|
||||
'operations', JSON_ARRAY(),
|
||||
'events', JSON_ARRAY(JSON_OBJECT(
|
||||
'key', 'bilibili-card.message',
|
||||
'eventName', 'message',
|
||||
'handlerName', 'handleMessage',
|
||||
'name', 'Bilibili 卡片解析'
|
||||
))
|
||||
'name', 'Bilibili 卡片解析',
|
||||
'description', '解析 QQ 中的 Bilibili 视频链接卡片并回复视频摘要。'
|
||||
)),
|
||||
'assets', JSON_ARRAY(),
|
||||
'migrations', JSON_ARRAY()
|
||||
)
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
package_hash = VALUES(package_hash),
|
||||
@ -300,10 +350,11 @@ INSERT INTO qqbot_plugin_installation (
|
||||
1000000000000001205,
|
||||
1000000000000000105,
|
||||
1000000000000001105,
|
||||
'installed',
|
||||
'idle',
|
||||
'enabled',
|
||||
'stopped',
|
||||
'src/modules/qqbot/plugins/bilibili-card'
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
version_id = VALUES(version_id),
|
||||
status = VALUES(status),
|
||||
runtime_status = VALUES(runtime_status),
|
||||
installed_path = VALUES(installed_path);
|
||||
|
||||
@ -41,11 +41,33 @@ FROM qqbot_plugin
|
||||
WHERE plugin_key = 'bilibili-card'
|
||||
AND status = 'installed';
|
||||
|
||||
SELECT 'seed_qqbot_plugin_version_bilibili_card' AS check_name, COUNT(*) AS matched_rows
|
||||
FROM qqbot_plugin_version v
|
||||
JOIN qqbot_plugin p ON p.id = v.plugin_id
|
||||
WHERE p.plugin_key = 'bilibili-card'
|
||||
AND v.version = '1.0.0'
|
||||
AND v.package_hash = 'bilibili-card:1.0.0'
|
||||
AND JSON_UNQUOTE(JSON_EXTRACT(v.manifest_json, '$.pluginKey')) = 'bilibili-card'
|
||||
AND JSON_UNQUOTE(JSON_EXTRACT(v.manifest_json, '$.runtime.workerType')) = 'thread'
|
||||
AND JSON_UNQUOTE(JSON_EXTRACT(v.manifest_json, '$.events[0].key')) = 'bilibili-card.message';
|
||||
|
||||
SELECT 'seed_qqbot_plugin_installation_bilibili_card' AS check_name, COUNT(*) AS matched_rows
|
||||
FROM qqbot_plugin_installation i
|
||||
JOIN qqbot_plugin p ON p.id = i.plugin_id
|
||||
JOIN qqbot_plugin_version v ON v.id = i.version_id
|
||||
WHERE p.plugin_key = 'bilibili-card'
|
||||
AND v.version = '1.0.0'
|
||||
AND i.status = 'enabled'
|
||||
AND i.runtime_status = 'stopped'
|
||||
AND i.installed_path = 'src/modules/qqbot/plugins/bilibili-card';
|
||||
|
||||
SELECT 'seed_qqbot_plugin_event_bilibili_card' AS check_name, COUNT(*) AS matched_rows
|
||||
FROM qqbot_plugin_event_handler
|
||||
WHERE event_key = 'bilibili-card.message'
|
||||
AND handler_name = 'handleMessage'
|
||||
AND enabled = 1;
|
||||
FROM qqbot_plugin_event_handler h
|
||||
JOIN qqbot_plugin p ON p.id = h.plugin_id
|
||||
WHERE p.plugin_key = 'bilibili-card'
|
||||
AND h.event_key = 'bilibili-card.message'
|
||||
AND h.handler_name = 'handleMessage'
|
||||
AND h.enabled = 1;
|
||||
|
||||
SELECT 'seed_qqbot_command_bangdream_song' AS check_name, COUNT(*) AS matched_rows
|
||||
FROM qqbot_command
|
||||
|
||||
@ -95,9 +95,32 @@ describe('QQBot existing plugin platform migration', () => {
|
||||
join(repoRoot, 'sql/refactor-v3/01-seed-core.sql'),
|
||||
'utf8',
|
||||
);
|
||||
const refactorVerifySql = readFileSync(
|
||||
join(repoRoot, 'sql/refactor-v3/99-verify.sql'),
|
||||
'utf8',
|
||||
);
|
||||
|
||||
expect(refactorSeedSql).toContain(`'bilibili-card'`);
|
||||
expect(refactorSeedSql).toContain(`'bilibili-card.message'`);
|
||||
expect(refactorSeedSql).toContain(`'pluginKey', 'bilibili-card'`);
|
||||
expect(refactorSeedSql).toContain(`'runtime', JSON_OBJECT(`);
|
||||
expect(refactorSeedSql).toContain(`'permissions', JSON_ARRAY(`);
|
||||
expect(refactorSeedSql).toContain(`'configSchema', JSON_OBJECT(`);
|
||||
expect(refactorSeedSql).toContain(`'bilibili-card:1.0.0'`);
|
||||
expect(refactorSeedSql).toContain(`'enabled',`);
|
||||
expect(refactorSeedSql).toContain(`'stopped',`);
|
||||
expect(refactorSeedSql).toContain(
|
||||
`version_id = VALUES(version_id),`,
|
||||
);
|
||||
expect(refactorVerifySql).toContain(
|
||||
`'seed_qqbot_plugin_version_bilibili_card'`,
|
||||
);
|
||||
expect(refactorVerifySql).toContain(
|
||||
`'seed_qqbot_plugin_installation_bilibili_card'`,
|
||||
);
|
||||
expect(refactorVerifySql).toContain(
|
||||
`JOIN qqbot_plugin p ON p.id = h.plugin_id`,
|
||||
);
|
||||
});
|
||||
|
||||
it('keeps BangDream manifest operations as the single metadata source', () => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user