Commit 916a4a74 authored by nanahira's avatar nanahira

add PutNext

parent 88210a7e
...@@ -186,7 +186,9 @@ function PutCommandParam<T extends keyof CommandPutConfigMap>( ...@@ -186,7 +186,9 @@ function PutCommandParam<T extends keyof CommandPutConfigMap>(
export const PutArgv = () => PutCommandParam('argv'); export const PutArgv = () => PutCommandParam('argv');
export const PutSession = (field?: keyof Session) => export const PutSession = (field?: keyof Session) =>
field ? PutCommandParam('sessionField', field) : PutCommandParam('session'); field
? PutCommandParam('sessionField', field)
: PutCommandParam('argvField', 'session');
export const PutArg = (i: number) => PutCommandParam('arg', i); export const PutArg = (i: number) => PutCommandParam('arg', i);
export const PutOption = ( export const PutOption = (
name: string, name: string,
...@@ -210,6 +212,7 @@ export const PutChannelId = () => PutSession('channelId'); ...@@ -210,6 +212,7 @@ export const PutChannelId = () => PutSession('channelId');
export const PutChannelName = () => PutSession('channelName'); export const PutChannelName = () => PutSession('channelName');
export const PutSelfId = () => PutSession('selfId'); export const PutSelfId = () => PutSession('selfId');
export const PutBot = () => PutSession('bot'); export const PutBot = () => PutSession('bot');
export const PutNext = () => PutCommandParam('argvField', 'next');
// Service // Service
......
...@@ -126,9 +126,10 @@ export interface CommandOptionConfig { ...@@ -126,9 +126,10 @@ export interface CommandOptionConfig {
} }
export interface CommandPutConfigMap { export interface CommandPutConfigMap {
args: never;
arg: number; arg: number;
argv: never; argv: never;
session: never; argvField: keyof Argv;
option: CommandOptionConfig; option: CommandOptionConfig;
user: FieldCollector<'user'>; user: FieldCollector<'user'>;
channel: FieldCollector<'channel'>; channel: FieldCollector<'channel'>;
......
...@@ -153,12 +153,13 @@ export function DefinePlugin<T = any>( ...@@ -153,12 +153,13 @@ export function DefinePlugin<T = any>(
} }
switch (config.type) { switch (config.type) {
case 'arg': case 'arg':
const { data: index } = config as CommandPutConfig<'arg'>; const { data: argIndex } = config as CommandPutConfig<'arg'>;
return args[index]; return args[argIndex];
case 'argv': case 'argv':
return argv; return argv;
case 'session': case 'argvField':
return argv.session; const { data: argvField } = config as CommandPutConfig<'argvField'>;
return argv[argvField];
case 'option': case 'option':
const { data: optionData } = config as CommandPutConfig<'option'>; const { data: optionData } = config as CommandPutConfig<'option'>;
return argv.options[optionData.name]; return argv.options[optionData.name];
......
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