2020-12-27 21:35:01 +03:00
|
|
|
import { Composer, Middleware, Telegraf } from 'telegraf';
|
2020-12-23 21:35:40 +03:00
|
|
|
|
2020-12-27 21:35:01 +03:00
|
|
|
export type Filter<T extends any[], F> = T extends []
|
|
|
|
? []
|
|
|
|
: T extends [infer Head, ...infer Tail]
|
|
|
|
? Head extends F
|
|
|
|
? Filter<Tail, F>
|
|
|
|
: [Head, ...Filter<Tail, F>]
|
|
|
|
: [];
|
2020-12-25 23:57:17 +03:00
|
|
|
|
2020-12-27 21:35:01 +03:00
|
|
|
export type UpdateMethods = Exclude<
|
|
|
|
keyof Composer<never>,
|
|
|
|
'middleware' | 'guard' | 'filter' | 'drop'
|
|
|
|
>;
|
|
|
|
export type UpdateMethodArgs<T extends UpdateMethods> = Filter<
|
|
|
|
Parameters<Composer<never>[T]>,
|
|
|
|
Middleware<any>
|
|
|
|
>;
|
2020-12-25 23:57:17 +03:00
|
|
|
|
2020-12-27 21:35:01 +03:00
|
|
|
export type TelegrafOption = ConstructorParameters<typeof Telegraf>[1];
|
2020-12-25 23:11:16 +03:00
|
|
|
export type TelegrafLaunchOption = Parameters<Telegraf['launch']>[0];
|