diff options
author | Célestin Matte <celestin.matte@gmail.com> | 2019-11-03 12:23:41 +0100 |
---|---|---|
committer | Célestin Matte <celestin.matte@gmail.com> | 2020-03-20 17:10:55 +0100 |
commit | 9df7a439e89debaf70f6d7a62ff0fcd7a9b2499e (patch) | |
tree | e1ae0e46a58107ca14e315f84365b280c71cfc12 | |
parent | a5b202ac162423b0be339495207a0ce1a76de289 (diff) | |
download | poezio-9df7a439e89debaf70f6d7a62ff0fcd7a9b2499e.tar.gz poezio-9df7a439e89debaf70f6d7a62ff0fcd7a9b2499e.tar.bz2 poezio-9df7a439e89debaf70f6d7a62ff0fcd7a9b2499e.tar.xz poezio-9df7a439e89debaf70f6d7a62ff0fcd7a9b2499e.zip |
Add remove_get_trackers plugin
Signed-off-by: Célestin Matte <celestin.matte@gmail.com>
-rw-r--r-- | plugins/remove_get_trackers.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/plugins/remove_get_trackers.py b/plugins/remove_get_trackers.py new file mode 100644 index 00000000..9c1eb9c1 --- /dev/null +++ b/plugins/remove_get_trackers.py @@ -0,0 +1,22 @@ +""" +Remove GET trackers from URLs in sent messages. +""" +from poezio.plugin import BasePlugin +import re + +class Plugin(BasePlugin): + def init(self): + self.api.add_event_handler('muc_say', self.remove_get_trackers) + self.api.add_event_handler('conversation_say', self.remove_get_trackers) + self.api.add_event_handler('private_say', self.remove_get_trackers) + + def remove_get_trackers(self, msg, tab): + # fbclid: used globally (Facebook) + # utm_*: used globally https://en.wikipedia.org/wiki/UTM_parameters + # ncid: DoubleClick (Google) + # ref_src, ref_url: twitter + # Others exist but are excluded because they are not common. + # See https://en.wikipedia.org/wiki/UTM_parameters + msg['body'] = re.sub('&?(fbclid|dclid|ncid|utm_source|utm_medium|utm_campaign|utm_term|utm_content|ref_src|ref_url)=[^ &#]*', + '', + msg['body']) |