Commit 883ec4ce authored by nanahira's avatar nanahira

use selection from koishi package

parent a415b3c6
...@@ -612,4 +612,4 @@ export class AppModule {} ...@@ -612,4 +612,4 @@ export class AppModule {}
* 增加了 `@CommandUserFields` 对应 `cmd.userFields` 以及 `@CommandChannelFields` 对应 `cmd.channelFields` * 增加了 `@CommandUserFields` 对应 `cmd.userFields` 以及 `@CommandChannelFields` 对应 `cmd.channelFields`
* 增加了用于注入 Koishi 指令调用信息的提供者方法参数装饰器。详见 **指令参数** 部分。 * 增加了用于注入 Koishi 指令调用信息的提供者方法参数装饰器。详见 **指令参数** 部分。
\ No newline at end of file
...@@ -15,7 +15,6 @@ import { ...@@ -15,7 +15,6 @@ import {
import { import {
CommandPutConfig, CommandPutConfig,
DoRegisterConfig, DoRegisterConfig,
EventName,
KoishiCommandInterceptorRegistration, KoishiCommandInterceptorRegistration,
KoishiModuleOptions, KoishiModuleOptions,
KoishiModulePlugin, KoishiModulePlugin,
......
...@@ -10,8 +10,7 @@ import { IncomingMessage } from 'http'; ...@@ -10,8 +10,7 @@ import { IncomingMessage } from 'http';
@WebSocketGateway() @WebSocketGateway()
export class KoishiWebsocketGateway export class KoishiWebsocketGateway
implements OnGatewayInit, OnGatewayConnection implements OnGatewayInit, OnGatewayConnection {
{
constructor(private readonly koishi: KoishiService) {} constructor(private readonly koishi: KoishiService) {}
@WebSocketServer() @WebSocketServer()
......
...@@ -25,9 +25,15 @@ import { ...@@ -25,9 +25,15 @@ import {
MetadataGenericMap, MetadataGenericMap,
MetadataKey, MetadataKey,
OnContextFunction, OnContextFunction,
Selection,
} from './koishi.interfaces'; } from './koishi.interfaces';
import { Argv, Command, Context, FieldCollector, Session } from 'koishi'; import {
Argv,
Command,
Context,
FieldCollector,
Selection,
Session,
} from 'koishi';
import { import {
ContextScopeTypes, ContextScopeTypes,
getContextProvideToken, getContextProvideToken,
......
...@@ -2,39 +2,19 @@ import { ModuleMetadata, Provider, Type } from '@nestjs/common'; ...@@ -2,39 +2,19 @@ import { ModuleMetadata, Provider, Type } from '@nestjs/common';
import { import {
App, App,
Argv, Argv,
BeforeEventMap,
Channel, Channel,
Command, Command,
Context, Context,
EventMap, EventMap,
FieldCollector, FieldCollector,
MaybeArray,
Modules, Modules,
Plugin, Plugin,
Selection,
Session, Session,
User, User,
} from 'koishi'; } from 'koishi';
import { MetadataArrayMap, MetadataMap } from './koishi.constants'; 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 { export interface ContextSelector {
select?: Selection; select?: Selection;
useSelector?: OnContextFunction; useSelector?: OnContextFunction;
...@@ -117,7 +97,7 @@ export type EventNameAndPrepend = CommonEventNameAndPrepend<EventName>; ...@@ -117,7 +97,7 @@ export type EventNameAndPrepend = CommonEventNameAndPrepend<EventName>;
type OmitSubstring< type OmitSubstring<
S extends string, S extends string,
T extends string, T extends string
> = S extends `${infer L}${T}${infer R}` ? `${L}${R}` : never; > = S extends `${infer L}${T}${infer R}` ? `${L}${R}` : never;
export type BeforeEventName = OmitSubstring<EventName & string, 'before-'>; export type BeforeEventName = OmitSubstring<EventName & string, 'before-'>;
export type BeforeEventNameAndPrepend = CommonEventNameAndPrepend<BeforeEventName>; 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