koishi-plugin-teach
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -1,6 +0,2 @@ | ||
import { Activity } from 'koishi-core'; | ||
declare module 'koishi-core/dist/database' { | ||
interface UserData { | ||
interactiveness: Activity; | ||
} | ||
interface TableMethods { | ||
@@ -7,0 +3,0 @@ dialogue: DialogueMethods; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const koishi_core_1 = require("koishi-core"); | ||
koishi_core_1.extendUser(() => ({ interactiveness: {} })); | ||
var DialogueFlag; | ||
@@ -6,0 +5,0 @@ (function (DialogueFlag) { |
@@ -1,3 +0,10 @@ | ||
import { Context } from 'koishi-core'; | ||
import { Context, Meta } from 'koishi-core'; | ||
import { TeachConfig } from './utils'; | ||
import { Dialogue } from './database'; | ||
declare module 'koishi-core/dist/context' { | ||
interface EventMap { | ||
'dialogue'(meta: Meta, dialogue: Dialogue): any; | ||
'after-dialogue'(meta: Meta, dialogue: Dialogue): any; | ||
} | ||
} | ||
export default function (ctx: Context, config: TeachConfig): void; |
@@ -26,5 +26,3 @@ "use strict"; | ||
return next(); | ||
const { interactiveness, name } = meta.$user; | ||
koishi_core_1.updateActivity(interactiveness, groupId); | ||
await meta.$user._update(); | ||
ctx.app.emitEvent(meta, 'dialogue', meta, dialogue); | ||
const answers = dialogue.answer | ||
@@ -35,3 +33,3 @@ .replace(/\$\$/g, '@@__DOLLARS_PLACEHOLDER__@@') | ||
.replace(/\$m/g, koishi_utils_1.CQCode.stringify('at', { qq: meta.selfId })) | ||
.replace(/\$s/g, escapeAnswer(name === String(meta.userId) && meta.sender ? meta.sender.card || meta.sender.nickname : name)) | ||
.replace(/\$s/g, escapeAnswer(koishi_core_1.getSenderName(meta))) | ||
.replace(/\$0/g, escapeAnswer(meta.message)) | ||
@@ -44,4 +42,5 @@ .split('$n') | ||
} | ||
ctx.app.emitEvent(meta, 'after-dialogue', meta, dialogue); | ||
}); | ||
} | ||
exports.default = default_1; |
{ | ||
"name": "koishi-plugin-teach", | ||
"description": "Teach plugin for Koishi", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"main": "dist/index.js", | ||
@@ -34,10 +34,10 @@ "typings": "dist/index.d.ts", | ||
"devDependencies": { | ||
"koishi-database-level": "^1.0.0-alpha.7", | ||
"koishi-database-mysql": "^1.0.0-alpha.7" | ||
"koishi-database-level": "^1.0.0-alpha.8", | ||
"koishi-database-mysql": "^1.0.0-alpha.8" | ||
}, | ||
"dependencies": { | ||
"fast-deep-equal": "^3.1.1", | ||
"koishi-core": "^1.0.0-alpha.7", | ||
"koishi-core": "^1.0.0-alpha.8", | ||
"koishi-utils": "^1.0.0-alpha.3" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import { injectMethods, extendUser, Activity } from 'koishi-core' | ||
import { injectMethods } from 'koishi-core' | ||
import deepEqual from 'fast-deep-equal' | ||
@@ -7,6 +7,2 @@ import {} from 'koishi-database-mysql' | ||
declare module 'koishi-core/dist/database' { | ||
interface UserData { | ||
interactiveness: Activity | ||
} | ||
interface TableMethods { | ||
@@ -31,4 +27,2 @@ dialogue: DialogueMethods | ||
extendUser(() => ({ interactiveness: {} })) | ||
export interface DialogueCount { | ||
@@ -35,0 +29,0 @@ questions: number |
@@ -1,6 +0,13 @@ | ||
import { updateActivity, Context } from 'koishi-core' | ||
import { Context, getSenderName, Meta } from 'koishi-core' | ||
import { randomPick, CQCode, sleep } from 'koishi-utils' | ||
import { simplifyQuestion, TeachConfig } from './utils' | ||
import { DialogueTest } from './database' | ||
import { DialogueTest, Dialogue } from './database' | ||
declare module 'koishi-core/dist/context' { | ||
interface EventMap { | ||
'dialogue' (meta: Meta, dialogue: Dialogue): any | ||
'after-dialogue' (meta: Meta, dialogue: Dialogue): any | ||
} | ||
} | ||
function escapeAnswer (message: string) { | ||
@@ -28,5 +35,3 @@ return message.replace(/\$/g, '@@__DOLLARS_PLACEHOLDER__@@') | ||
const { interactiveness, name } = meta.$user | ||
updateActivity(interactiveness, groupId) | ||
await meta.$user._update() | ||
ctx.app.emitEvent(meta, 'dialogue', meta, dialogue) | ||
@@ -38,3 +43,3 @@ const answers = dialogue.answer | ||
.replace(/\$m/g, CQCode.stringify('at', { qq: meta.selfId })) | ||
.replace(/\$s/g, escapeAnswer(name === String(meta.userId) && meta.sender ? meta.sender.card || meta.sender.nickname : name)) | ||
.replace(/\$s/g, escapeAnswer(getSenderName(meta))) | ||
.replace(/\$0/g, escapeAnswer(meta.message)) | ||
@@ -48,3 +53,5 @@ .split('$n') | ||
} | ||
ctx.app.emitEvent(meta, 'after-dialogue', meta, dialogue) | ||
}) | ||
} |
Sorry, the diff of this file is not supported yet
213493
1307
Updatedkoishi-core@^1.0.0-alpha.8