Ejemplo n.º 1
0
    def notification(self, cmd):
        smType = SM_TYPE.lookup(cmd.type)
        if smType is None:
            raise WebCommandException("Unknown notification's type: %s!" %
                                      cmd.type)
        if cmd.hasMessage():
            pushMessage(cmd.message, type=smType, messageData=cmd.message_data)
        elif cmd.hasI18nKey():
            parameters = cmd.i18n_data
            params = {
                'type': smType,
                'key': cmd.i18n_key,
                'messageData': cmd.message_data
            }
            for key, value in parameters.iteritems():
                params[key] = value

            pushI18nMessage(**params)
        elif cmd.hasKey():
            custom_parameters = cmd.custom_parameters
            params = {
                'type': smType,
                'key': cmd.key,
                'messageData': cmd.message_data
            }
            for key, value in custom_parameters.iteritems():
                params[key] = value

            pushI18nMessage(**params)
        return
Ejemplo n.º 2
0
def handleNotificationCommand(command, ctx):
    """
    Shows notification according to command's parameters
    """
    type = SM_TYPE.lookup(command.type)
    if type is None:
        raise WebCommandException("Unknown notification's type: %s!" % command.type)
    if command.hasMessage():
        pushMessage(command.message, type=type, messageData=command.message_data)
    elif command.hasI18nKey():
        parameters = command.i18n_data
        params = {'type': type,
         'key': command.i18n_key,
         'messageData': command.message_data}
        for key, value in parameters.iteritems():
            params[key] = value

        pushI18nMessage(**params)
    elif command.hasKey():
        custom_parameters = command.custom_parameters
        params = {'type': type,
         'key': command.key,
         'messageData': command.message_data}
        for key, value in custom_parameters.iteritems():
            params[key] = value

        pushI18nMessage(**params)
    else:
        raise WebCommandException("'i18n_key' or 'message' parameter are missing!")
    return
Ejemplo n.º 3
0
 def addEncyclopediaRecommendation(self, recId):
     if not self.__isLobbyStarted:
         return
     recId = int(recId)
     if 0 <= recId > _MAX_RECOMMENDATION_ID:
         LOG_ERROR('Recommendation ID is out of range', recId)
         return
     if self.__recommendations and self.__recommendations[0] == recId:
         return
     if recId in self.__recommendations:
         self.__recommendations.remove(recId)
     self.__recommendations.insert(0, recId)
     self.__recommendations = self.__recommendations[:_RECOMMENDATIONS_COUNT]
     _setEncyclopediaRecommendationsSections(self.__recommendations, self.settingsCore)
     self.settingsCore.serverSettings.setHasNewEncyclopediaRecommendations()
     self.onNewRecommendationReceived()
     if self.isActivated():
         pushI18nMessage(SYSTEM_MESSAGES.PRMP_NOTIFICATION_NEWENCYCLOPEDIARECOMMENDATION, priority=NotificationPriorityLevel.MEDIUM)
Ejemplo n.º 4
0
 def addEncyclopediaRecommendation(self, recId):
     if not self.__isLobbyStarted:
         return
     recId = int(recId)
     if 0 <= recId > _MAX_RECOMMENDATION_ID:
         LOG_ERROR('Recommendation ID is out of range', recId)
         return
     if self.__recommendations and self.__recommendations[0] == recId:
         return
     if recId in self.__recommendations:
         self.__recommendations.remove(recId)
     self.__recommendations.insert(0, recId)
     self.__recommendations = self.__recommendations[:_RECOMMENDATIONS_COUNT]
     _setEncyclopediaRecommendationsSections(self.__recommendations)
     g_settingsCore.serverSettings.setHasNewEncyclopediaRecommendations()
     self.onNewRecommendationReceived()
     if self.isActivated():
         pushI18nMessage(SYSTEM_MESSAGES.PRMP_NOTIFICATION_NEWENCYCLOPEDIARECOMMENDATION, priority=NotificationPriorityLevel.MEDIUM)