예제 #1
0
    void Del(string channel, string nick, string deletions, int?assocPat)
    {
        var numbers = InputTools.GetNumbers(deletions);

        // If we got no numbers, assume it's a list of patterns (or parts thereof) to be deleted.
        // Search include patterns (no search for excludes) for pattern by their substrings.
        if (assocPat == null && numbers.Count == 0)
        {
            var delPatterns = InputTools.GetPatterns(deletions);
            numbers = feedPatterns.Search(channel, delPatterns);
            // Search returns results in the order they were requested, so we need to sort.
            numbers.Sort();
        }
        numbers = InputTools.PrepareDeletions(numbers);

        string removedPattern;

        if (assocPat == null)
        {
            foreach (int n in numbers)
            {
                removedPattern = feedPatterns.Remove(channel, n);
                if (removedPattern != null)
                {
                    irc.SendNotice(nick, "Deleted pattern: {0}", removedPattern);
                }
            }
        }
        else if (assocPat >= 0)
        {
            foreach (int n in numbers)
            {
                removedPattern = feedPatterns.RemoveExclude(channel, assocPat.Value, n);
                if (removedPattern != null)
                {
                    irc.SendNotice(nick, "Removed exclude pattern: {0}", removedPattern);
                }
            }
        }
        else
        {
            foreach (int n in numbers)
            {
                removedPattern = feedPatterns.RemoveGlobalExclude(channel, n);
                if (removedPattern != null)
                {
                    irc.SendNotice(nick, "Removed global exclude pattern: {0}", removedPattern);
                }
            }
        }
        irc.SendNotice(nick, " -----");
    }
예제 #2
0
    void Add(string channel, string nick, string patternsStr, int?assocPat)
    {
        var patterns = InputTools.GetPatterns(patternsStr);

        int amount = 0;

        if (assocPat == null)
        {
            foreach (var pattern in patterns)
            {
                if (feedPatterns.Add(channel, pattern) != -1)
                {
                    amount++;
                }
            }

            irc.SendNotice(nick, "Added {0} pattern(s)", amount);
        }
        else if (assocPat >= 0)
        {
            foreach (var pattern in patterns)
            {
                if (feedPatterns.AddExclude(channel, assocPat.Value, pattern) != -1)
                {
                    amount++;
                }
            }

            irc.SendNotice(nick, "Added {0} exclude pattern(s)", amount);
        }
        else
        {
            foreach (var pattern in patterns)
            {
                if (feedPatterns.AddGlobalExclude(channel, pattern) != -1)
                {
                    amount++;
                }
            }

            irc.SendNotice(nick, "Added {0} global exclude pattern(s)", amount);
        }
    }