Source code for slixmpp.plugins.xep_0424.retraction
# Slixmpp: The Slick XMPP Library# Copyright (C) 2020 Mathieu Pasquet <mathieui@mathieui.net># This file is part of Slixmpp.# See the file LICENSE for copying permission.fromtypingimportOptionalfromslixmppimportJID,Messagefromslixmpp.exceptionsimportIqError,IqTimeoutfromslixmpp.xmlstream.matcherimportStanzaPathfromslixmpp.xmlstream.handlerimportCallbackfromslixmpp.pluginsimportBasePluginfromslixmpp.plugins.xep_0424importstanzaDEFAULT_FALLBACK=('This person attempted to retract a previous message, but your client ''does not support it.')
[docs]defsend_retraction(self,mto:JID,id:str,mtype:str='chat',include_fallback:bool=True,fallback_text:Optional[str]=None,*,mfrom:Optional[JID]=None):""" Send a message retraction :param JID mto: The JID to retract the message from :param str id: Message ID to retract :param str mtype: Message type :param bool include_fallback: Whether to include a fallback body :param Optional[str] fallback_text: The content of the fallback body. None will set the default value. """iffallback_textisNone:fallback_text=DEFAULT_FALLBACKmsg=self.xmpp.make_message(mto=mto,mtype=mtype,mfrom=mfrom)ifinclude_fallback:msg['body']=fallback_textmsg.enable('fallback')msg['apply_to']['id']=idmsg['apply_to'].enable('retract')msg.enable('store')msg.send()