add optional muc_list to configuration of simple_notify, as a whitelist of MUCs you want to be notified from.
This commit is contained in:
parent
38399f2cae
commit
51025b8d78
1 changed files with 12 additions and 2 deletions
|
@ -50,10 +50,15 @@ Third example:
|
||||||
[simple_notify]
|
[simple_notify]
|
||||||
command = notify-send -i /path/to/poezio/data/poezio_80.png "New message from %(from)s" "%(body)s"
|
command = notify-send -i /path/to/poezio/data/poezio_80.png "New message from %(from)s" "%(body)s"
|
||||||
muc_too = true
|
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
|
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.
|
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
|
.. note:: If you set the :term:`exec_remote` option to ``true`` into the
|
||||||
main configuration file, the command will be executed remotely
|
main configuration file, the command will be executed remotely
|
||||||
(as explained in the :ref:`link-plugin` plugin help).
|
(as explained in the :ref:`link-plugin` plugin help).
|
||||||
|
@ -107,12 +112,17 @@ class Plugin(BasePlugin):
|
||||||
self.do_notify(message, fro)
|
self.do_notify(message, fro)
|
||||||
|
|
||||||
def on_muc_msg(self, message, tab):
|
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
|
# Prevent old messages to be notified
|
||||||
# find_delayed_tag(message) returns (True, the datetime) or
|
# find_delayed_tag(message) returns (True, the datetime) or
|
||||||
# (False, None)
|
# (False, None)
|
||||||
if not common.find_delayed_tag(message)[0]:
|
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):
|
def do_notify(self, message, fro):
|
||||||
body = get_body_from_message_stanza(message, use_xhtml=False)
|
body = get_body_from_message_stanza(message, use_xhtml=False)
|
||||||
|
|
Loading…
Reference in a new issue