VK-IO Session - Simple implementation of the sessions ⚙️
Node.js 12.20.0 or newer is required
- Using
npm
(recommended)npm i @vk-io/session
- Using
Yarn
yarn add @vk-io/session
- Using
pnpm
pnpm add @vk-io/session
import { VK } from 'vk-io';
import { SessionManager } from '@vk-io/session';
const vk = new VK({
token: process.env.TOKEN
});
const sessionManager = new SessionManager();
vk.updates.on('message_new', sessionManager.middleware);
vk.updates.on('message_new', async (context, next) => {
if (context.text !== '/counter') {
return next();
}
const { session } = context;
if (!session.counter) {
session.counter = 0;
}
session.counter += 1;
await context.send(`You turned to the bot (${session.counter}) times`);
});
vk.updates.start().catch(console.error);
- vk-io-redis-storage: Simple storage add-on for @vk-io/session
If you want to add your module in the list, create a new issue in the repository.