Constructor
new LocalSession(optionsopt)
- Source:
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
Options for Properties
|
Returns:
Instance of LocalSession
Members
(readonly) .storagefileAsync
- Description:
lowdb storage named fileAsync before lowdb@0.17.0
- Source:
lowdb storage named fileAsync before lowdb@0.17.0
(readonly) .storagefileSync
- Description:
lowdb storage named fileSync before lowdb@0.17.0
- Source:
lowdb storage named fileSync before lowdb@0.17.0
Methods
getSession(key) → {Object}
- Description:
Get session by it's key in database
- Source:
Parameters:
Name | Type | Description |
---|---|---|
key |
String | Key which will be used to find associated session object |
Returns:
Session data object or empty object if there's no session in database with this key
- Type
- Object
getSessionKey(ctx) → {String}
- Description:
Get session key from Telegraf Context
- Source:
Parameters:
Name | Type | Description |
---|---|---|
ctx |
Object |
Returns:
Session key in format number:number
(chat.id:from.id)
- Type
- String
middleware(propertyopt) → {Promise}
- Description:
Session middleware for use in Telegraf
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
property |
String |
<optional> |
Name of property in Telegraf Context where session object will be located (overrides |
Returns:
- Type
- Promise
(async) saveSession(key, data) → {Promise|function}
- Description:
Save session to database
- Source:
Parameters:
Name | Type | Description |
---|---|---|
key |
String | Unique Key which will be used to store session object |
data |
Object | Session data object (if empty, session will be removed from database) |
Returns:
- Promise or Promise-like
.then()
function, with session object at 1-st argument
- Type
- Promise | function