From 51025b8d7841deebb6c7873208b79f5fba5a4d9c Mon Sep 17 00:00:00 2001 From: Lasse Aagren Date: Sun, 22 May 2016 08:32:45 +0200 Subject: add optional muc_list to configuration of simple_notify, as a whitelist of MUCs you want to be notified from. --- plugins/simple_notify.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/simple_notify.py b/plugins/simple_notify.py index 461f1faf..00355fcd 100644 --- a/plugins/simple_notify.py +++ b/plugins/simple_notify.py @@ -50,10 +50,15 @@ Third example: [simple_notify] command = notify-send -i /path/to/poezio/data/poezio_80.png "New message from %(from)s" "%(body)s" muc_too = true + muc_list = someroom@conference.jabber.org,someotherroom@conference.jabber.org If present and set to ``True``, the ``muc_too`` option will also trigger a notification when a new message arrives on a Multi User Chat you've joined. +If present and set to a comma separated list of muc JIDs, muc_list together +with muc_too = true will only notify when a new message arrives on a Multi +User Chat, you've joined if it is present on the list. + .. note:: If you set the :term:`exec_remote` option to ``true`` into the main configuration file, the command will be executed remotely (as explained in the :ref:`link-plugin` plugin help). @@ -107,12 +112,17 @@ class Plugin(BasePlugin): self.do_notify(message, fro) def on_muc_msg(self, message, tab): - fro = message['from'].bare + fro = message['from'].full + muc = message['from'].bare + whitelist=self.config.get('muc_list', '').split(',') + # Prevent old messages to be notified # find_delayed_tag(message) returns (True, the datetime) or # (False, None) if not common.find_delayed_tag(message)[0]: - self.do_notify(message, fro) + # Only notify if whitelist is empty or muc in whitelist + if whitelist == [''] or muc in whitelist: + self.do_notify(message, fro) def do_notify(self, message, fro): body = get_body_from_message_stanza(message, use_xhtml=False) -- cgit v1.2.3