summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/en/configure.txt32
-rw-r--r--doc/en/plugins.txt6
-rw-r--r--src/core.py14
-rw-r--r--src/events.py6
4 files changed, 53 insertions, 5 deletions
diff --git a/doc/en/configure.txt b/doc/en/configure.txt
index 6bbf52cc..e18b4fbb 100644
--- a/doc/en/configure.txt
+++ b/doc/en/configure.txt
@@ -435,8 +435,40 @@ foo = true
*display_user_color_in_join_part*:: false
+ If set to true, the color of the nick will be used in MUCs information
+ messages, instead of the default color from the theme.
+
*hide_exit_join*:: -1
+ Exact same thing than hide_status_change, except that it concerns
+ the quit message, and that it will be hidden only if the value is 0.
+ Default setting means:
+ - all quit and join notices will be displayed
+
*hide_status_change*:: 120
+ Set a number for this setting.
+ The join OR status-change notices will be
+ displayed according to this number.
+ -1: the notices will ALWAYS be displayed
+ 0: the notices will NEVER be displayed
+ n: On any other number, the notices will only be displayed
+ if the user involved has talked since the last n seconds
+ if the value is incorrect, -1 is assumed
+ Default setting means :
+ - status changes won't be displayed unless
+ the user talked in the last 2 minutes
+
*highlight_on*:: [empty]
+
+ a list of words (separated by a colon (:)) that will be
+ highlighted if said by someone on a room
+
+*ignore_private*:: false
+
+ Ignore private messages sent from this room.
+
+*private_auto_response*:: "Not in private, please."
+
+ The message you want to be sent when someone tries to message you.
+
diff --git a/doc/en/plugins.txt b/doc/en/plugins.txt
index 9d81ad66..3e8a0447 100644
--- a/doc/en/plugins.txt
+++ b/doc/en/plugins.txt
@@ -337,6 +337,12 @@ The handlers for this event are called when someone gets kicked in a MUC.
* _presence_: Presence received.
* _tab_: Tab of the concerned MUC.
+*ignored_private*:: +message+ +tab+ +
+The handlers for this event are called when a private message gets ignored.
+
+* _message_: Message received.
+* _tab_: Tab of the concerned message.
+
SleekXMPP events
~~~~~~~~~~~~~~~~
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)