diff options
author | mathieui <mathieui@mathieui.net> | 2012-05-12 20:44:38 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2012-05-12 20:44:38 +0200 |
commit | 28c15a889e006769d343e729b55de66df3a00526 (patch) | |
tree | c25392700839977a56b8800af654ab914ddbac39 /src | |
parent | 0c6a0abe8609b870570a623348b4deb62a89cd6f (diff) | |
download | poezio-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.py | 14 | ||||
-rw-r--r-- | src/events.py | 6 |
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) |