Fix examples relying on the changed API
This commit is contained in:
parent
bf5d7c83af
commit
83d00a5913
4 changed files with 8 additions and 10 deletions
|
@ -82,15 +82,13 @@ class Disco(slixmpp.ClientXMPP):
|
||||||
# for the disco_info event, or passing a handler
|
# for the disco_info event, or passing a handler
|
||||||
# function using the callback parameter.
|
# function using the callback parameter.
|
||||||
info = yield from self['xep_0030'].get_info(jid=self.target_jid,
|
info = yield from self['xep_0030'].get_info(jid=self.target_jid,
|
||||||
node=self.target_node,
|
node=self.target_node)
|
||||||
coroutine=True)
|
|
||||||
if self.get in self.items_types:
|
if self.get in self.items_types:
|
||||||
# The same applies from above. Listen for the
|
# The same applies from above. Listen for the
|
||||||
# disco_items event or pass a callback function
|
# disco_items event or pass a callback function
|
||||||
# if you need to process a non-blocking request.
|
# if you need to process a non-blocking request.
|
||||||
items = yield from self['xep_0030'].get_items(jid=self.target_jid,
|
items = yield from self['xep_0030'].get_items(jid=self.target_jid,
|
||||||
node=self.target_node,
|
node=self.target_node)
|
||||||
coroutine=True)
|
|
||||||
if self.get not in self.info_types and self.get not in self.items_types:
|
if self.get not in self.info_types and self.get not in self.items_types:
|
||||||
logging.error("Invalid disco request type.")
|
logging.error("Invalid disco request type.")
|
||||||
return
|
return
|
||||||
|
|
|
@ -75,7 +75,7 @@ class AvatarDownloader(slixmpp.ClientXMPP):
|
||||||
print("Received vCard avatar update from %s" % pres['from'].bare)
|
print("Received vCard avatar update from %s" % pres['from'].bare)
|
||||||
try:
|
try:
|
||||||
result = yield from self['xep_0054'].get_vcard(pres['from'].bare, cached=True,
|
result = yield from self['xep_0054'].get_vcard(pres['from'].bare, cached=True,
|
||||||
coroutine=True, timeout=5)
|
timeout=5)
|
||||||
except XMPPError:
|
except XMPPError:
|
||||||
print("Error retrieving avatar for %s" % pres['from'])
|
print("Error retrieving avatar for %s" % pres['from'])
|
||||||
return
|
return
|
||||||
|
@ -97,7 +97,7 @@ class AvatarDownloader(slixmpp.ClientXMPP):
|
||||||
if not info['url']:
|
if not info['url']:
|
||||||
try:
|
try:
|
||||||
result = yield from self['xep_0084'].retrieve_avatar(msg['from'].bare, info['id'],
|
result = yield from self['xep_0084'].retrieve_avatar(msg['from'].bare, info['id'],
|
||||||
coroutine=True, timeout=5)
|
timeout=5)
|
||||||
except XMPPError:
|
except XMPPError:
|
||||||
print("Error retrieving avatar for %s" % msg['from'])
|
print("Error retrieving avatar for %s" % msg['from'])
|
||||||
return
|
return
|
||||||
|
|
|
@ -90,7 +90,7 @@ class RegisterBot(slixmpp.ClientXMPP):
|
||||||
resp['register']['password'] = self.password
|
resp['register']['password'] = self.password
|
||||||
|
|
||||||
try:
|
try:
|
||||||
yield from resp.send_coroutine()
|
yield from resp.send()
|
||||||
logging.info("Account created for %s!" % self.boundjid)
|
logging.info("Account created for %s!" % self.boundjid)
|
||||||
except IqError as e:
|
except IqError as e:
|
||||||
logging.error("Could not register account: %s" %
|
logging.error("Could not register account: %s" %
|
||||||
|
|
|
@ -68,14 +68,14 @@ class AvatarSetter(slixmpp.ClientXMPP):
|
||||||
used_xep84 = False
|
used_xep84 = False
|
||||||
|
|
||||||
print('Publish XEP-0084 avatar data')
|
print('Publish XEP-0084 avatar data')
|
||||||
result = yield from self['xep_0084'].publish_avatar(avatar, coroutine=True)
|
result = yield from self['xep_0084'].publish_avatar(avatar)
|
||||||
if isinstance(result, XMPPError):
|
if isinstance(result, XMPPError):
|
||||||
print('Could not publish XEP-0084 avatar')
|
print('Could not publish XEP-0084 avatar')
|
||||||
else:
|
else:
|
||||||
used_xep84 = True
|
used_xep84 = True
|
||||||
|
|
||||||
print('Update vCard with avatar')
|
print('Update vCard with avatar')
|
||||||
result = yield from self['xep_0153'].set_avatar(avatar=avatar, mtype=avatar_type, coroutine=True)
|
result = yield from self['xep_0153'].set_avatar(avatar=avatar, mtype=avatar_type)
|
||||||
if isinstance(result, XMPPError):
|
if isinstance(result, XMPPError):
|
||||||
print('Could not set vCard avatar')
|
print('Could not set vCard avatar')
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ class AvatarSetter(slixmpp.ClientXMPP):
|
||||||
# options in image type, source (HTTP vs pubsub),
|
# options in image type, source (HTTP vs pubsub),
|
||||||
# size, etc.
|
# size, etc.
|
||||||
# {'id': ....}
|
# {'id': ....}
|
||||||
], coroutine=True)
|
])
|
||||||
if isinstance(result, XMPPError):
|
if isinstance(result, XMPPError):
|
||||||
print('Could not publish XEP-0084 metadata')
|
print('Could not publish XEP-0084 metadata')
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue