comparison src/plugins/plugin_misc_room_game.py @ 844:f3513c8cc2e6

misc: fix unnamed arguments in format strings
author souliane <souliane@mailoo.org>
date Mon, 17 Feb 2014 14:58:26 +0100
parents 8f335c03eebb
children c5a8f602662b
comparison
equal deleted inserted replaced
843:efd92a645220 844:f3513c8cc2e6
191 if nick in [JID(invited).user for invited in invitations[1]]: 191 if nick in [JID(invited).user for invited in invitations[1]]:
192 auth = True 192 auth = True
193 break 193 break
194 194
195 if not auth and (verbose or _DEBUG): 195 if not auth and (verbose or _DEBUG):
196 debug(_("%s not allowed to join the game %s in %s") % (user_jid_s or nick, self.name, room_jid_s)) 196 debug(_("%(user)s not allowed to join the game %(game)s in %(room)s") % {'user': user_jid_s or nick, 'game': self.name, 'room': room_jid_s})
197 return auth 197 return auth
198 198
199 def _updatePlayers(self, room_jid_s, nicks, sync, profile): 199 def _updatePlayers(self, room_jid_s, nicks, sync, profile):
200 """Update the list of players and signal to the room that some players joined the game. 200 """Update the list of players and signal to the room that some players joined the game.
201 If sync is True, the news players are synchronized with the game data they have missed. 201 If sync is True, the news players are synchronized with the game data they have missed.
325 elif self.invite_mode == self.FROM_REFEREE: 325 elif self.invite_mode == self.FROM_REFEREE:
326 auth = self.isReferee(room_jid_s, nick) 326 auth = self.isReferee(room_jid_s, nick)
327 elif self.invite_mode == self.FROM_PLAYERS: 327 elif self.invite_mode == self.FROM_PLAYERS:
328 auth = self.isPlayer(room_jid_s, nick) 328 auth = self.isPlayer(room_jid_s, nick)
329 if not auth and (verbose or _DEBUG): 329 if not auth and (verbose or _DEBUG):
330 debug(_("%s not allowed to invite for the game %s in %s") % (nick, self.name, room_jid_s)) 330 debug(_("%(user)s not allowed to invite for the game %(game)s in %(room)s") % {'user': nick, 'game': self.name, 'room': room_jid_s})
331 return auth 331 return auth
332 332
333 def isReferee(self, room_jid_s, nick): 333 def isReferee(self, room_jid_s, nick):
334 """Checks if the player with this nick is the referee for the game in this room" 334 """Checks if the player with this nick is the referee for the game in this room"
335 @param room_jid_s: room userhost 335 @param room_jid_s: room userhost
370 else: 370 else:
371 # TODO: find a way to make it secure 371 # TODO: find a way to make it secure
372 (nicks, missing) = self.host.plugins["XEP-0045"].getRoomNicksOfUsers(room, other_players, secure=False) 372 (nicks, missing) = self.host.plugins["XEP-0045"].getRoomNicksOfUsers(room, other_players, secure=False)
373 result = (len(nicks) == len(other_players), nicks, missing) 373 result = (len(nicks) == len(other_players), nicks, missing)
374 if not result[0] and (verbose or _DEBUG): 374 if not result[0] and (verbose or _DEBUG):
375 debug(_("Still waiting for %s before starting the game %s in %s") % (result[2], self.name, room.occupantJID.userhost())) 375 debug(_("Still waiting for %(users)s before starting the game %(game)s in %(room)s") % {'users': result[2], 'game': self.name, 'room': room.occupantJID.userhost()})
376 return result 376 return result
377 377
378 def getUniqueName(self, muc_service="", profile_key='@DEFAULT@'): 378 def getUniqueName(self, muc_service="", profile_key='@DEFAULT@'):
379 """ 379 """
380 @param muc_service: you can leave empty to autofind the muc service 380 @param muc_service: you can leave empty to autofind the muc service
497 error('Internal error: profile %s has not joined the room %s' % (profile, room_jid_s)) 497 error('Internal error: profile %s has not joined the room %s' % (profile, room_jid_s))
498 return False, False 498 return False, False
499 if self._gameExists(room_jid_s): 499 if self._gameExists(room_jid_s):
500 is_referee = self.isReferee(room_jid_s, user_nick) 500 is_referee = self.isReferee(room_jid_s, user_nick)
501 if self._gameExists(room_jid_s, started=True): 501 if self._gameExists(room_jid_s, started=True):
502 warning(_("%s game already created in room %s") % (self.name, room_jid_s)) 502 warning(_("%(game)s game already created in room %(room)s") % {'game': self.name, 'room': room_jid_s})
503 return False, is_referee 503 return False, is_referee
504 elif not is_referee: 504 elif not is_referee:
505 warning(_("%s game in room %s can only be created by %s") % (self.name, room_jid_s, user_nick)) 505 warning(_("%(game)s game in room %(room)s can only be created by %(user)s") % {'game': self.name, 'room': room_jid_s, 'user': user_nick})
506 return False, False 506 return False, False
507 else: 507 else:
508 self._initGame(room_jid_s, user_nick) 508 self._initGame(room_jid_s, user_nick)
509 return True, False 509 return True, False
510 510
513 and skips all the checks and invitation system, but the game must 513 and skips all the checks and invitation system, but the game must
514 not exist and all the players must be in the room already. 514 not exist and all the players must be in the room already.
515 @param room_jid: JID userhost of the room 515 @param room_jid: JID userhost of the room
516 @param nicks: list of players nicks in the room (referee included, in first position) 516 @param nicks: list of players nicks in the room (referee included, in first position)
517 @param profile_key: %(doc_profile_key)s""" 517 @param profile_key: %(doc_profile_key)s"""
518 debug(_("Creating %s game in room %s") % (self.name, room_jid_s)) 518 debug(_("Creating %(game)s game in room %(room)s") % {'game': self.name, 'room': room_jid_s})
519 profile = self.host.memory.getProfileName(profile_key) 519 profile = self.host.memory.getProfileName(profile_key)
520 if not profile: 520 if not profile:
521 error(_("profile %s is unknown") % profile_key) 521 error(_("profile %s is unknown") % profile_key)
522 return 522 return
523 (create, sync) = self._checkCreateGameAndInit(room_jid_s, profile) 523 (create, sync) = self._checkCreateGameAndInit(room_jid_s, profile)