Commit 883ec4ce authored by nanahira's avatar nanahira

use selection from koishi package

parent a415b3c6
......@@ -612,4 +612,4 @@ export class AppModule {}
* 增加了 `@CommandUserFields` 对应 `cmd.userFields` 以及 `@CommandChannelFields` 对应 `cmd.channelFields`
* 增加了用于注入 Koishi 指令调用信息的提供者方法参数装饰器。详见 **指令参数** 部分。
\ No newline at end of file
* 增加了用于注入 Koishi 指令调用信息的提供者方法参数装饰器。详见 **指令参数** 部分。
......@@ -15,7 +15,6 @@ import {
import {
CommandPutConfig,
DoRegisterConfig,
EventName,
KoishiCommandInterceptorRegistration,
KoishiModuleOptions,
KoishiModulePlugin,
......
......@@ -10,8 +10,7 @@ import { IncomingMessage } from 'http';
@WebSocketGateway()
export class KoishiWebsocketGateway
implements OnGatewayInit, OnGatewayConnection
{
implements OnGatewayInit, OnGatewayConnection {
constructor(private readonly koishi: KoishiService) {}
@WebSocketServer()
......
......@@ -25,9 +25,15 @@ import {
MetadataGenericMap,
MetadataKey,
OnContextFunction,
Selection,
} from './koishi.interfaces';
import { Argv, Command, Context, FieldCollector, Session } from 'koishi';
import {
Argv,
Command,
Context,
FieldCollector,
Selection,
Session,
} from 'koishi';
import {
ContextScopeTypes,
getContextProvideToken,
......
......@@ -2,39 +2,19 @@ import { ModuleMetadata, Provider, Type } from '@nestjs/common';
import {
App,
Argv,
BeforeEventMap,
Channel,
Command,
Context,
EventMap,
FieldCollector,
MaybeArray,
Modules,
Plugin,
Selection,
Session,
User,
} from 'koishi';
import { MetadataArrayMap, MetadataMap } from './koishi.constants';
const selectors = [
'user',
'guild',
'channel',
'self',
'private',
'platform',
] as const;
type SelectorType = typeof selectors[number];
type SelectorValue = boolean | MaybeArray<string | number>;
type BaseSelection = { [K in SelectorType as `$${K}`]?: SelectorValue };
export interface Selection extends BaseSelection {
$and?: Selection[];
$or?: Selection[];
$not?: Selection;
}
export interface ContextSelector {
select?: Selection;
useSelector?: OnContextFunction;
......@@ -117,7 +97,7 @@ export type EventNameAndPrepend = CommonEventNameAndPrepend<EventName>;
type OmitSubstring<
S extends string,
T extends string,
T extends string
> = S extends `${infer L}${T}${infer R}` ? `${L}${R}` : never;
export type BeforeEventName = OmitSubstring<EventName & string, 'before-'>;
export type BeforeEventNameAndPrepend = CommonEventNameAndPrepend<BeforeEventName>;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment