JSPM

telegraf-session-sqlite

1.0.6
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q63758F
  • License MIT

sqlite session middleware for telegraf framework

Package Exports

  • telegraf-session-sqlite

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (telegraf-session-sqlite) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

telegraf-session-sqlite sqlite session middleware for telegraf framework

Install with npm/yarn

npm install telegraf-session-sqlite
yarn add telegraf-session-sqlite

Create table in your database

create table 'your_table_name'
(
  id      varchar(255)
    primary key,
  session varchar(255)
);

Example:

const sqlite3 = require('sqlite3').verbose();
const db = new sqlite3.Database(PATH_TO_DATABASE);
const session = require('telegraf-session-sqlite');
const Telegraf = require('telegraf');
const bot = new Telegraf(process.env.BOT_TOKEN);
const options = {
    db: db, //your sqlite3 instance
    table_name: 'user_session', //database table name 
}
bot.use(session(options))
...

Options object description

key description default
db sqlite3 instance none
table_name database table name where session will be stored 'telegraf_session'