Source code for slixmpp.plugins.xep_0444.reactions
# Slixmpp: The Slick XMPP Library# Copyright (C) 2020 Mathieu Pasquet# This file is part of Slixmpp.# See the file LICENSE for copying permission.fromtypingimportIterablefromslixmppimportJIDfromslixmpp.pluginsimportBasePluginfromslixmpp.stanzaimportMessagefromslixmpp.xmlstreamimportregister_stanza_pluginfromslixmpp.xmlstream.matcherimportStanzaPathfromslixmpp.xmlstream.handlerimportCallbackfromslixmpp.plugins.xep_0444importstanza
[docs]defsend_reactions(self,to:JID,to_id:str,reactions:Iterable[str],*,store=True):"""Send reactions related to a message"""msg=self.xmpp.make_message(mto=to)self.set_reactions(msg,to_id,reactions)ifstore:msg.enable('store')msg.send()
[docs]@staticmethoddefset_reactions(message:Message,to_id:str,reactions:Iterable[str]):"""Add reactions to a Message object."""message['reactions']['id']=to_idforreactioninreactions:reaction_stanza=stanza.Reaction()reaction_stanza['value']=reactionmessage['reactions'].append(reaction_stanza)