chore(release): v0.7.2

This commit is contained in:
Aleksandr Bukhalo 2020-02-11 21:54:54 +03:00 committed by GitHub
commit 4f7615c4f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 2 deletions

View File

@ -1,5 +1,6 @@
import { ContextTransformer } from './' import { ContextTransformer } from './'
import { HearsTriggers } from 'telegraf' import { HearsTriggers } from 'telegraf'
import { UpdateType, MessageSubTypes } from 'telegraf/typings/telegram-types'
import { Type } from '@nestjs/common' import { Type } from '@nestjs/common'
interface ArgumentTransformation { interface ArgumentTransformation {
@ -9,6 +10,7 @@ interface ArgumentTransformation {
export interface HandleParameters { export interface HandleParameters {
onStart?: boolean onStart?: boolean
on?: UpdateType | UpdateType[] | MessageSubTypes | MessageSubTypes[]
command?: string command?: string
message?: string | RegExp message?: string | RegExp
action?: HearsTriggers action?: HearsTriggers

View File

@ -34,6 +34,7 @@ export class TelegrafService {
const handlers = this.createHandlers() const handlers = this.createHandlers()
this.setupOnStart(handlers) this.setupOnStart(handlers)
this.setupOn(handlers)
this.setupOnMessage(handlers) this.setupOnMessage(handlers)
this.setupOnCommand(handlers) this.setupOnCommand(handlers)
this.setupActions(handlers) this.setupActions(handlers)
@ -96,6 +97,14 @@ export class TelegrafService {
this.bot.start(this.adoptHandle(head(onStart))) this.bot.start(this.adoptHandle(head(onStart)))
} }
private setupOn(handlers: Handler[]): void {
const onHandlers = handlers.filter(({ config }) => config.on)
onHandlers.forEach(handler => {
this.bot.on(handler.config.on, this.adoptHandle(handler))
})
}
private setupOnMessage(handlers: Handler[]): void { private setupOnMessage(handlers: Handler[]): void {
const onMessageHandlers = handlers.filter(({ config }) => config.message) const onMessageHandlers = handlers.filter(({ config }) => config.message)

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "nestjs-telegraf", "name": "nestjs-telegraf",
"version": "0.7.1", "version": "0.7.2",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "nestjs-telegraf", "name": "nestjs-telegraf",
"version": "0.7.1", "version": "0.7.2",
"description": "Telegraf module for Nest framework", "description": "Telegraf module for Nest framework",
"keywords": [ "keywords": [
"nest", "nest",