Source code for slixmpp.plugins.xep_0152.reachability
# Slixmpp: The Slick XMPP Library# Copyright (C) 2013 Nathanael C. Fritz, Lance J.T. Stout# This file is part of Slixmpp.# See the file LICENSE for copying permission.importloggingfromasyncioimportFuturefromslixmppimportJIDfromtypingimportDict,List,Optional,Callablefromslixmpp.plugins.baseimportBasePluginfromslixmpp.plugins.xep_0152importstanza,Reachabilityfromslixmpp.plugins.xep_0004importFormlog=logging.getLogger(__name__)
[docs]defpublish_reachability(self,addresses:List[Dict[str,str]],**pubsubkwargs)->Future:""" Publish alternative addresses where the user can be reached. :param addresses: A list of dictionaries containing the URI and optional description for each address. """ifnotisinstance(addresses,(list,tuple)):addresses=[addresses]reach=Reachability()foraddressinaddresses:ifnothasattr(address,'items'):address={'uri':address}addr=stanza.Address()forkey,valinaddress.items():addr[key]=valreach.append(addr)returnself.xmpp['xep_0163'].publish(reach,node=Reachability.namespace,**pubsubkwargs)
[docs]defstop(self,**pubsubkwargs)->Future:""" Clear existing user activity information to stop notifications. """reach=Reachability()returnself.xmpp['xep_0163'].publish(reach,node=Reachability.namespace,**pubsubkwargs)