本文整理匯總了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