telegram: Add filters for received messages, in these filters:
patch d147fb4ac2eb91490933ee7ba89ecffcde0255c1
Author: E. Bosch <presidev@AT@gmail.com>
Date: Sat May 20 23:39:03 CEST 2023
* telegram: Add filters for received messages, in these filters:
Include existing emoji to ASCII function
Add conversion of "@mention" to "~mention~" as "@user" is used to denote
channel operator in most IRC clients
hunk ./telegram.py 373
+ def replace_mentions(self, text):
+ def repl_mentioned(text):
+ if text and text[0] == '@':
+ part = text[1:].lower()
+ if part in self.irc.users:
+ return '{}{}{}'.format('~', self.irc.users[part].irc_nick, '~')
+ return text
+
+ if text.find('@') != -1:
+ words = text.split(' ')
+ words_replaced = [repl_mentioned(elem) for elem in words]
+ text_replaced = ' '.join(words_replaced)
+ else:
+ text_replaced = text
+ return text_replaced
+
+ def filters(self, text):
+ filtered = e.replace_mult(text, e.emo)
+ filtered = self.replace_mentions(filtered)
+ return filtered
+
hunk ./telegram.py 400
- message = e.replace_mult(event.message.message, e.emo)
+ message = self.filters(event.message.message)
hunk ./telegram.py 408
- t = e.replace_mult(self.cache[id]['text'], e.emo)
+ t = self.filters(self.cache[id]['text'])
hunk ./telegram.py 504
- final_text = e.replace_mult(final_text, e.emo)
+ final_text = self.filters(final_text)