summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core.py6
-rw-r--r--src/events.py1
-rw-r--r--src/multiuserchat.py30
3 files changed, 19 insertions, 18 deletions
diff --git a/src/core.py b/src/core.py
index 6d882835..0d53f5b6 100644
--- a/src/core.py
+++ b/src/core.py
@@ -1735,11 +1735,11 @@ class Core(object):
seconds = int(seconds)
else:
seconds = 0
- muc.join_groupchat(self.xmpp, room, nick, password,
+ muc.join_groupchat(self, room, nick, password,
histo_length, current_status.message, current_status.show, seconds=seconds)
if not tab:
self.open_new_room(room, nick)
- muc.join_groupchat(self.xmpp, room, nick, password,
+ muc.join_groupchat(self, room, nick, password,
histo_length, current_status.message, current_status.show)
else:
tab.own_nick = nick
@@ -3272,7 +3272,7 @@ class Core(object):
# do not join rooms that do not have autojoin
# but display them anyway
if bm.autojoin:
- muc.join_groupchat(self.xmpp, bm.jid, nick,
+ muc.join_groupchat(self, bm.jid, nick,
passwd=bm.password,
maxhistory=histo_length,
status=self.status.message,
diff --git a/src/events.py b/src/events.py
index b7bcfc9e..f90624a6 100644
--- a/src/events.py
+++ b/src/events.py
@@ -38,6 +38,7 @@ class EventHandler(object):
'normal_presence': [],
'muc_presence': [],
'muc_join': [],
+ 'joining_muc': [],
'muc_kick': [],
'muc_nickchange': [],
'muc_ban': [],
diff --git a/src/multiuserchat.py b/src/multiuserchat.py
index 0617adda..7aefae28 100644
--- a/src/multiuserchat.py
+++ b/src/multiuserchat.py
@@ -61,25 +61,25 @@ def change_nick(xmpp, jid, nick, status=None, show=None):
"""
xmpp.make_presence(pshow=show, pstatus=status, pto=safeJID('%s/%s' % (jid, nick))).send()
-def join_groupchat(xmpp, 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=0):
+ xmpp = core.xmpp
jid = safeJID(jid)
- if not seconds:
- xmpp.plugin['xep_0045'].joinMUC(jid, nick, maxhistory=maxhistory, password=passwd, pstatus=status, pshow=show)
- else:
- # hackish but modifying the plugin is not worth it (since it is bound to be rewritten)
- stanza = xmpp.makePresence(pto="%s/%s" % (jid, nick), pstatus=status, pshow=show)
- x = ET.Element('{http://jabber.org/protocol/muc}x')
- if passwd:
- passelement = ET.Element('password')
- passelement.text = passwd
- x.append(passelement)
+ stanza = xmpp.makePresence(pto="%s/%s" % (jid, nick), pstatus=status, pshow=show)
+ x = ET.Element('{http://jabber.org/protocol/muc}x')
+ if passwd:
+ passelement = ET.Element('password')
+ passelement.text = passwd
+ x.append(passelement)
+ if seconds:
history = ET.Element('{http://jabber.org/protocol/muc}history')
history.attrib['seconds'] = str(seconds)
x.append(history)
- stanza.append(x)
- stanza.send()
- xmpp.plugin['xep_0045'].rooms[jid] = {}
- xmpp.plugin['xep_0045'].ourNicks[jid] = nick
+ stanza.append(x)
+ core.events.trigger('joining_muc', stanza)
+ to = stanza["to"]
+ stanza.send()
+ xmpp.plugin['xep_0045'].rooms[jid] = {}
+ xmpp.plugin['xep_0045'].ourNicks[jid] = to.resource
def leave_groupchat(xmpp, jid, own_nick, msg):
"""