示例#1
0
    def set_pingif_count(self, value, old=None):
        temp = self.lower()

        if not value:
            if temp.account in var.PING_IF_PREFS_ACCS:
                del var.PING_IF_PREFS_ACCS[temp.account]
                db.set_pingif(0, temp.account)
                if old is not None:
                    with var.WARNING_LOCK:
                        if old in var.PING_IF_NUMS_ACCS:
                            var.PING_IF_NUMS_ACCS[old].discard(temp.account)
        else:
            if temp.account is not None:
                var.PING_IF_PREFS_ACCS[temp.account] = value
                db.set_pingif(value, temp.account)
                with var.WARNING_LOCK:
                    if value not in var.PING_IF_NUMS_ACCS:
                        var.PING_IF_NUMS_ACCS[value] = set()
                    var.PING_IF_NUMS_ACCS[value].add(temp.account)
                    if old is not None:
                        if old in var.PING_IF_NUMS_ACCS:
                            var.PING_IF_NUMS_ACCS[old].discard(temp.account)
示例#2
0
    def set_pingif_count(self, value, old=None):
        temp = self.lower()

        if not value:
            if not var.DISABLE_ACCOUNTS and temp.account:
                if temp.account in var.PING_IF_PREFS_ACCS:
                    del var.PING_IF_PREFS_ACCS[temp.account]
                    db.set_pingif(0, temp.account, None)
                    if old is not None:
                        with var.WARNING_LOCK:
                            if old in var.PING_IF_NUMS_ACCS:
                                var.PING_IF_NUMS_ACCS[old].discard(
                                    temp.account)

            if not var.ACCOUNTS_ONLY:
                for hostmask in list(var.PING_IF_PREFS):
                    if temp.match_hostmask(hostmask):
                        del var.PING_IF_PREFS[hostmask]
                        db.set_pingif(0, None, hostmask)
                        if old is not None:
                            with var.WARNING_LOCK:
                                if old in var.PING_IF_NUMS:
                                    var.PING_IF_NUMS[old].discard(hostmask)
                                    var.PING_IF_NUMS[old].discard(temp.host)

        else:
            if not var.DISABLE_ACCOUNTS and temp.account:
                var.PING_IF_PREFS_ACCS[temp.account] = value
                db.set_pingif(value, temp.account, None)
                with var.WARNING_LOCK:
                    if value not in var.PING_IF_NUMS_ACCS:
                        var.PING_IF_NUMS_ACCS[value] = set()
                    var.PING_IF_NUMS_ACCS[value].add(temp.account)
                    if old is not None:
                        if old in var.PING_IF_NUMS_ACCS:
                            var.PING_IF_NUMS_ACCS[old].discard(temp.account)

            elif not var.ACCOUNTS_ONLY:
                var.PING_IF_PREFS[temp.userhost] = value
                db.set_pingif(value, None, temp.userhost)
                with var.WARNING_LOCK:
                    if value not in var.PING_IF_NUMS:
                        var.PING_IF_NUMS[value] = set()
                    var.PING_IF_NUMS[value].add(temp.userhost)
                    if old is not None:
                        if old in var.PING_IF_NUMS:
                            var.PING_IF_NUMS[old].discard(temp.host)
                            var.PING_IF_NUMS[old].discard(temp.userhost)