From 2c833e83f2f489ad3803fe26ee49afefad176f4e Mon Sep 17 00:00:00 2001 From: sunlei Date: Fri, 5 Jun 2026 20:22:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A1=A5=E9=BD=90=20BangDream=20?= =?UTF-8?q?=E5=9C=A8=E7=BA=BF=E5=91=BD=E4=BB=A4=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/qqbot-init.sql | 1 + .../qqbot-bangdream-command-sql.spec.ts | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 test/qqbot/plugins/bangDream/qqbot-bangdream-command-sql.spec.ts diff --git a/sql/qqbot-init.sql b/sql/qqbot-init.sql index a206230..d3aafcf 100644 --- a/sql/qqbot-init.sql +++ b/sql/qqbot-init.sql @@ -533,6 +533,7 @@ VALUES (2041700000000300516, 'bangdream_cutoff_all', 'BangDream ycxall', '["ycxall","myycx","全部档线"]', '["/","!","!"]', 'bangDream', 'bangdream.cutoff.all', 'plain', 'all', '{}', '', 'BangDream ycxall 失败:{{error}}', 1, 0, 3000, '查询所有档位预测线;格式:/ycxall [活动ID] [服务器]'), (2041700000000300517, 'bangdream_cutoff_recent', 'BangDream lsycx', '["lsycx","历史档线","近期档线"]', '["/","!","!"]', 'bangDream', 'bangdream.cutoff.recent', 'plain', 'all', '{}', '', 'BangDream lsycx 失败:{{error}}', 1, 0, 3000, '查询同类型活动档线;格式:/lsycx 档位 [活动ID] [服务器]') ON DUPLICATE KEY UPDATE + `code` = VALUES(`code`), `name` = VALUES(`name`), `aliases` = VALUES(`aliases`), `prefixes` = VALUES(`prefixes`), diff --git a/test/qqbot/plugins/bangDream/qqbot-bangdream-command-sql.spec.ts b/test/qqbot/plugins/bangDream/qqbot-bangdream-command-sql.spec.ts new file mode 100644 index 0000000..ec64b74 --- /dev/null +++ b/test/qqbot/plugins/bangDream/qqbot-bangdream-command-sql.spec.ts @@ -0,0 +1,26 @@ +import { readFileSync } from 'node:fs'; +import { join } from 'node:path'; +import { BANGDREAM_OPERATION_DEFS } from '@/qqbot/plugins/bangDream/commands/qqbot-bangdream-command.definitions'; + +describe('qqbot BangDream command init SQL', () => { + const sql = readFileSync(join(process.cwd(), 'sql/qqbot-init.sql'), 'utf8'); + + it('keeps every BangDream plugin operation available as an online command', () => { + const sqlOperationKeys = Array.from( + sql.matchAll(/'bangDream', '([^']+)'/g), + ).map((match) => match[1]); + const definedOperationKeys = BANGDREAM_OPERATION_DEFS.map( + (operation) => operation.key, + ); + + expect([...sqlOperationKeys].sort()).toEqual( + [...definedOperationKeys].sort(), + ); + expect(sqlOperationKeys).toHaveLength(15); + }); + + it('overwrites dirty online command metadata on duplicate ids', () => { + expect(sql).toContain('`code` = VALUES(`code`)'); + expect(sql).toContain('`is_deleted` = 0'); + }); +});