koishi-core
Advanced tools
Comparing version 2.0.0-alpha.10 to 2.0.0-alpha.11
@@ -83,2 +83,1 @@ /// <reference types="node" /> | ||
} | ||
//# sourceMappingURL=app.d.ts.map |
@@ -114,2 +114,1 @@ /// <reference types="node" /> | ||
export {}; | ||
//# sourceMappingURL=command.d.ts.map |
@@ -138,2 +138,1 @@ /// <reference types="node" /> | ||
export {}; | ||
//# sourceMappingURL=context.d.ts.map |
@@ -111,2 +111,1 @@ import { Observed } from 'koishi-utils'; | ||
export {}; | ||
//# sourceMappingURL=database.d.ts.map |
@@ -16,2 +16,1 @@ export * from './app'; | ||
import './plugins/validate'; | ||
//# sourceMappingURL=index.d.ts.map |
import { User, Group } from './database'; | ||
import { ParsedCommandLine } from './command'; | ||
import { App } from './app'; | ||
export declare type PostType = 'message' | 'notice' | 'request' | 'meta_event' | 'send'; | ||
@@ -49,2 +50,3 @@ export declare type MessageType = 'private' | 'group' | 'discuss'; | ||
$ctxType?: ContextType; | ||
$app?: App; | ||
$argv?: ParsedCommandLine; | ||
@@ -182,2 +184,1 @@ $parsed?: ParsedMessage; | ||
export declare function getTargetId(target: string | number): number; | ||
//# sourceMappingURL=meta.d.ts.map |
@@ -24,2 +24,1 @@ import { Command, Meta } from '..'; | ||
} | ||
//# sourceMappingURL=help.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import { NextFunction, Command, Meta } from '..'; | ||
import { NextFunction, Meta } from '..'; | ||
interface SuggestOptions { | ||
@@ -10,3 +10,2 @@ target: string; | ||
coefficient?: number; | ||
command: Command | ((suggestion: string) => Command); | ||
execute: (suggestion: string, meta: Meta<'message'>, next: NextFunction) => any; | ||
@@ -16,2 +15,1 @@ } | ||
export {}; | ||
//# sourceMappingURL=suggest.d.ts.map |
@@ -28,3 +28,2 @@ "use strict"; | ||
coefficient: app.options.similarityCoefficient, | ||
command: suggestion => app._commandMap[suggestion], | ||
async execute(suggestion, meta, next) { | ||
@@ -48,4 +47,3 @@ const newMessage = suggestion + message.slice(target.length); | ||
return meta.$send(message); | ||
const command = typeof options.command === 'function' ? options.command(suggestions[0]) : options.command; | ||
command.context.onceMiddleware(async (meta, next) => { | ||
meta.$app.onceMiddleware(async (meta, next) => { | ||
const message = meta.message.trim(); | ||
@@ -52,0 +50,0 @@ if (message && message !== '.' && message !== '。') |
@@ -10,2 +10,1 @@ export interface ThrottleConfig { | ||
} | ||
//# sourceMappingURL=throttle.d.ts.map |
@@ -32,2 +32,1 @@ import { UserData, Command } from '..'; | ||
export {}; | ||
//# sourceMappingURL=validate.d.ts.map |
@@ -93,2 +93,1 @@ import { App } from './app'; | ||
} | ||
//# sourceMappingURL=sender.d.ts.map |
@@ -47,2 +47,1 @@ /// <reference types="node" /> | ||
export declare function createServer(app: App): Server; | ||
//# sourceMappingURL=server.d.ts.map |
@@ -114,2 +114,3 @@ "use strict"; | ||
const app = this.appMap[meta.selfId]; | ||
Object.defineProperty(meta, '$app', { value: app }); | ||
// add context properties | ||
@@ -116,0 +117,0 @@ if (meta.postType === 'message') { |
@@ -35,2 +35,1 @@ /// <reference types="node" /> | ||
}; | ||
//# sourceMappingURL=shared.d.ts.map |
{ | ||
"name": "koishi-core", | ||
"description": "Core features for Koishi", | ||
"version": "2.0.0-alpha.10", | ||
"version": "2.0.0-alpha.11", | ||
"main": "dist/index.js", | ||
@@ -39,4 +39,4 @@ "typings": "dist/index.d.ts", | ||
"get-port": "^5.1.1", | ||
"koishi-database-memory": "^2.0.0-alpha.10", | ||
"koishi-test-utils": "^4.0.0-alpha.10" | ||
"koishi-database-memory": "^2.0.0-alpha.11", | ||
"koishi-test-utils": "^4.0.0-alpha.11" | ||
}, | ||
@@ -43,0 +43,0 @@ "dependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
245094
41
3453