summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/remove_get_trackers.py22
-rw-r--r--plugins/reorder.py14
2 files changed, 33 insertions, 3 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'])
diff --git a/plugins/reorder.py b/plugins/reorder.py
index 32fa6639..8d9516f8 100644
--- a/plugins/reorder.py
+++ b/plugins/reorder.py
@@ -117,6 +117,8 @@ def parse_runtime_tablist(tablist):
class Plugin(BasePlugin):
+ """reorder plugin"""
+
def init(self):
self.api.add_command(
'reorder',
@@ -129,20 +131,24 @@ class Plugin(BasePlugin):
help='Save the current tab layout')
@command_args_parser.ignored
- def command_save_order(self):
+ def command_save_order(self) -> None:
+ """
+ /save_order
+ """
conf = parse_runtime_tablist(self.core.tabs)
for key, value in conf:
self.config.set(key, value)
self.api.information('Tab order saved', 'Info')
@command_args_parser.ignored
- def command_reorder(self):
+ def command_reorder(self) -> None:
"""
/reorder
"""
tabs_spec = parse_config(self.config)
if not tabs_spec:
- return self.api.information('Invalid reorder config', 'Error')
+ self.api.information('Invalid reorder config', 'Error')
+ return None
old_tabs = self.core.tabs.get_tabs()
roster = old_tabs.pop(0)
@@ -173,3 +179,5 @@ class Plugin(BasePlugin):
self.core.tabs.replace_tabs(new_tabs)
self.core.refresh_window()
+
+ return None