summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrédéric Meynadier <Frederic.Meynadier@obspm.fr>2016-03-09 17:37:31 +0100
committerlouiz’ <louiz@louiz.org>2016-03-09 17:53:42 +0100
commit558ef877cbcc477ed0fd8e395196e92ddca6d6a3 (patch)
tree45edaf95e6cc4d25ea1c7f7793bc11440445522c
parentbfbd61c42397dcf70c11c19eb8948909ced9ecfd (diff)
downloadpoezio-558ef877cbcc477ed0fd8e395196e92ddca6d6a3.tar.gz
poezio-558ef877cbcc477ed0fd8e395196e92ddca6d6a3.tar.bz2
poezio-558ef877cbcc477ed0fd8e395196e92ddca6d6a3.tar.xz
poezio-558ef877cbcc477ed0fd8e395196e92ddca6d6a3.zip
Added ability to notify new messages in MUCs
-rw-r--r--plugins/simple_notify.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/plugins/simple_notify.py b/plugins/simple_notify.py
index 9311efed..461f1faf 100644
--- a/plugins/simple_notify.py
+++ b/plugins/simple_notify.py
@@ -43,6 +43,17 @@ are used to erase/delete/kill the notification after a certain
delay. In our example it is used to display an empty message in our
xmobar, erasing the notification after 3 seconds.
+Third example:
+
+.. code-block:: ini
+
+ [simple_notify]
+ command = notify-send -i /path/to/poezio/data/poezio_80.png "New message from %(from)s" "%(body)s"
+ muc_too = true
+
+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.
+
.. 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).
@@ -62,17 +73,25 @@ Options defined
after_command
Command to run after :term:`delay`. You probably want to clean up things.
+ muc_too
+ Boolean indicating whether new messages in Multi User Chat rooms should
+ trigger a notification or not.
+
"""
from plugin import BasePlugin
from xhtml import get_body_from_message_stanza
from timed_events import DelayedEvent
import shlex
+import common
+
class Plugin(BasePlugin):
def init(self):
self.api.add_event_handler('private_msg', self.on_private_msg)
self.api.add_event_handler('conversation_msg', self.on_conversation_msg)
+ if self.config.get('muc_too', False):
+ self.api.add_event_handler('muc_msg', self.on_muc_msg)
self.api.add_event_handler('highlight', self.on_highlight)
def on_private_msg(self, message, tab):
@@ -87,6 +106,14 @@ class Plugin(BasePlugin):
fro = message['from'].bare
self.do_notify(message, fro)
+ def on_muc_msg(self, message, tab):
+ fro = message['from'].bare
+ # 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)
+
def do_notify(self, message, fro):
body = get_body_from_message_stanza(message, use_xhtml=False)
if not body: