telegraf-session-sequelize
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

Sequelize session middleware for Telegraf

Sequelize powered simple session middleware for Telegraf 4.0 with TypeScript support.

Installation

$ npm install telegraf-session-sequelize
$ yarn add telegraf-session-sequelize

Example

import { Telegraf } from 'telegraf'
import { Sequelize } from 'sequelize'
import { session } from 'telegraf-session-sequelize'

const bot = new Telegraf(process.env.BOT_TOKEN)

const init = async () => {
    const sequelize = await new Sequelize('dbName', 'username', 'pass', {
	    host: 'host',
	    dialect: 'postgres'
    })
	
    bot.use(session(sequelize, { collectionName: 'Sessions' }))
    bot.launch()
}

init()

API

Options

  • collectionName: name for MongoDB collection (default: Sessions)
  • sessionName: context property name (default: session)
  • sessionKeyFn: function that generates the session key from the context (default implementation, legacy deprecated function)

Package Sidebar

Install

npm i telegraf-session-sequelize

Weekly Downloads

1

Version

1.0.2

License

ISC

Unpacked Size

11.2 kB

Total Files

12

Last publish

Collaborators

  • oranjevo