Commit 916a4a74 authored by nanahira's avatar nanahira

add PutNext

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