* fixed some python3 transition bugs

* added status options to muc joining
This commit is contained in:
Nathan Fritz 2009-09-01 17:24:52 +00:00
parent 32ef496502
commit b9f7af885c
4 changed files with 8 additions and 8 deletions

View file

@ -93,7 +93,7 @@ class ClientXMPP(basexmpp, XMLStream):
self.registerStanza(**register) self.registerStanza(**register)
def __getitem__(self, key): def __getitem__(self, key):
if self.plugin.has_key(key): if key in self.plugin:
return self.plugin[key] return self.plugin[key]
else: else:
logging.warning("""Plugin "%s" is not loaded.""" % key) logging.warning("""Plugin "%s" is not loaded.""" % key)

View file

@ -36,17 +36,17 @@ class xep_0030(base.base_plugin):
self.xmpp.add_handler("<iq type='get' xmlns='%s'><query xmlns='http://jabber.org/protocol/disco#items' /></iq>" % self.xmpp.default_ns, self.item_handler) self.xmpp.add_handler("<iq type='get' xmlns='%s'><query xmlns='http://jabber.org/protocol/disco#items' /></iq>" % self.xmpp.default_ns, self.item_handler)
def add_feature(self, feature, node='main'): def add_feature(self, feature, node='main'):
if not self.features.has_key(node): if not node in self.features:
self.features[node] = [] self.features[node] = []
self.features[node].append(feature) self.features[node].append(feature)
def add_identity(self, category=None, itype=None, name=None, node='main'): def add_identity(self, category=None, itype=None, name=None, node='main'):
if not self.identities.has_key(node): if not node in self.identities:
self.identities[node] = [] self.identities[node] = []
self.identities[node].append({'category': category, 'type': itype, 'name': name}) self.identities[node].append({'category': category, 'type': itype, 'name': name})
def add_item(self, jid=None, name=None, node='main', subnode=''): def add_item(self, jid=None, name=None, node='main', subnode=''):
if not self.items.has_key(node): if not node in self.items:
self.items[node] = [] self.items[node] = []
self.items[node].append({'jid': jid, 'name': name, 'node': subnode}) self.items[node].append({'jid': jid, 'name': name, 'node': subnode})

View file

@ -87,10 +87,10 @@ class xep_0045(base.base_plugin):
mtype = xml.attrib.get('type', 'normal') mtype = xml.attrib.get('type', 'normal')
self.xmpp.event("groupchat_message", {'room': mfrom, 'name': resource, 'type': mtype, 'subject': subject, 'message': message}) self.xmpp.event("groupchat_message", {'room': mfrom, 'name': resource, 'type': mtype, 'subject': subject, 'message': message})
def joinMUC(self, room, nick, maxhistory="0", password='', wait=False): def joinMUC(self, room, nick, maxhistory="0", password='', wait=False, pstatus=None, pshow=None):
""" Join the specified room, requesting 'maxhistory' lines of history. """ Join the specified room, requesting 'maxhistory' lines of history.
""" """
stanza = self.xmpp.makePresence(pto="%s/%s" % (room, nick)) stanza = self.xmpp.makePresence(pto="%s/%s" % (room, nick), pstatus=pstatus, pshow=pshow)
x = ET.Element('{http://jabber.org/protocol/muc}x') x = ET.Element('{http://jabber.org/protocol/muc}x')
if password: if password:
passelement = ET.Element('password') passelement = ET.Element('password')
@ -180,7 +180,7 @@ class xep_0045(base.base_plugin):
""" Get the property of a nick in a room, such as its 'jid' or 'affiliation' """ Get the property of a nick in a room, such as its 'jid' or 'affiliation'
If not found, return None. If not found, return None.
""" """
if self.rooms.has_key(room) and self.rooms[room].has_key(nick) and self.rooms[room][nick].has_key(jidProperty): if room in self.rooms and nick in self.rooms[room] and jidProperty in self.rooms[room][nick]:
return self.rooms[room][nick][jidProperty] return self.rooms[room][nick][jidProperty]
else: else:
return None return None

View file

@ -25,7 +25,7 @@ class StateMachine(object):
if gstate in self.__state or gstate in self.__group: if gstate in self.__state or gstate in self.__group:
raise IndexError("The key or group '%s' is already in the StateMachine." % gstate) raise IndexError("The key or group '%s' is already in the StateMachine." % gstate)
for state in groups[gstate]: for state in groups[gstate]:
if self.__state.has_key(state): if state in self.__state:
raise IndexError("The group %s contains a key %s which is not set in the StateMachine." % (gstate, state)) raise IndexError("The group %s contains a key %s which is not set in the StateMachine." % (gstate, state))
self.__group[gstate] = groups[gstate] self.__group[gstate] = groups[gstate]