diff --git a/lib/telegraf.types.ts b/lib/telegraf.types.ts index e2b5e52..9b50ff3 100644 --- a/lib/telegraf.types.ts +++ b/lib/telegraf.types.ts @@ -1,22 +1,26 @@ +import { Type } from '@nestjs/common/interfaces/type.interface'; import { Composer, Telegraf } from 'telegraf'; import { Context } from './interfaces'; -export type TelegrafActionTriggers = Parameters['action']>[0]; -export type TelegrafHearsTriggers = Parameters['hears']>[0]; -export type TelegrafInlineQueryTriggers = Parameters< - Composer['inlineQuery'] +type CtxComposer = Composer; + +type ComposerMethodFirstArg = Parameters< + CtxComposer[T] >[0]; -export type TelegrafEmail = Parameters['email']>[0]; -export type TelegrafUrl = Parameters['url']>[0]; -export type TelegrafTextLink = Parameters['textLink']>[0]; -export type TelegrafTextMention = Parameters< - Composer['textMention'] ->[0]; -export type TelegrafCashtag = Parameters['cashtag']>[0]; -export type TelegrafHashtag = Parameters['hashtag']>[0]; -export type TelegrafCommand = Parameters['command']>[0]; -export type TelegrafMention = Parameters['mention']>[0]; -export type TelegrafPhone = Parameters['phone']>[0]; -export type TelegrafUpdateType = Parameters['on']>[0]; -export type TelegrafOption = ConstructorParameters[1]; + +export type TelegrafActionTriggers = ComposerMethodFirstArg<'action'>; +export type TelegrafHearsTriggers = ComposerMethodFirstArg<'hears'>; +export type TelegrafInlineQueryTriggers = ComposerMethodFirstArg<'inlineQuery'>; +export type TelegrafEmail = ComposerMethodFirstArg<'email'>; +export type TelegrafUrl = ComposerMethodFirstArg<'url'>; +export type TelegrafTextLink = ComposerMethodFirstArg<'textLink'>; +export type TelegrafTextMention = ComposerMethodFirstArg<'textMention'>; +export type TelegrafCashtag = ComposerMethodFirstArg<'cashtag'>; +export type TelegrafHashtag = ComposerMethodFirstArg<'hashtag'>; +export type TelegrafCommand = ComposerMethodFirstArg<'command'>; +export type TelegrafMention = ComposerMethodFirstArg<'mention'>; +export type TelegrafPhone = ComposerMethodFirstArg<'phone'>; +export type TelegrafUpdateType = ComposerMethodFirstArg<'on'>; + +export type TelegrafOption = ConstructorParameters>>[1]; export type TelegrafLaunchOption = Parameters[0];