Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

botmaster-session-ware

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

botmaster-session-ware

botmaster session ware for storing context

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

Build Status

Botmaster Session Ware

A configurable botmaster ware to provide session data to downstream middleware. Works with Botmaster ^3.0.7.

Quick Start

npm install botmaster-session-ware -S
const Botmaster = require('botmaster');
const SessionWare = require('botmaster-session-ware');

botmaster.use({
  type: 'incoming',
  name: 'some controller',
  controller: (bot, update) => {
    // this will be {} on the first call from a certain user
    // and will contain the last message upon all the next iterations
    console.log(update.session);

    update.session.lastMessage = update.message;
  }
})
.
.
.
// place after declaring all your other middleware
const sessionWare = SessionWare();
botmaster.useWrapped(sessionWare.incoming, sessionWare.outgoing);

Using a different adapter

Adapters should be provided in their own package. Their api must follow the MemoryStore example.

API

SessionWare

Create an object providing incoming and outgoing middleware that manages a session object for you. By using this middleware, your other middleware will have access to a persisted update.session object.

Parameters

  • options [Object] options object for generated sessionWare
    • options.adapter [Object] an object implementing the adapter api. defaults to in MemoryStore.
    • options.sessionPath [String] dot denoted path to where to store the context in the update. defaults to 'session'

Returns Object an object that contains two functions 'incoming' and 'outgoing'. They should be used with the useWrapped method of botmaster

MemoryStore

The most basic adapter ever for SessionWare. This is the default store that is used when instantiating a SessionWare object without any params. It provides the standard required API for stores. I.e. a getter and a setter method. Called get and set that both return promises where get resolves with the session value and set sets the session value

get

Get or create a session with the id.

Parameters

  • id String a unique id for the session

Returns Promise evaluates to an object that is the session

set

Update a session in the storage.

Parameters

  • id String a unique id for the session
  • value Object the new value for the session

Returns Promise resolves when the session has been saved

Keywords

FAQs

Package last updated on 26 Oct 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc