def reply(self, body=None, clear=True): """ Create a message reply. Overrides StanzaBase.reply. Sets proper 'to' attribute if the message is from a MUC, and adds a message body if one is given. :param str body: Optional text content for the message. :param bool clear: Indicates if existing content should be removed before replying. Defaults to True. :rtype: :class:`~.Message` """ new_message = StanzaBase.reply(self, clear) if self['type'] == 'groupchat': new_message['to'] = new_message['to'].bare new_message['thread'] = self['thread'] new_message['parent_thread'] = self['parent_thread'] del new_message['id'] if self.stream is not None and self.stream.use_message_ids: new_message['id'] = self.stream.new_id() if body is not None: new_message['body'] = body return new_message
def reply(self, body=None, clear=True): """ Create a message reply. Overrides StanzaBase.reply. Sets proper 'to' attribute if the message is from a MUC, and adds a message body if one is given. :param str body: Optional text content for the message. :param bool clear: Indicates if existing content should be removed before replying. Defaults to True. :rtype: :class:`~.Message` """ new_message = StanzaBase.reply(self, clear) if self['type'] == 'groupchat': new_message['to'] = new_message['to'].bare new_message['thread'] = self['thread'] new_message['parent_thread'] = self['parent_thread'] del new_message['id'] if body is not None: new_message['body'] = body return new_message
def reply(self, clear=True): """ Create a new <iq> stanza replying to ``self``. Overrides StanzaBase.reply Sets the 'type' to 'result' in addition to the default StanzaBase.reply behavior. :param bool clear: Indicates if existing content should be removed before replying. Defaults to True. """ new_iq = StanzaBase.reply(self, clear=clear) new_iq["type"] = "result" return new_iq
def reply(self, clear=True): """ Create a new <iq> stanza replying to ``self``. Overrides StanzaBase.reply Sets the 'type' to 'result' in addition to the default StanzaBase.reply behavior. :param bool clear: Indicates if existing content should be removed before replying. Defaults to True. """ new_iq = StanzaBase.reply(self, clear=clear) new_iq['type'] = 'result' return new_iq
def reply(self, clear=True): """ Create a new reply <presence/> stanza from ``self``. Overrides StanzaBase.reply. :param bool clear: Indicates if the stanza contents should be removed before replying. Defaults to True. """ new_presence = StanzaBase.reply(self, clear) if self['type'] == 'unsubscribe': new_presence['type'] = 'unsubscribed' elif self['type'] == 'subscribe': new_presence['type'] = 'subscribed' return new_presence
def reply(self, clear=True): """ Create a new reply <presence/> stanza from ``self``. Overrides StanzaBase.reply. :param bool clear: Indicates if the stanza contents should be removed before replying. Defaults to True. """ new_presence = StanzaBase.reply(self, clear) if self['type'] == 'unsubscribe': new_presence['type'] = 'unsubscribed' elif self['type'] == 'subscribe': new_presence['type'] = 'subscribed' return new_presence