diff src/plugins/plugin_xep_0163.py @ 660:69a8bfd266a5

core, plugins: fixed bad use of children instead of elements() for domish.Element instances.
author Goffi <goffi@goffi.org>
date Tue, 15 Oct 2013 19:28:34 +0200
parents 84a6e83157c2
children 3c304929af74
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0163.py	Mon Oct 07 13:09:57 2013 +0200
+++ b/src/plugins/plugin_xep_0163.py	Tue Oct 15 19:28:34 2013 +0200
@@ -104,15 +104,15 @@
             debug(_("No item found"))
             return
         try:
-            mood_elem = filter(lambda x: x.name == "mood", itemsEvent.items[0].children)[0]
-        except KeyError:
+            mood_elt = [child for child in itemsEvent.items[0].elements() if child.name == "mood"][0]
+        except IndexError:
             error(_("Can't find mood element in mood event"))
             return
-        _mood = Mood.fromXml(mood_elem)
-        if not _mood:
+        mood = Mood.fromXml(mood_elt)
+        if not mood:
             debug(_("No mood found"))
             return
-        self.host.bridge.personalEvent(itemsEvent.sender.full(), "MOOD", {"mood": _mood.value or "", "text": _mood.text or ""}, profile)
+        self.host.bridge.personalEvent(itemsEvent.sender.full(), "MOOD", {"mood": mood.value or "", "text": mood.text or ""}, profile)
 
     def sendMood(self, data, profile):
         """Send XEP-0107's User Mood
@@ -124,8 +124,8 @@
         except KeyError:
             error(_("Mood data must contain at least 'mood' key"))
             return 3
-        _mood = UserMood(value, text)
-        self.sendPEPEvent(NS_USER_MOOD, _mood, profile)
+        mood = UserMood(value, text)
+        self.sendPEPEvent(NS_USER_MOOD, mood, profile)
         return 0