@vk-io/session
v2.2.1
Published
Session for the library vk-io
Downloads
324
Readme
VK-IO Session
VK-IO Session - Simple implementation of the sessions ⚙️
📦 Installation
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
Example usage
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);
Community
Useful modules that may be useful to you
- 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.