def _make(self, item=None, settings=None): if not item: raise AssertionError("Item is not defined") self._itemName = item.getName() if settings: self._settings = settings layout, states = self._makeButtonsLayout(item) topic = i18n.encodeUtf8(item.getTopic()) if len(topic): topic = g_settings.htmlTemplates.format("notificationsCenterTopic", ctx={"topic": topic}) body = i18n.encodeUtf8(item.getBody()) note = item.getNote() len(note) and body += g_settings.htmlTemplates.format("notificationsCenterNote", ctx={"note": note}) bgSource, (_, bgHeight) = item.getLocalBG() message = g_settings.msgTemplates.format( "wgncNotification_v2", ctx={"topic": topic, "body": body}, data={ "icon": makePathToIcon(item.getLocalIcon()), "defaultIcon": makePathToIcon(WGNC_DEFAULT_ICON), "bgIcon": {None: makePathToIcon(bgSource)}, "bgIconHeight": bgHeight, "buttonsLayout": layout, "buttonsStates": states, }, ) self._vo = { "typeID": self.getType(), "entityID": self.getID(), "message": message, "notify": self.isNotify(), "auxData": [], } return
def _make(self, item = None, settings = None): if not item: raise AssertionError('Item is not defined') self._itemName = item.getName() if settings: self._settings = settings layout, states = self._makeButtonsLayout(item) topic = i18n.encodeUtf8(item.getTopic()) if len(topic): topic = g_settings.htmlTemplates.format('notificationsCenterTopic', ctx={'topic': topic}) body = i18n.encodeUtf8(item.getBody()) note = item.getNote() len(note) and body += g_settings.htmlTemplates.format('notificationsCenterNote', ctx={'note': note}) bgSource, (_, bgHeight) = item.getLocalBG() message = g_settings.msgTemplates.format('wgncNotification_v2', ctx={'topic': topic, 'body': body}, data={'icon': makePathToIcon(item.getLocalIcon()), 'defaultIcon': makePathToIcon(WGNC_DEFAULT_ICON), 'bgIcon': {None: makePathToIcon(bgSource)}, 'bgIconHeight': bgHeight, 'buttonsLayout': layout, 'buttonsStates': states}) self._vo = {'typeID': self.getType(), 'entityID': self.getID(), 'message': message, 'notify': self.isNotify(), 'auxData': []} return
def _make(self, entity = None, settings = None): self._settings = NotificationGuiSettings(True, NotificationPriorityLevel.MEDIUM, showAt=_makeShowTime()) name = self._getName(entity) formatter = ClanAppActionHtmlTextFormatter(self._actionType) message = g_settings.msgTemplates.format('clanSimple', ctx={'text': formatter.getText(name)}, data={'timestamp': self._createdAt, 'icon': makePathToIcon('clanInviteIcon'), 'defaultIcon': makePathToIcon('InformationIcon')}) self._vo = {'typeID': self.getType(), 'entityID': self.getID(), 'message': message, 'notify': self.isNotify(), 'auxData': []}
def _make(self, entity = None, settings = None): self._settings = NotificationGuiSettings(True, NotificationPriorityLevel.MEDIUM, showAt=_makeShowTime()) formatter = self._getFormatter() message = g_settings.msgTemplates.format(self._getTemplateId(), ctx={'text': self._getText(formatter, entity)}, data={'timestamp': self._createdAt, 'icon': makePathToIcon('clanInviteIcon'), 'defaultIcon': makePathToIcon('InformationIcon'), 'buttonsStates': self._getButtonsStates(entity)}) self._vo = {'typeID': self.getType(), 'entityID': self.getID(), 'message': message, 'notify': self.isNotify(), 'auxData': []}
def _make(self, activeApps = None, settings = None): self._settings = NotificationGuiSettings(True, NotificationPriorityLevel.HIGH, showAt=_makeShowTime()) activeApps = activeApps or [] formatter = ClubAppsHtmlTextFormatter() message = g_settings.msgTemplates.format('clubApps', ctx={'text': formatter.getText(len(activeApps))}, data={'timestamp': self._createdAt, 'icon': makePathToIcon('InformationIcon'), 'defaultIcon': makePathToIcon('InformationIcon'), 'buttonsStates': {'submit': NOTIFICATION_BUTTON_STATE.DEFAULT}}) self._vo = {'typeID': self.getType(), 'entityID': self.getID(), 'message': message, 'notify': self.isNotify(), 'auxData': []}
def _make(self, entity = None, settings = None): if self._settings is None: self._settings = NotificationGuiSettings(True, NotificationPriorityLevel.MEDIUM, showAt=_makeShowTime()) formatter = self._getFormatter() message = g_settings.msgTemplates.format(self._getTemplateId(), ctx={'text': self._getText(formatter, entity)}, data={'timestamp': self._createdAt, 'icon': makePathToIcon('clanInviteIcon'), 'defaultIcon': makePathToIcon('InformationIcon'), 'buttonsStates': self._getButtonsStates(entity)}) self._vo = {'typeID': self.getType(), 'entityID': self.getID(), 'message': message, 'notify': self.isNotify(), 'auxData': []} return
def _make(self, invite=None, settings=None): invite = invite or self.clubsCtrl.getProfile().getInvite( self._entityID) if not invite: LOG_ERROR('Invite not found', self._entityID) self._vo = {} self._settings = NotificationGuiSettings( False, NotificationPriorityLevel.LOW, showAt=_makeShowTime()) return if not invite.showAt() or invite.isActive(): if invite.showAt() > 0: self._isOrderChanged = True invite.setShowTime(_makeShowTime()) if invite.isActive(): self._settings = NotificationGuiSettings( True, NotificationPriorityLevel.HIGH, showAt=invite.showAt()) else: self._settings = NotificationGuiSettings( False, NotificationPriorityLevel.LOW, showAt=invite.showAt()) canAccept = invite.isActive() canDecline = invite.isActive() if canAccept or canDecline: submitState = cancelState = NOTIFICATION_BUTTON_STATE.VISIBLE if canAccept: submitState |= NOTIFICATION_BUTTON_STATE.ENABLED if canDecline: cancelState |= NOTIFICATION_BUTTON_STATE.ENABLED else: submitState = cancelState = 0 formatter = ClubInviteHtmlTextFormatter() message = g_settings.msgTemplates.format( 'clubInvite', ctx={'text': formatter.getText(invite)}, data={ 'timestamp': self._createdAt, 'icon': makePathToIcon('clubInviteIcon'), 'defaultIcon': makePathToIcon('prebattleInviteIcon'), 'buttonsStates': { 'submit': submitState, 'cancel': cancelState } }) self._vo = { 'typeID': self.getType(), 'entityID': self.getID(), 'message': message, 'notify': self.isNotify(), 'auxData': [] }
def _make(self, user = None, settings = None): if settings: self._settings = settings contacts = self.proto.contacts if user.getItemType() in XMPP_ITEM_TYPE.SUB_PENDING_ITEMS: self._receivedAt = user.getItem().receivedAt() canCancel, error = contacts.canCancelFriendship(user) if canCancel: canApprove, error = contacts.canApproveFriendship(user) else: canApprove = False if canApprove or canCancel: submitState = cancelState = NOTIFICATION_BUTTON_STATE.VISIBLE if canApprove: submitState |= NOTIFICATION_BUTTON_STATE.ENABLED if canCancel: cancelState |= NOTIFICATION_BUTTON_STATE.ENABLED self._settings.isNotify = True self._settings.priorityLevel = NotificationPriorityLevel.HIGH else: submitState = cancelState = NOTIFICATION_BUTTON_STATE.HIDDEN message = g_settings.msgTemplates.format('friendshipRequest', ctx={'text': makeFriendshipRequestText(user, error)}, data={'timestamp': self._receivedAt, 'icon': makePathToIcon('friendshipIcon'), 'buttonsStates': {'submit': submitState, 'cancel': cancelState}}) self._vo = {'typeID': self.getType(), 'entityID': self.getID(), 'message': message, 'notify': self.isNotify(), 'auxData': []}
def _make(self, user = None, settings = None): if settings: self._settings = settings contacts = self.proto.contacts if user.getItemType() == XMPP_ITEM_TYPE.SUB_PENDING: self._receivedAt = user.getItem().receivedAt() canCancel, error = contacts.canCancelFriendship(user) if canCancel: canApprove, error = contacts.canApproveFriendship(user) else: canApprove = False if canApprove or canCancel: submitState = cancelState = NOTIFICATION_BUTTON_STATE.VISIBLE if canApprove: submitState |= NOTIFICATION_BUTTON_STATE.ENABLED if canCancel: cancelState |= NOTIFICATION_BUTTON_STATE.ENABLED self._settings.isNotify = True self._settings.priorityLevel = NotificationPriorityLevel.HIGH else: submitState = cancelState = NOTIFICATION_BUTTON_STATE.HIDDEN message = g_settings.msgTemplates.format('friendshipRequest', ctx={'text': makeFriendshipRequestText(user, error)}, data={'timestamp': self._receivedAt, 'icon': makePathToIcon('friendshipIcon'), 'buttonsStates': {'submit': submitState, 'cancel': cancelState}}) self._vo = {'typeID': self.getType(), 'entityID': self.getID(), 'message': message, 'notify': self.isNotify(), 'auxData': []}
def _make(self, invite=None, settings=None): invite = invite or g_clubsCtrl.getProfile().getInvite(self._entityID) if not invite: LOG_ERROR("Invite not found", self._entityID) self._vo = {} self._settings = NotificationGuiSettings(False, NotificationPriorityLevel.LOW, showAt=_makeShowTime()) return if not invite.showAt() or invite.isActive(): if invite.showAt() > 0: self._isOrderChanged = True invite.setShowTime(_makeShowTime()) if invite.isActive(): self._settings = NotificationGuiSettings(True, NotificationPriorityLevel.HIGH, showAt=invite.showAt()) else: self._settings = NotificationGuiSettings(False, NotificationPriorityLevel.LOW, showAt=invite.showAt()) canAccept = invite.isActive() canDecline = invite.isActive() if canAccept or canDecline: submitState = cancelState = NOTIFICATION_BUTTON_STATE.VISIBLE if canAccept: submitState |= NOTIFICATION_BUTTON_STATE.ENABLED if canDecline: cancelState |= NOTIFICATION_BUTTON_STATE.ENABLED else: submitState = cancelState = 0 formatter = ClubInviteHtmlTextFormatter() message = g_settings.msgTemplates.format( "clubInvite", ctx={"text": formatter.getText(invite)}, data={ "timestamp": self._createdAt, "icon": makePathToIcon("clubInviteIcon"), "defaultIcon": makePathToIcon("prebattleInviteIcon"), "buttonsStates": {"submit": submitState, "cancel": cancelState}, }, ) self._vo = { "typeID": self.getType(), "entityID": self.getID(), "message": message, "notify": self.isNotify(), "auxData": [], }
def _make(self, entity=None, settings=None): self._settings = NotificationGuiSettings(True, NotificationPriorityLevel.MEDIUM, showAt=_makeShowTime()) name = self._getName(entity) formatter = ClanAppActionHtmlTextFormatter(self._actionType) message = g_settings.msgTemplates.format( "clanSimple", ctx={"text": formatter.getText(name)}, data={ "timestamp": self._createdAt, "icon": makePathToIcon("clanInviteIcon"), "defaultIcon": makePathToIcon("InformationIcon"), }, ) self._vo = { "typeID": self.getType(), "entityID": self.getID(), "message": message, "notify": self.isNotify(), "auxData": [], }
def _make(self, activeApps=None, settings=None): self._settings = NotificationGuiSettings(True, NotificationPriorityLevel.HIGH, showAt=_makeShowTime()) activeApps = activeApps or [] formatter = ClubAppsHtmlTextFormatter() message = g_settings.msgTemplates.format( "clubApps", ctx={"text": formatter.getText(len(activeApps))}, data={ "timestamp": self._createdAt, "icon": makePathToIcon("InformationIcon"), "defaultIcon": makePathToIcon("InformationIcon"), "buttonsStates": {"submit": NOTIFICATION_BUTTON_STATE.DEFAULT}, }, ) self._vo = { "typeID": self.getType(), "entityID": self.getID(), "message": message, "notify": self.isNotify(), "auxData": [], }
def _make(self, entity=None, settings=None): self._settings = NotificationGuiSettings( isNotify=True, priorityLevel=NotificationPriorityLevel.MEDIUM) message = g_settings.msgTemplates.format( 'ProgressiveRewardNotification', data={'icon': makePathToIcon('InformationIcon')}) self._vo = { 'typeID': self.getType(), 'entityID': self.getID(), 'message': message, 'notify': self.isNotify(), 'auxData': [] }
def _make(self, entity=None, settings=None): self._settings = NotificationGuiSettings( isNotify=True, priorityLevel=NotificationPriorityLevel.HIGH) message = g_settings.msgTemplates.format('MissingEventsNotification', ctx={'count': entity}) message['icon'] = makePathToIcon(message['icon']) self._vo = { 'typeID': self.getType(), 'entityID': self.getID(), 'message': message, 'notify': self.isNotify(), 'auxData': [] }
def _make(self, formatted=None, settings=None): if settings: self._settings = settings if not self._settings.showAt: self._settings.showAt = _makeShowTime() message = formatted.copy() if formatted else {} for key in _ICONS_FIELDS: if key in formatted: message[key] = makePathToIcon(message[key]) else: message[key] = "" self._vo = {"typeID": self.getType(), "entityID": self.getID(), "message": message, "notify": self.isNotify()}
def _make(self, entity=None, settings=None): if self._settings is None: self._settings = NotificationGuiSettings(True, NotificationPriorityLevel.MEDIUM, showAt=_makeShowTime()) formatter = self._getFormatter() message = g_settings.msgTemplates.format( self._getTemplateId(), ctx={"text": self._getText(formatter, entity)}, data={ "timestamp": self._createdAt, "icon": makePathToIcon("clanInviteIcon"), "defaultIcon": makePathToIcon("InformationIcon"), "buttonsStates": self._getButtonsStates(entity), }, ) self._vo = { "typeID": self.getType(), "entityID": self.getID(), "message": message, "notify": self.isNotify(), "auxData": [], } return
def _make(self, formatted=None, settings=None): if settings: self._settings = settings if not self._settings.showAt: self._settings.showAt = _makeShowTime() message = formatted.copy() if formatted else {} for key in _ICONS_FIELDS: if key in formatted: message[key] = makePathToIcon(message[key]) message[key] = '' self._vo = {'typeID': self.getType(), 'entityID': self.getID(), 'message': message, 'notify': self.isNotify()}
def _make(self, invite = None, settings = None): invite = invite or g_clubsCtrl.getProfile().getInvite(self._entityID) if not invite: LOG_ERROR('Invite not found', self._entityID) self._vo = {} self._settings = NotificationGuiSettings(False, NotificationPriorityLevel.LOW, showAt=_makeShowTime()) return if not invite.showAt() or invite.isActive(): if invite.showAt() > 0: self._isOrderChanged = True invite.setShowTime(_makeShowTime()) if invite.isActive(): self._settings = NotificationGuiSettings(True, NotificationPriorityLevel.HIGH, showAt=invite.showAt()) else: self._settings = NotificationGuiSettings(False, NotificationPriorityLevel.LOW, showAt=invite.showAt()) canAccept = invite.isActive() canDecline = invite.isActive() if canAccept or canDecline: submitState = cancelState = NOTIFICATION_BUTTON_STATE.VISIBLE if canAccept: submitState |= NOTIFICATION_BUTTON_STATE.ENABLED if canDecline: cancelState |= NOTIFICATION_BUTTON_STATE.ENABLED else: submitState = cancelState = 0 formatter = ClubInviteHtmlTextFormatter() message = g_settings.msgTemplates.format('clubInvite', ctx={'text': formatter.getText(invite)}, data={'timestamp': self._createdAt, 'icon': makePathToIcon('clubInviteIcon'), 'defaultIcon': makePathToIcon('prebattleInviteIcon'), 'buttonsStates': {'submit': submitState, 'cancel': cancelState}}) self._vo = {'typeID': self.getType(), 'entityID': self.getID(), 'message': message, 'notify': self.isNotify(), 'auxData': []}
def _make(self, formatted = None, settings = None): if settings: self._settings = settings if not self._settings.showAt: self._settings.showAt = _makeShowTime() message = formatted.copy() if formatted else {} for key in ['icon', 'defaultIcon', 'bgIcon']: if key in formatted: message[key] = makePathToIcon(message[key]) else: message[key] = '' self._vo = {'typeID': self.getType(), 'entityID': self.getID(), 'message': message, 'notify': self.isNotify()}
def _make(self, user=None, settings=None): if settings: self._settings = settings contacts = self.proto.contacts if user.getItemType() in XMPP_ITEM_TYPE.SUB_PENDING_ITEMS: self._receivedAt = user.getItem().receivedAt() canCancel, error = contacts.canCancelFriendship(user) if canCancel: canApprove, error = contacts.canApproveFriendship(user) else: canApprove = False if canApprove or canCancel: submitState = cancelState = NOTIFICATION_BUTTON_STATE.VISIBLE if canApprove: submitState |= NOTIFICATION_BUTTON_STATE.ENABLED if canCancel: cancelState |= NOTIFICATION_BUTTON_STATE.ENABLED self._settings.isNotify = True self._settings.priorityLevel = NotificationPriorityLevel.HIGH else: submitState = cancelState = NOTIFICATION_BUTTON_STATE.HIDDEN message = g_settings.msgTemplates.format( "friendshipRequest", ctx={"text": makeFriendshipRequestText(user, error)}, data={ "timestamp": self._receivedAt, "icon": makePathToIcon("friendshipIcon"), "buttonsStates": {"submit": submitState, "cancel": cancelState}, }, ) self._vo = { "typeID": self.getType(), "entityID": self.getID(), "message": message, "notify": self.isNotify(), "auxData": [], }