changeset 2634:53a79ea2ad93

Make url description mandatory, pass args in a dictionary.
author Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
date Thu, 26 Jul 2007 04:19:37 +0200
parents f42fb1ae0a38
children 8ec6cc1a909f
files jabberbot/oob.py
diffstat 1 files changed, 12 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/jabberbot/oob.py	Thu Jul 26 04:05:21 2007 +0200
+++ b/jabberbot/oob.py	Thu Jul 26 04:19:37 2007 +0200
@@ -12,27 +12,24 @@
 from pyxmpp.message import Message
 from pyxmpp.presence import Presence
 
-def add_uri(stanza, uri, description):
-    """Adds an URI to a message or presence stanza
+def add_urls(stanza, data):
+    """Adds a URL to a message or presence stanza
     
     Adds an <x> element qualified by the jabber:x:oob namespace
     to the stanza's payload
     
-    @param stanza: message or presence stanza to add the uri info to
+    @param stanza: message or presence stanza to add the URL info to
     @type stanza: pyxmpp.message.Message or pyxmpp.presence.Presence
-    @param uri: an URI to add
-    @type uri: unicode
-    @param description: description of the URI
-    @type description: unicode
+    @param data: a list of dictionaries containing (url, description), as unicode
+    @type data: list
     
     """
     if not (isinstance(stanza, Presence) or isinstance(stanza, Message)):
         raise TypeError("Stanza must be either of type Presence or Message!")
-    
-    
-    x_elem = stanza.add_new_content(u"jabber:x:oob", u"x")
-    url = x_elem.newChild(None, u"url", None)
-    desc = x_elem.newChild(None, u"desc", None)
-    url.addContent(uri.encode("utf-8"))
-    desc.addContent(description.encode("utf-8"))
-    
\ No newline at end of file
+
+    for piece in data:
+        x_elem = stanza.add_new_content(u"jabber:x:oob", u"x")
+        url = x_elem.newChild(None, u"url", None)
+        desc = x_elem.newChild(None, u"desc", None)
+        url.addContent(piece['url'].encode("utf-8"))
+        desc.addContent(piece['description'].encode("utf-8"))