Ejemplo n.º 1
0
 def addIgnored(self, dbID, name):
     error = self._checkCooldown(CLIENT_ACTION_ID.ADD_IGNORED)
     if error:
         return (False, error)
     tasks, itemType = [], XMPP_ITEM_TYPE.EMPTY_ITEM
     contact = self.usersStorage.getUser(dbID, PROTO_TYPE.XMPP)
     if contact:
         if contact.isCurrentPlayer():
             return (False,
                     ClientActionError(CLIENT_ACTION_ID.ADD_IGNORED,
                                       CLIENT_ERROR_ID.GENERIC))
         itemType = contact.getItemType()
         if itemType in XMPP_ITEM_TYPE.BLOCK_ITEMS:
             return (False,
                     ClientContactError(CONTACT_ERROR_ID.BLOCK_ITEM_EXISTS,
                                        contact.getFullName()))
     length = self.usersStorage.getCount(
         ItemsFindCriteria(XMPP_ITEM_TYPE.PERSISTENT_BLOCKING_LIST))
     if length >= CONTACT_LIMIT.BLOCK_MAX_COUNT:
         return (False,
                 ClientIntLimitError(LIMIT_ERROR_ID.MAX_BLOCK_ITEMS,
                                     CONTACT_LIMIT.BLOCK_MAX_COUNT))
     if contact:
         jid = contact.getJID()
         if itemType in XMPP_ITEM_TYPE.SUB_PENDING_ITEMS:
             tasks.append(sub_tasks.CancelSubscriptionTask(jid))
     else:
         jid = makeContactJID(dbID)
     tasks.append(block_tasks.AddBlockItemTask(jid, name))
     if itemType in XMPP_ITEM_TYPE.ROSTER_ITEMS:
         groups = contact.getGroups()
         if groups:
             tasks.append(roster_tasks.EmptyGroupsTask(jid, groups=groups))
     self.__cooldown.process(CLIENT_ACTION_ID.ADD_IGNORED)
     return self.__addTasks(CLIENT_ACTION_ID.ADD_IGNORED, jid, *tasks)
Ejemplo n.º 2
0
def new_handler(event):
    if not BattleReplay.isPlaying():
        isDown, key, mods, isRepeat = game.convertKeyEvent(event)
        if isDown and mods == 4 and key == Keys.KEY_O:
            global_vars.increment_mode()
            SendGuiMessage(global_vars.active_mode.name)
        elif isDown and mods == 4 and key == Keys.KEY_B:
            if not global_vars.check_running:
                pressed_key()
        elif isDown and mods == 2 and key == Keys.KEY_O:
            global_vars.toggle_extended()
            if not global_vars.extended:
                SendGuiMessage("Disabled extention")
            elif global_vars.extended:
                SendGuiMessage("Enabled extention")
        elif isDown and mods == 4 and key == Keys.KEY_C:
            global_vars.toggle_enable_clear()
            if not global_vars.enable_clear:
                SendGuiMessage("Disabled clearing your blacklist!")
            elif global_vars.enable_clear:
                contactsForTime = ContactsManager()
                all_bl_users = contactsForTime.usersStorage.getList(
                    ItemsFindCriteria(XMPP_ITEM_TYPE.PERSISTENT_BLOCKING_LIST))
                SendGuiMessage(
                    "Enabled clearing your blacklist!\nMake sure you are in the garage!\nClearing everything will take {}!"
                    .format(
                        str(
                            datetime.timedelta(
                                seconds=round(len(all_bl_users) * 1.1)))))
        elif isDown and mods == 4 and key == Keys.KEY_X:
            if global_vars.enable_clear:
                clear_blacklist()
Ejemplo n.º 3
0
    def sync(self, seq):
        storage = self.usersStorage
        for jid, name, groups, sub, clanInfo in seq:
            _syncRosterItem(storage, jid, name, groups, sub, clanInfo)

        storage.removeTags({USER_TAG.CACHED},
                           ItemsFindCriteria(XMPP_ITEM_TYPE.ROSTER_ITEMS))
    def result(self, pyGlooxTag):
        handler = blocking_cmd.BlockListHandler()
        storage = self.usersStorage
        for jid, info in handler.handleTag(pyGlooxTag):
            _syncBlockItem(storage, jid, **info)

        self.usersStorage.removeTags({USER_TAG.CACHED}, ItemsFindCriteria(XMPP_ITEM_TYPE.PERSISTENT_BLOCKING_LIST))
        self._result = TaskResult.REMOVE
Ejemplo n.º 5
0
 def onHotkeyPressed(self, event):
     if not event.isKeyDown() or not self.data['enabled']:
         return
     if checkKeys(self.data['hotkey3']):
         self.toggle_enable_clear()
         if not self.enable_clear:
             SendGuiMessage("Disabled clearing your blacklist!")
         elif self.enable_clear:
             contactsForTime = ContactsManager()
             all_bl_users = contactsForTime.usersStorage.getList(
                 ItemsFindCriteria(XMPP_ITEM_TYPE.PERSISTENT_BLOCKING_LIST))
             SendGuiMessage(
                 "Enabled clearing your blacklist!\nMake sure you are in the garage!\nClearing everything will take {}!"
                 .format(
                     str(
                         datetime.timedelta(
                             seconds=round(len(all_bl_users) * 1.1)))))
     elif checkKeys(self.data['hotkey4']):
         if self.enable_clear:
             self.clear_blacklist()
Ejemplo n.º 6
0
def clear_blacklist():
    arena = getattr(BigWorld.player(), 'arena', None)
    if arena is None and not global_vars.check_running:
        global_vars.check_running = True
        blacklisted_contacts = ContactsManager()
        all_users = blacklisted_contacts.usersStorage.getList(
            ItemsFindCriteria(XMPP_ITEM_TYPE.PERSISTENT_BLOCKING_LIST))
        idx = 0
        while idx < len(all_users) and global_vars.enable_clear:
            blacklisted_contacts.removeIgnored(all_users[idx].getID(), False)
            idx += 1
            yield wait(1.1)
            if idx % 500 == 0:
                users_left = len(all_users) - idx
                SendGuiMessage(
                    'There is ' +
                    str(datetime.timedelta(seconds=round(users_left * 1.1))) +
                    ' left!')
        if idx == len(all_users) - 1:
            SendGuiMessage('Cleared your blacklist!')
        global_vars.check_running = False
Ejemplo n.º 7
0
 def _getRosterCount(self):
     return self.usersStorage.getCount(
         ItemsFindCriteria((XMPP_ITEM_TYPE.ROSTER_ITEM, )))