Source code for slixmpp.plugins.xep_0107.user_mood
# Slixmpp: The Slick XMPP Library# Copyright (C) 2011 Nathanael C. Fritz, Lance J.T. Stout# This file is part of Slixmpp.# See the file LICENSE for copying permission.importloggingfromasyncioimportFuturefromtypingimport(Optional,)fromslixmppimportMessagefromslixmpp.xmlstreamimportregister_stanza_pluginfromslixmpp.xmlstream.handlerimportCallbackfromslixmpp.xmlstream.matcherimportMatchXPathfromslixmpp.plugins.baseimportBasePluginfromslixmpp.plugins.xep_0107importstanza,UserMoodlog=logging.getLogger(__name__)
[docs]classXEP_0107(BasePlugin):""" XEP-0107: User Mood """name='xep_0107'description='XEP-0107: User Mood'dependencies={'xep_0163'}stanza=stanzadefplugin_init(self):register_stanza_plugin(Message,UserMood)defplugin_end(self):self.xmpp['xep_0030'].del_feature(feature=UserMood.namespace)self.xmpp['xep_0163'].remove_interest(UserMood.namespace)defsession_bind(self,jid):self.xmpp['xep_0163'].register_pep('user_mood',UserMood)
[docs]defpublish_mood(self,value:Optional[str]=None,text:Optional[str]=None,**pubsubkwargs)->Future:""" Publish the user's current mood. :param value: The name of the mood to publish. :param text: Optional natural-language description or reason for the mood. """mood=UserMood()mood['value']=valuemood['text']=textreturnself.xmpp['xep_0163'].publish(mood,node=UserMood.namespace,**pubsubkwargs)
[docs]defstop(self,**pubsubkwargs)->Future:""" Clear existing user mood information to stop notifications. """mood=UserMood()returnself.xmpp['xep_0163'].publish(mood,node=UserMood.namespace,**pubsubkwargs)