comparison 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
comparison
equal deleted inserted replaced
825:e3f4d80f987d 826:71f8e996f765
445 """ 445 """
446 @param mess_elt: instance of twisted.words.xish.domish.Element 446 @param mess_elt: instance of twisted.words.xish.domish.Element
447 """ 447 """
448 from_jid = jid.JID(mess_elt['from']) 448 from_jid = jid.JID(mess_elt['from'])
449 room_jid = jid.JID(from_jid.userhost()) 449 room_jid = jid.JID(from_jid.userhost())
450 nick = self.host.plugins["XEP-0045"].getRoomNick(room_jid.userhost(), profile)
451
450 game_elt = mess_elt.firstChildElement() 452 game_elt = mess_elt.firstChildElement()
451 game_data = self.games[room_jid.userhost()] 453 game_data = self.games[room_jid.userhost()]
454 is_player = self.isPlayer(room_jid.userhost(), nick)
452 if 'players_data' in game_data: 455 if 'players_data' in game_data:
453 players_data = game_data['players_data'] 456 players_data = game_data['players_data']
454 457
455 for elt in game_elt.elements(): 458 for elt in game_elt.elements():
456 459 if not is_player and (elt.name not in ('started', 'players')):
457 if elt.name == 'started' or elt.name == 'players': # new game created 460 continue # user is in the room but not playing
461
462 if elt.name in ('started', 'players'): # new game created and/or players list updated
458 players = [] 463 players = []
459 for player in elt.elements(): 464 for player in elt.elements():
460 players.append(unicode(player)) 465 players.append(unicode(player))
461 signal = self.host.bridge.tarotGameStarted if elt.name == 'started' else self.host.bridge.tarotGamePlayers 466 signal = self.host.bridge.tarotGameStarted if elt.name == 'started' else self.host.bridge.tarotGamePlayers
462 signal(room_jid.userhost(), from_jid.full(), players, profile) 467 signal(room_jid.userhost(), from_jid.full(), players, profile)