diff src/plugins/plugin_misc_tarot.py @ 826:71f8e996f765

plugins radiocol_tarot: do not process received messages for MUC users that are actually not playing the game + fix for testing purpose
author souliane <souliane@mailoo.org>
date Wed, 15 Jan 2014 23:09:39 +0100
parents e3f4d80f987d
children 8f335c03eebb
line wrap: on
line diff
--- a/src/plugins/plugin_misc_tarot.py	Wed Jan 15 23:01:23 2014 +0100
+++ b/src/plugins/plugin_misc_tarot.py	Wed Jan 15 23:09:39 2014 +0100
@@ -447,14 +447,19 @@
         """
         from_jid = jid.JID(mess_elt['from'])
         room_jid = jid.JID(from_jid.userhost())
+        nick = self.host.plugins["XEP-0045"].getRoomNick(room_jid.userhost(), profile)
+
         game_elt = mess_elt.firstChildElement()
         game_data = self.games[room_jid.userhost()]
+        is_player = self.isPlayer(room_jid.userhost(), nick)
         if 'players_data' in game_data:
             players_data = game_data['players_data']
 
         for elt in game_elt.elements():
+            if not is_player and (elt.name not in ('started', 'players')):
+                continue  # user is in the room but not playing
 
-            if elt.name == 'started' or elt.name == 'players':  # new game created
+            if elt.name in ('started', 'players'):  # new game created and/or players list updated
                 players = []
                 for player in elt.elements():
                     players.append(unicode(player))