plugin xep-0045: nick change management
This commit is contained in:
parent
0f6de78a3b
commit
58f2410945
1 changed files with 20 additions and 1 deletions
|
|
@ -25,6 +25,9 @@ from twisted.internet import protocol, defer, threads, reactor
|
|||
from twisted.words.protocols.jabber import client, jid, xmlstream
|
||||
from twisted.words.protocols.jabber import error as jab_error
|
||||
from twisted.words.protocols.jabber.xmlstream import IQ
|
||||
|
||||
from sat.core import exceptions
|
||||
|
||||
import os.path
|
||||
import uuid
|
||||
|
||||
|
|
@ -52,6 +55,9 @@ PLUGIN_INFO = {
|
|||
"description": _("""Implementation of Multi-User Chat""")
|
||||
}
|
||||
|
||||
class UnknownRoom(Exception):
|
||||
pass
|
||||
|
||||
class XEP_0045():
|
||||
|
||||
def __init__(self, host):
|
||||
|
|
@ -59,6 +65,7 @@ class XEP_0045():
|
|||
self.host = host
|
||||
self.clients={}
|
||||
host.bridge.addMethod("joinMUC", ".plugin", in_sign='ssa{ss}s', out_sign='', method=self._join)
|
||||
host.bridge.addMethod("changeNick", ".plugin", in_sign='sss', out_sign='', method=self.changeNick)
|
||||
host.bridge.addMethod("getRoomsJoined", ".plugin", in_sign='s', out_sign='a(sass)', method=self.getRoomsJoined)
|
||||
host.bridge.addMethod("getRoomsSubjects", ".plugin", in_sign='s', out_sign='a(ss)', method=self.getRoomsSubjects)
|
||||
host.bridge.addMethod("getUniqueRoomName", ".plugin", in_sign='s', out_sign='s', method=self.getUniqueName)
|
||||
|
|
@ -171,7 +178,19 @@ class XEP_0045():
|
|||
return
|
||||
d = self.join(room_jid, nick, options, profile)
|
||||
d.addErrback(lambda x: warning(_('Error while joining room'))) #TODO: error management + signal in bridge
|
||||
|
||||
|
||||
def nick(self, room_jid, nick, profile_key='@DEFAULT@'):
|
||||
profile = self.host.memory.getProfileName(profile_key)
|
||||
if not self.__check_profile(profile):
|
||||
raise exceptions.UnknownProfileError("Unknown or disconnected profile")
|
||||
if not self.clients[profile].joined_rooms.has_key(room_jid.userhost()):
|
||||
raise UnknownRoom("This room has not been joined")
|
||||
return self.clients[profile].nick(room_jid, nick)
|
||||
|
||||
def changeNick(self, room_jid_s, nick, profile_key='@DEFAULT@'):
|
||||
"""Change nickname in a room"""
|
||||
return self.nick(jid.JID(room_jid_s), nick, profile_key)
|
||||
|
||||
def getHandler(self, profile):
|
||||
self.clients[profile] = SatMUCClient(self)
|
||||
return self.clients[profile]
|
||||
|
|
|
|||
Loading…
Reference in a new issue