Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

simple implementation of redis sessions for vk-io

License

Notifications You must be signed in to change notification settings

xzeldon/vk-io-session-redis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vk-io-session-redis

vk-io-session-redis - simple implementation of the Redis sessions ⚙️

Installation

Node.js 13.0.0 or newer is required

Yarn

Recommended

yarn add vk-io-session-redis

NPM

npm i vk-io-session-redis

Example usage:

import { VK } from "vk-io";
import { RedisSession } from "vk-io-session-redis";

const bot = new VK({
    token: process.env.TOKEN
});

const redisSession = new RedisSession();
bot.updates.use(redisSession.middleware());

bot.updates.on("message", (context) => {
    if (context.isOutbox) return;

    const { session } = context;

    session.counter = session.counter || 0;
    session.counter++;

    context.send(`You turned to the bot (${session.counter}) times`);
});

bot.updates.start().catch(err => console.error(err));