40 lines
588 B
JavaScript
40 lines
588 B
JavaScript
function main(context) {
|
|
const { bot } = context;
|
|
bot.KeyValue = class {
|
|
constructor() {
|
|
this.map = new Map();
|
|
}
|
|
|
|
store(key, value, time) {
|
|
this.map.set(key, value);
|
|
setTimeout(() => this.map.delete(key), time);
|
|
}
|
|
|
|
get(key) {
|
|
return this.map.get(key);
|
|
}
|
|
|
|
delete(key) {
|
|
this.map.delete(key);
|
|
}
|
|
|
|
clear() {
|
|
this.map = new Map();
|
|
}
|
|
|
|
keys() {
|
|
return this.map.keys();
|
|
}
|
|
|
|
values() {
|
|
return this.map.values();
|
|
}
|
|
|
|
getMap() {
|
|
return this.map;
|
|
}
|
|
};
|
|
}
|
|
|
|
module.exports = main;
|