diff --git a/packages/plugin-mysql/src/database.ts b/packages/plugin-mysql/src/database.ts index 3ca9af3619..0fdde24cb0 100644 --- a/packages/plugin-mysql/src/database.ts +++ b/packages/plugin-mysql/src/database.ts @@ -22,8 +22,8 @@ export default class MysqlDatabase { public pool: Pool public config: Config - escape = escape - escapeId = escapeId + escape: typeof escape + escapeId: typeof escapeId constructor(public app: App, config: Config) { this.config = { @@ -158,3 +158,6 @@ export default class MysqlDatabase { this.pool.end() } } + +MysqlDatabase.prototype.escape = escape +MysqlDatabase.prototype.escapeId = escapeId diff --git a/packages/plugin-teach/src/database/mysql.ts b/packages/plugin-teach/src/database/mysql.ts index 031085910d..82329d44f7 100644 --- a/packages/plugin-teach/src/database/mysql.ts +++ b/packages/plugin-teach/src/database/mysql.ts @@ -1,8 +1,7 @@ import { Context, extendDatabase } from 'koishi-core' import { clone, defineProperty, Observed, pick } from 'koishi-utils' import { Dialogue, equal, DialogueTest } from '../utils' -import { escape } from 'mysql' -import MysqlDatabase from 'koishi-plugin-mysql/dist/database' +import type MysqlDatabase from 'koishi-plugin-mysql/dist/database' declare module 'koishi-core/dist/context' { interface EventMap { @@ -127,6 +126,8 @@ export default function apply(ctx: Context, config: Dialogue.Config) { }) ctx.on('dialogue/mysql', ({ regexp, answer, question, original }, conditionals) => { + const { escape } = require('koishi-plugin-mysql/dist/database').default.prototype as MysqlDatabase + if (regexp) { if (answer !== undefined) conditionals.push('`answer` REGEXP ' + escape(answer)) if (question !== undefined) conditionals.push('`question` REGEXP ' + escape(original))