summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorLink Mauve <linkmauve@linkmauve.fr>2020-03-20 17:14:32 +0100
committerLink Mauve <linkmauve@linkmauve.fr>2020-03-20 17:14:32 +0100
commitb2e6d29c4ce8b380cf988b6007da81b687972402 (patch)
treee6b9a69877a7ed9d6275848cfdcee43f4162bc6e /plugins
parenta5b202ac162423b0be339495207a0ce1a76de289 (diff)
parentcd2adbbc3b6108112efc699b573724b362e74282 (diff)
downloadpoezio-b2e6d29c4ce8b380cf988b6007da81b687972402.tar.gz
poezio-b2e6d29c4ce8b380cf988b6007da81b687972402.tar.bz2
poezio-b2e6d29c4ce8b380cf988b6007da81b687972402.tar.xz
poezio-b2e6d29c4ce8b380cf988b6007da81b687972402.zip
Merge branch 'master' into 'master'
Master See merge request poezio/poezio!69
Diffstat (limited to 'plugins')
-rw-r--r--plugins/remove_get_trackers.py22
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..423e9b4e
--- /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('(https?://[^ ]+)&?(fbclid|dclid|ncid|utm_source|utm_medium|utm_campaign|utm_term|utm_content|ref_src|ref_url)=[^ &#]*',
+ r'\1',
+ msg['body'])