feat: complete rewrite

This commit is contained in:
Aleksandr Bukhalo
2020-03-19 16:21:35 +03:00
parent 5cf452784f
commit 9fedcb964f
25 changed files with 309 additions and 395 deletions

View File

@@ -1,5 +0,0 @@
import { ContextMessageUpdate } from 'telegraf'
export interface ContextTransformer<T = any> {
transform: (ctx: ContextMessageUpdate) => Promise<T>
}

View File

@@ -1,18 +0,0 @@
import { ContextTransformer } from './'
import { HearsTriggers } from 'telegraf'
import { UpdateType, MessageSubTypes } from 'telegraf/typings/telegram-types'
import { Type } from '@nestjs/common'
interface ArgumentTransformation {
index: number
transform: Type<ContextTransformer>
}
export interface HandleParameters {
onStart?: boolean
on?: UpdateType | UpdateType[] | MessageSubTypes | MessageSubTypes[]
command?: string
message?: string | RegExp
action?: HearsTriggers
transformations?: ArgumentTransformation[]
}

View File

@@ -1,6 +0,0 @@
import { HandleParameters } from './'
export interface Handler {
handle: (...args: any[]) => Promise<void>
config: HandleParameters
}

View File

@@ -1,5 +1 @@
export * from './telegraf-options.interface'
export * from './handler.interface'
export * from './handle-parameters.interface'
export * from './telegram-error-handler.interface'
export * from './context-transformer.interface'
export * from './telegraf-options.interface';

View File

@@ -1,22 +1,21 @@
import { ModuleMetadata, Type } from '@nestjs/common/interfaces'
import { TelegrafOptions } from 'telegraf'
import { ModuleMetadata, Type } from '@nestjs/common/interfaces';
import { TelegrafOptions } from 'telegraf';
export interface TelegrafModuleOptions {
token: string
sitePublicUrl?: string
telegrafOptions?: TelegrafOptions
token: string;
options?: TelegrafOptions;
}
export interface TelegrafOptionsFactory {
createTelegrafOptions(): TelegrafModuleOptions
createTelegrafOptions(): TelegrafModuleOptions;
}
export interface TelegrafModuleAsyncOptions
extends Pick<ModuleMetadata, 'imports'> {
useExisting?: Type<TelegrafOptionsFactory>
useClass?: Type<TelegrafOptionsFactory>
useExisting?: Type<TelegrafOptionsFactory>;
useClass?: Type<TelegrafOptionsFactory>;
useFactory?: (
...args: any[]
) => Promise<TelegrafModuleOptions> | TelegrafModuleOptions
inject?: any[]
) => Promise<TelegrafModuleOptions> | TelegrafModuleOptions;
inject?: any[];
}

View File

@@ -1,5 +0,0 @@
import { ContextMessageUpdate } from 'telegraf'
export interface TelegramErrorHandler<E = any> {
catch(ctx: ContextMessageUpdate, error: E): Promise<void>
}