summaryrefslogtreecommitdiff
path: root/plugins/simple_notify.py
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2012-02-15 20:10:00 +0100
committerFlorent Le Coz <louiz@louiz.org>2012-02-15 20:10:00 +0100
commit695a7ebebaf6a277420dcb42cd96d92d77df0379 (patch)
tree8c9da1e5bf988356ad110f42113949aab94a5866 /plugins/simple_notify.py
parent0606c2b351ac87f110e1240d2f4ba1b94b275930 (diff)
parentb89cd8fd8322bf8aa23130398a0a70defcba708d (diff)
downloadpoezio-695a7ebebaf6a277420dcb42cd96d92d77df0379.tar.gz
poezio-695a7ebebaf6a277420dcb42cd96d92d77df0379.tar.bz2
poezio-695a7ebebaf6a277420dcb42cd96d92d77df0379.tar.xz
poezio-695a7ebebaf6a277420dcb42cd96d92d77df0379.zip
Merge branch 'master' of https://git.louiz.org/poezio
Diffstat (limited to 'plugins/simple_notify.py')
-rw-r--r--plugins/simple_notify.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/plugins/simple_notify.py b/plugins/simple_notify.py
new file mode 100644
index 00000000..32861d87
--- /dev/null
+++ b/plugins/simple_notify.py
@@ -0,0 +1,34 @@
+# A plugin that adds the /link command, letting you open links that are pasted
+# in the conversation, without having to click them.
+
+import os
+import re
+
+from plugin import BasePlugin, PluginConfig
+from xhtml import clean_text, get_body_from_message_stanza
+import common
+
+url_pattern = re.compile(r'\b(http[s]?://(?:\S+))\b', re.I|re.U)
+
+class Plugin(BasePlugin):
+ def init(self):
+ self.add_event_handler('private_msg', self.on_private_msg)
+ self.add_event_handler('conversation_msg', self.on_conversation_msg)
+
+ def on_private_msg(self, message, tab):
+ fro = message['from']
+ self.do_notify(message, fro)
+
+ def on_conversation_msg(self, message, tab):
+ fro = message['from'].bare
+ self.do_notify(message, fro)
+
+ def do_notify(self, message, fro):
+ body = clean_text(get_body_from_message_stanza(message))
+ if not body:
+ return
+ command = self.config.get('command', '').strip()
+ if not command:
+ self.core.information('No notification command was provided in the configuration file', 'Warning')
+ return
+ self.core.exec_command(command % {'body':body, 'from':fro})