Log part messages and show a leave message on /cycle

This commit is contained in:
mathieui 2014-04-17 00:02:19 +02:00
parent 214904f199
commit 71ae73ca7b
2 changed files with 6 additions and 7 deletions

View file

@ -64,7 +64,7 @@ def change_nick(core, jid, nick, status=None, show=None):
core.events.trigger('changing_nick', presence)
presence.send()
def join_groupchat(core, jid, nick, passwd='', maxhistory=None, status=None, show=None, seconds=0):
def join_groupchat(core, jid, nick, passwd='', maxhistory=None, status=None, show=None, seconds=None):
xmpp = core.xmpp
stanza = xmpp.makePresence(pto='%s/%s' % (jid, nick), pstatus=status, pshow=show)
x = ET.Element('{http://jabber.org/protocol/muc}x')
@ -72,7 +72,7 @@ def join_groupchat(core, jid, nick, passwd='', maxhistory=None, status=None, sho
passelement = ET.Element('password')
passelement.text = passwd
x.append(passelement)
if seconds:
if seconds is not None:
history = ET.Element('{http://jabber.org/protocol/muc}history')
history.attrib['seconds'] = str(seconds)
x.append(history)

View file

@ -340,12 +340,11 @@ class MucTab(ChatTab):
def command_cycle(self, arg):
"""/cycle [reason]"""
if self.joined:
muc.leave_groupchat(self.core.xmpp, self.get_name(), self.own_nick, arg)
self.command_part(arg)
self.disconnect()
self.user_win.pos = 0
self.core.disable_private_tabs(self.name)
self.core.command_join('"/%s"' % self.own_nick)
self.user_win.pos = 0
def command_recolor(self, arg):
"""
@ -414,8 +413,6 @@ class MucTab(ChatTab):
arg = arg.strip()
msg = None
if self.joined:
self.disconnect()
muc.leave_groupchat(self.core.xmpp, self.name, self.own_nick, arg)
info_col = dump_tuple(get_theme().COLOR_INFORMATION_TEXT)
char_quit = get_theme().CHAR_QUIT
spec_col = dump_tuple(get_theme().COLOR_QUIT_CHAR)
@ -447,6 +444,8 @@ class MucTab(ChatTab):
}
self.add_message(msg, typ=2)
self.disconnect()
muc.leave_groupchat(self.core.xmpp, self.name, self.own_nick, arg)
self.core.disable_private_tabs(self.name, reason=msg)
if self == self.core.current_tab():
self.refresh()