telegram: Add message cache
patch 677c32d4755b0de6d30000202b99de435ca742d3
Author: E. Bosch <presidev@AT@gmail.com>
Date: Sat Apr 8 12:30:10 CEST 2023
* telegram: Add message cache
hunk ./telegram.py 16
+import collections
hunk ./telegram.py 58
+ self.cache = collections.OrderedDict()
hunk ./telegram.py 296
+ def add_to_cache(self, id, mid, message, user, chan):
+ if len(self.cache) >= 10000:
+ self.cache.popitem(last=False)
+ self.cache[id] = {
+ 'mid': mid,
+ 'rendered_text': message,
+ 'user': user,
+ 'channel': chan
+ }
+
hunk ./telegram.py 341
+ chan = None
hunk ./telegram.py 343
- await self.handle_telegram_channel_message(event, user, message)
+ chan = await self.handle_telegram_channel_message(event, user, message)
+
+ self.add_to_cache(event.message.id, mid, message, user, chan)
hunk ./telegram.py 360
+ return channel