mirror of
https://github.com/Maks1mS/nestjs-telegraf.git
synced 2025-09-23 09:49:06 +03:00
feat: complete rewrite
This commit is contained in:
@@ -1,5 +0,0 @@
|
||||
import { ContextMessageUpdate } from 'telegraf'
|
||||
|
||||
export interface ContextTransformer<T = any> {
|
||||
transform: (ctx: ContextMessageUpdate) => Promise<T>
|
||||
}
|
@@ -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[]
|
||||
}
|
@@ -1,6 +0,0 @@
|
||||
import { HandleParameters } from './'
|
||||
|
||||
export interface Handler {
|
||||
handle: (...args: any[]) => Promise<void>
|
||||
config: HandleParameters
|
||||
}
|
@@ -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';
|
||||
|
@@ -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[];
|
||||
}
|
||||
|
@@ -1,5 +0,0 @@
|
||||
import { ContextMessageUpdate } from 'telegraf'
|
||||
|
||||
export interface TelegramErrorHandler<E = any> {
|
||||
catch(ctx: ContextMessageUpdate, error: E): Promise<void>
|
||||
}
|
Reference in New Issue
Block a user