summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2012-05-12 20:44:38 +0200
committermathieui <mathieui@mathieui.net>2012-05-12 20:44:38 +0200
commit28c15a889e006769d343e729b55de66df3a00526 (patch)
treec25392700839977a56b8800af654ab914ddbac39 /src
parent0c6a0abe8609b870570a623348b4deb62a89cd6f (diff)
downloadpoezio-28c15a889e006769d343e729b55de66df3a00526.tar.gz
poezio-28c15a889e006769d343e729b55de66df3a00526.tar.bz2
poezio-28c15a889e006769d343e729b55de66df3a00526.tar.xz
poezio-28c15a889e006769d343e729b55de66df3a00526.zip
Add the ignore_private and private_auto_response options
MUC-specific options. private_auto_response is empty by default. + new event ignored_private
Diffstat (limited to 'src')
-rw-r--r--src/core.py14
-rw-r--r--src/events.py6
2 files changed, 15 insertions, 5 deletions
diff --git a/src/core.py b/src/core.py
index 94c1af5a..7fad4a63 100644
--- a/src/core.py
+++ b/src/core.py
@@ -842,13 +842,19 @@ class Core(object):
room_from = jid.bare
body = xhtml.get_body_from_message_stanza(message)
tab = self.get_tab_by_name(jid.full, tabs.PrivateTab) # get the tab with the private conversation
+ ignore = config.get_by_tabname('ignore_private', 'false',
+ room_from).lower() == 'true'
if not tab: # It's the first message we receive: create the tab
- if body:
+ if body and not ignore:
tab = self.open_private_window(room_from, nick_from, False)
- if not tab:
- return
+ if ignore:
+ self.events.trigger('ignored_private', message, tab)
+ msg = config.get_by_tabname('private_auto_response', None, room_from)
+ if msg and body:
+ self.xmpp.send_message(mto=jid.full, mbody=msg, mtype='chat')
+ return
self.events.trigger('private_msg', message, tab)
- if not body:
+ if not body or not tab:
return
tab.add_message(body, time=None, nickname=nick_from,
forced_user=self.get_tab_by_name(room_from, tabs.MucTab).get_user_by_name(nick_from))
diff --git a/src/events.py b/src/events.py
index 8def6cb0..e66c5ee5 100644
--- a/src/events.py
+++ b/src/events.py
@@ -40,6 +40,7 @@ class EventHandler(object):
'muc_nickchange': [],
'muc_ban': [],
'send_normal_presence': [],
+ 'ignored_private': [],
}
def add_event_handler(self, name, callback, position=0):
@@ -63,7 +64,10 @@ class EventHandler(object):
"""
Call all the callbacks associated to the given event name.
"""
- callbacks = self.events[name]
+ callbacks = self.events.get(name, None)
+ if callbacks is None:
+ log.debug('%s: No such event.', name)
+ return
for callback in callbacks:
callback(*args, **kwargs)