cross-bot-bridge
Version:
A simple and customizable cross-bot bridge package that connects Discord and Telegram with admin and owner features, auto-reconnecting, media handling, message formatting conversion, user identity mapping, emoji and reaction support, and a command system.
28 lines (23 loc) • 566 B
JavaScript
class MessageCache {
constructor(size) {
this.size = size;
this.cache = new Map();
}
addMessage(id, message) {
if (this.cache.size >= this.size) {
const oldestKey = this.cache.keys().next().value;
this.cache.delete(oldestKey);
}
this.cache.set(id, message);
}
getMessage(id) {
return this.cache.get(id);
}
hasMessage(id) {
return this.cache.has(id);
}
clear() {
this.cache.clear();
}
}
module.exports = MessageCache;