XEP-0191: wrap functions with coroutine_wrapper
This commit is contained in:
parent
6e35948276
commit
6e8235544c
@ -9,6 +9,7 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from slixmpp import Iq
|
from slixmpp import Iq
|
||||||
|
from slixmpp import coroutine_wrapper
|
||||||
from slixmpp.plugins import BasePlugin
|
from slixmpp.plugins import BasePlugin
|
||||||
from slixmpp.xmlstream.handler import Callback
|
from slixmpp.xmlstream.handler import Callback
|
||||||
from slixmpp.xmlstream.matcher import StanzaPath
|
from slixmpp.xmlstream.matcher import StanzaPath
|
||||||
@ -45,14 +46,18 @@ class XEP_0191(BasePlugin):
|
|||||||
self.xmpp.remove_handler('Blocked Contact')
|
self.xmpp.remove_handler('Blocked Contact')
|
||||||
self.xmpp.remove_handler('Unblocked Contact')
|
self.xmpp.remove_handler('Unblocked Contact')
|
||||||
|
|
||||||
def get_blocked(self, ifrom=None, timeout=None, callback=None):
|
@coroutine_wrapper
|
||||||
|
def get_blocked(self, ifrom=None, timeout=None, callback=None,
|
||||||
|
coroutine=False):
|
||||||
iq = self.xmpp.Iq()
|
iq = self.xmpp.Iq()
|
||||||
iq['type'] = 'get'
|
iq['type'] = 'get'
|
||||||
iq['from'] = ifrom
|
iq['from'] = ifrom
|
||||||
iq.enable('blocklist')
|
iq.enable('blocklist')
|
||||||
return iq.send(timeout=timeout, callback=callback)
|
return iq.send(timeout=timeout, callback=callback, coroutine=coroutine)
|
||||||
|
|
||||||
def block(self, jids, ifrom=None, timeout=None, callback=None):
|
@coroutine_wrapper
|
||||||
|
def block(self, jids, ifrom=None, timeout=None, callback=None,
|
||||||
|
coroutine=False):
|
||||||
iq = self.xmpp.Iq()
|
iq = self.xmpp.Iq()
|
||||||
iq['type'] = 'set'
|
iq['type'] = 'set'
|
||||||
iq['from'] = ifrom
|
iq['from'] = ifrom
|
||||||
@ -61,9 +66,11 @@ class XEP_0191(BasePlugin):
|
|||||||
jids = [jids]
|
jids = [jids]
|
||||||
|
|
||||||
iq['block']['items'] = jids
|
iq['block']['items'] = jids
|
||||||
return iq.send(timeout=timeout, callback=callback)
|
return iq.send(timeout=timeout, callback=callback, coroutine=coroutine)
|
||||||
|
|
||||||
def unblock(self, jids=None, ifrom=None, timeout=None, callback=None):
|
@coroutine_wrapper
|
||||||
|
def unblock(self, jids=None, ifrom=None, timeout=None, callback=None,
|
||||||
|
coroutine=False):
|
||||||
iq = self.xmpp.Iq()
|
iq = self.xmpp.Iq()
|
||||||
iq['type'] = 'set'
|
iq['type'] = 'set'
|
||||||
iq['from'] = ifrom
|
iq['from'] = ifrom
|
||||||
@ -74,7 +81,7 @@ class XEP_0191(BasePlugin):
|
|||||||
jids = [jids]
|
jids = [jids]
|
||||||
|
|
||||||
iq['unblock']['items'] = jids
|
iq['unblock']['items'] = jids
|
||||||
return iq.send(timeout=timeout, callback=callback)
|
return iq.send(timeout=timeout, callback=callback, coroutine=coroutine)
|
||||||
|
|
||||||
def _handle_blocked(self, iq):
|
def _handle_blocked(self, iq):
|
||||||
self.xmpp.event('blocked', iq)
|
self.xmpp.event('blocked', iq)
|
||||||
|
Loading…
Reference in New Issue
Block a user