Socket
Book a DemoInstallSign in
Socket

nestjs-telegraf-state

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nestjs-telegraf-state

The "Nestjs-telegraf-state" library is an extension for the NestJS framework and the Telegraf bot framework, designed to manage states inside scenes and process scripts in Telegram bots.

1.0.12
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Nestjs telegraf state

The "Nestjs-telegraf-state" library is an extension for the NestJS framework and the Telegraf bot framework, designed to manage states inside scenes and process scripts in Telegram bots.

Key features

  • State mechanism inside scenes: The library provides a mechanism for managing states inside Telegram bot scenes. With Nestjs-telegraf-state you can define different states within each scene and store the data associated with each state.

  • Scene Utilities: The library provides convenient utilities for working with scenes in Telegram bots. You can define scenes, switch between them, perform certain actions when entering and exiting a scene.

  • Integration with NestJS and Telegraf: The library allows you to easily integrate the state engine and scene utilities into your applications developed using the NestJS framework and the Telegraf bot framework.

Install

$ npm install nestjs-telegraf-state

Usage

  • Create a entity of your state.
import { StateEntity } from 'nestjs-telegraf-state'

export interface InitState {
    title: string
}

interface State extends InitState {
    description?: string 
}

@StateEntity()
export class MyStateEntity {
    constructor(private state: State) {}
    
    get title(): string {
        return this.state.title
    }
    
    get description(): string | undefined {
        return this.state.description
    }
}
  • Usage state entity in scene
import { Scene, InFn, BaseScene, UpdateSceneContextType } from 'nestjs-telegraf-state'
import { Ctx, SceneEnter } from 'nestjs-telegraf'

@Scene()
export class MyScene implements BaseScene {
    static in: InFn<InitState>
    
    @SceneEnter()
    enter(
        @Ctx() context: UpdateSceneContextType, 
        @State(MyStateEntity) entity: MyStateEntity
    ) {
        context.reply(entity.title)
    }
}

Keywords

nestjs-telegraf

FAQs

Package last updated on 13 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.