Add the ignore_private and private_auto_response options
MUC-specific options. private_auto_response is empty by default. + new event ignored_private
This commit is contained in:
parent
0c6a0abe86
commit
28c15a889e
4 changed files with 53 additions and 5 deletions
|
@ -435,8 +435,40 @@ foo = true
|
||||||
|
|
||||||
*display_user_color_in_join_part*:: false
|
*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
|
*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
|
*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]
|
*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.
|
||||||
|
|
||||||
|
|
|
@ -337,6 +337,12 @@ The handlers for this event are called when someone gets kicked in a MUC.
|
||||||
* _presence_: Presence received.
|
* _presence_: Presence received.
|
||||||
* _tab_: Tab of the concerned MUC.
|
* _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
|
SleekXMPP events
|
||||||
~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
14
src/core.py
14
src/core.py
|
@ -842,13 +842,19 @@ class Core(object):
|
||||||
room_from = jid.bare
|
room_from = jid.bare
|
||||||
body = xhtml.get_body_from_message_stanza(message)
|
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
|
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 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)
|
tab = self.open_private_window(room_from, nick_from, False)
|
||||||
if not tab:
|
if ignore:
|
||||||
return
|
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)
|
self.events.trigger('private_msg', message, tab)
|
||||||
if not body:
|
if not body or not tab:
|
||||||
return
|
return
|
||||||
tab.add_message(body, time=None, nickname=nick_from,
|
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))
|
forced_user=self.get_tab_by_name(room_from, tabs.MucTab).get_user_by_name(nick_from))
|
||||||
|
|
|
@ -40,6 +40,7 @@ class EventHandler(object):
|
||||||
'muc_nickchange': [],
|
'muc_nickchange': [],
|
||||||
'muc_ban': [],
|
'muc_ban': [],
|
||||||
'send_normal_presence': [],
|
'send_normal_presence': [],
|
||||||
|
'ignored_private': [],
|
||||||
}
|
}
|
||||||
|
|
||||||
def add_event_handler(self, name, callback, position=0):
|
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.
|
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:
|
for callback in callbacks:
|
||||||
callback(*args, **kwargs)
|
callback(*args, **kwargs)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue