fixes double status announce
This commit is contained in:
parent
e84b23d1ad
commit
85d9e693ea
2 changed files with 130 additions and 121 deletions
29
src/gui.py
29
src/gui.py
|
@ -186,6 +186,7 @@ class Gui(object):
|
|||
Display the presence on the room window and update the
|
||||
presence information of the concerned user
|
||||
"""
|
||||
from common import debug
|
||||
from_nick = presence['from'].resource
|
||||
from_room = presence['from'].bare
|
||||
room = self.get_room_by_name(from_room)
|
||||
|
@ -196,14 +197,14 @@ class Gui(object):
|
|||
return self.room_error(presence, from_room)
|
||||
if not room:
|
||||
return
|
||||
else:
|
||||
msg = None
|
||||
affiliation = presence['muc']['affiliation']
|
||||
show = presence['muc']['type']
|
||||
show = presence['show']
|
||||
status = presence['status']
|
||||
role = presence['muc']['role']
|
||||
jid = presence['muc']['jid']
|
||||
typ = presence['type']
|
||||
debug('PRESENCE: %s\n->> affiliation:%s, show:%s, status:%s, role:%s\n' % (presence, affiliation, show, status, role))
|
||||
if not room.joined: # user in the room BEFORE us.
|
||||
# ignore redondant presence message, see bug #1509
|
||||
if from_nick not in [user.nick for user in room.users]:
|
||||
|
@ -221,14 +222,7 @@ class Gui(object):
|
|||
user = room.get_user_by_name(from_nick)
|
||||
# New user
|
||||
if not user:
|
||||
room.users.append(User(from_nick, affiliation,
|
||||
show, status, role))
|
||||
hide_exit_join = config.get('hide_exit_join', -1)
|
||||
if hide_exit_join != 0:
|
||||
if not jid.full:
|
||||
self.add_message_to_room(room, _("%(spec)s [%(nick)s] joined the room") % {'nick':from_nick, 'spec':theme.CHAR_JOIN}, colorized=True)
|
||||
else:
|
||||
self.add_message_to_room(room, _("%(spec)s [%(nick)s] (%(jid)s) joined the room") % {'spec':theme.CHAR_JOIN, 'nick':from_nick, 'jid':jid.full}, colorized=True)
|
||||
self.on_user_join(room, from_nick, affiliation, show, status, role, jid)
|
||||
# nick change
|
||||
elif change_nick:
|
||||
new_nick = presence.find('{http://jabber.org/protocol/muc#user}x/{http://jabber.org/protocol/muc#user}item').attrib['nick']
|
||||
|
@ -314,7 +308,7 @@ class Gui(object):
|
|||
status != user.status):
|
||||
# display the message in the room
|
||||
self.add_message_to_room(room, msg)
|
||||
private_room = self.get_room_by_name(from_room)
|
||||
private_room = self.get_room_by_name('%s/%s' % (from_room, from_nick))
|
||||
if private_room: # display the message in private
|
||||
self.add_message_to_room(private_room, msg)
|
||||
# finally, effectively change the user status
|
||||
|
@ -324,6 +318,19 @@ class Gui(object):
|
|||
self.window.input.refresh()
|
||||
doupdate()
|
||||
|
||||
def on_user_join(self, room, from_nick, affiliation, show, status, role, jid):
|
||||
"""
|
||||
When a new user joins a groupchat
|
||||
"""
|
||||
room.users.append(User(from_nick, affiliation,
|
||||
show, status, role))
|
||||
hide_exit_join = config.get('hide_exit_join', -1)
|
||||
if hide_exit_join != 0:
|
||||
if not jid.full:
|
||||
self.add_message_to_room(room, _("%(spec)s [%(nick)s] joined the room") % {'nick':from_nick, 'spec':theme.CHAR_JOIN}, colorized=True)
|
||||
else:
|
||||
self.add_message_to_room(room, _("%(spec)s [%(nick)s] (%(jid)s) joined the room") % {'spec':theme.CHAR_JOIN, 'nick':from_nick, 'jid':jid.full}, colorized=True)
|
||||
|
||||
def on_message(self, message):
|
||||
"""
|
||||
When receiving private message from a muc OR a normal message
|
||||
|
|
|
@ -27,6 +27,8 @@ class User(object):
|
|||
keep trace of an user in a Room
|
||||
"""
|
||||
def __init__(self, nick, affiliation, show, status, role):
|
||||
from common import debug
|
||||
debug('NEW USER: nick:%s, affiliation:%s, show:%s, status:%s, role:%s\n' % (nick, affiliation, show, status, role))
|
||||
self.last_talked = None
|
||||
self.update(affiliation, show, status, role)
|
||||
self.change_nick(nick)
|
||||
|
|
Loading…
Reference in a new issue