本文整理汇总了Python中slixmpp.xmlstream.StanzaBase.reply方法的典型用法代码示例。如果您正苦于以下问题:Python StanzaBase.reply方法的具体用法?Python StanzaBase.reply怎么用?Python StanzaBase.reply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类slixmpp.xmlstream.StanzaBase
的用法示例。
在下文中一共展示了StanzaBase.reply方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: reply
# 需要导入模块: from slixmpp.xmlstream import StanzaBase [as 别名]
# 或者: from slixmpp.xmlstream.StanzaBase import reply [as 别名]
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
示例2: reply
# 需要导入模块: from slixmpp.xmlstream import StanzaBase [as 别名]
# 或者: from slixmpp.xmlstream.StanzaBase import reply [as 别名]
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
示例3: reply
# 需要导入模块: from slixmpp.xmlstream import StanzaBase [as 别名]
# 或者: from slixmpp.xmlstream.StanzaBase import reply [as 别名]
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