Bug Fixes

This commit is contained in:
Luis Fernando Molina committed 2020-02-09 16:35:17 +01:00
1 parent 82bc086e92
commit b1af6e078c
131 files changed
+8597 -1930

No files matched your search

+5 -4
View File
@@ -1,9 +1,10 @@
module.exports = function (opts) {
const options = Object.assign({
const options = {
property: 'session',
store: new Map(),
getSessionKey: (ctx) => ctx.from && ctx.chat && `${ctx.from.id}:${ctx.chat.id}`
}, opts)
getSessionKey: (ctx) => ctx.from && ctx.chat && `${ctx.from.id}:${ctx.chat.id}`,
...opts
}
const ttlMs = options.ttl && options.ttl * 1000
@@ -21,7 +22,7 @@ module.exports = function (opts) {
}
Object.defineProperty(ctx, options.property, {
get: function () { return session },
set: function (newValue) { session = Object.assign({}, newValue) }
set: function (newValue) { session = { ...newValue } }
})
return next(ctx).then(() => options.store.set(key, {
session,