summaryrefslogtreecommitdiff
path: root/sleekxmpp/stanza/presence.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2012-09-25 12:26:56 -0700
committerLance Stout <lancestout@gmail.com>2012-09-25 12:26:56 -0700
commitb5c669bdff4111c5754f237d13224ec1ee1d595a (patch)
tree2c5a1e35ed4d3d962b93cf3f40c2efb3aa6734e2 /sleekxmpp/stanza/presence.py
parente449dce65c0d267c4d3206b6f9ac2e89807192bc (diff)
downloadslixmpp-b5c669bdff4111c5754f237d13224ec1ee1d595a.tar.gz
slixmpp-b5c669bdff4111c5754f237d13224ec1ee1d595a.tar.bz2
slixmpp-b5c669bdff4111c5754f237d13224ec1ee1d595a.tar.xz
slixmpp-b5c669bdff4111c5754f237d13224ec1ee1d595a.zip
Add options to auto add ID values to message and presence stanzas.
Diffstat (limited to 'sleekxmpp/stanza/presence.py')
-rw-r--r--sleekxmpp/stanza/presence.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/sleekxmpp/stanza/presence.py b/sleekxmpp/stanza/presence.py
index 7951f861..84bcd122 100644
--- a/sleekxmpp/stanza/presence.py
+++ b/sleekxmpp/stanza/presence.py
@@ -72,6 +72,17 @@ class Presence(RootStanza):
'subscribed', 'unsubscribe', 'unsubscribed'])
showtypes = set(['dnd', 'chat', 'xa', 'away'])
+ def __init__(self, *args, **kwargs):
+ """
+ Initialize a new <presence /> stanza with an optional 'id' value.
+
+ Overrides StanzaBase.__init__.
+ """
+ StanzaBase.__init__(self, *args, **kwargs)
+ if self['id'] == '':
+ if self.stream is not None and self.stream.use_presence_ids:
+ self['id'] = self.stream.new_id()
+
def exception(self, e):
"""
Override exception passback for presence.