예제 #1
0
        public override void HandleCommand(IrcLine line, Nick nick, Channel channel)
        {
            try {
                if (!isOp(nick))
                {
                    conn.SendPrivmsg(nick.Name, String.Format("Sorry, {0}, but that command doesn't exist. Try !help.", nick.DisplayName));
                    return;
                }

                string target = nick.Name;
                if (channel != null && channel.AllowCommandsInChannel)
                {
                    target = channel.Name;
                }

                Regex r = new Regex(@"^!botban ?");
                line.Args = r.Replace(line.Args, "").Trim();
                if (line.Args.Length <= 0)   // Whaaaat??
                {
                    conn.SendPrivmsg(target, "Usage(1): !botban <add|remove> <nick|$a:account|mask:*!*@*.*> [ban message]");
                }
                else
                {
                    string[] argBits = line.Args.Split(" ".ToCharArray(), 3);
                    if (argBits.Length > 3)
                    {
                        conn.SendPrivmsg(target, "Usage(2): !botban <add|remove> <nick|$a:account|mask:*!*@*.*> [ban message]");
                        return;
                    }

                    string banMessage = null;
                    if (argBits.Length == 3)
                    {
                        banMessage = argBits[2];
                    }

                    string mode = argBits[0];
                    switch (mode)
                    {
                    case "add":
                    case "remove":
                        break;

                    //                        case "remove":
                    //                            if (banMessage != null) {
                    //                                conn.SendPrivmsg(target, "Ban message can't be set when removing a ban, you DERP!");
                    //                                return;
                    //                            }
                    //                            break;

                    default:
                        conn.SendPrivmsg(target, "Usage(3): !botban <add|remove> <nick|$a:account|mask:*!*@*.*> [ban message]");
                        break;
                    }

                    argBits = argBits[1].Split(':');
                    string search     = argBits[0];
                    string searchType = "nick";
                    if (argBits.Length > 2 || (argBits.Length == 2 && argBits[0] != "$a" && argBits[0] != "mask"))
                    {
                        conn.SendPrivmsg(target, "Usage(4): !botban <add|remove> <nick|$a:account|mask:*!*@*.*> [ban message]");
                        return;
                    }
                    if (argBits.Length == 2)
                    {
                        if (argBits[0] == "mask")
                        {
                            search     = argBits[1];
                            searchType = "mask";
                        }
                        else if (argBits[0] == "$a")
                        {
                            search     = argBits[1];
                            searchType = "account";
                        }
                        else
                        {
                            conn.SendPrivmsg(target, "Usage(5): !botban <add|remove> <nick|$a:account|mask:*!*@*.*> [ban message]");
                            return;
                        }
                    }

                    Ban     ircBan     = null;
                    Nick    ircNick    = null;
                    Account ircAccount = null;
                    switch (searchType)
                    {
                    case "nick":
                        ircNick = Nick.Fetch(search, conn.Server);
                        if (ircNick == null)
                        {
                            conn.SendPrivmsg(target, String.Format("{0}{2}{1}: Nick `{3}` does not exist in the database.", "\x02", "\x0f", nick.DisplayName, search));
                            return;
                        }
                        ircAccount = ircNick.Account;
                        ircBan     = Ban.Fetch(ircNick, ircAccount);
                        break;

                    case "account":
                        ircAccount = Account.Fetch(search, conn.Server);
                        if (ircAccount == null)
                        {
                            conn.SendPrivmsg(target, String.Format("{0}{2}{1}: Account `{3}` does not exist in the database.", "\x02", "\x0f", nick.DisplayName, search));
                            return;
                        }
                        ircNick = ircAccount.MostRecentNick;
                        ircBan  = Ban.Fetch(ircNick, ircAccount);
                        break;

                    case "mask":
                        ircBan = Ban.Fetch(conn.Server, search);

                        if (ircBan != null)
                        {
                            if (ircBan.Nick != null)
                            {
                                ircNick = ircBan.Nick;
                            }
                            if (ircBan.Account != null)
                            {
                                ircAccount = ircBan.Account;
                            }
                        }

                        break;

                    default:
                        conn.SendPrivmsg(target, "This what you're seeing here is a big fat error happening. Poke TwoWholeWorms.");
                        break;
                    }

                    if (ircBan == null)
                    {
                        if (mode == "remove")
                        {
                            conn.SendPrivmsg(target, String.Format("{0}{2}{1}: {3} `{4}` is not currently banned.", "\x02", "\x0f", nick.DisplayName, searchType.Capitalise(), search));
                            return;
                        }
                        ircBan = new Ban();
                    }
                    else if (mode == "add" && ircBan.IsMugshotBan)
                    {
                        Account banner = ircBan.BannerAccount;
                        if (banner != null)
                        {
                            conn.SendPrivmsg(target, String.Format("{0}{2}{1}: {3} `{4}` was already banned from accessing {8} by $a:{5} on {6}: {7}", "\x02", "\x0f", nick.DisplayName, searchType.Capitalise(), search, banner.Name, ircBan.CreatedAt.ToString("u"), (ircBan.BanMessage ?? "No message"), conn.Server.BotNick));
                        }
                        else
                        {
                            conn.SendPrivmsg(target, String.Format("{0}{2}{1}: {3} `{4}` was already banned from accessing {7} on {5}: {6}", "\x02", "\x0f", nick.DisplayName, searchType.Capitalise(), search, ircBan.CreatedAt.ToString("u"), (ircBan.BanMessage ?? "No message"), conn.Server.BotNick));
                        }
                        return;
                    }

                    if (ircNick == null && ircAccount != null && ircAccount.MostRecentNick != null)
                    {
                        ircNick = ircAccount.MostRecentNick;
                    }
                    if (ircAccount == null && ircNick != null && ircNick.Account != null)
                    {
                        ircAccount = ircNick.Account;
                    }

                    ircBan.Server       = conn.Server;
                    ircBan.Nick         = ircNick;
                    ircBan.Account      = ircAccount;
                    ircBan.IsMugshotBan = (mode == "add");
                    if (ircBan.IsActive && ircBan.Channel == null)
                    {
                        ircBan.IsActive = false;
                    }
                    if (mode == "add")
                    {
                        ircBan.BanMessage      = banMessage;
                        ircBan.BannerAccount   = nick.Account;
                        ircBan.UnbanMessage    = null;
                        ircBan.UnbannerAccount = null;
                        ircBan.UnbannedAt      = null;
                    }
                    else if (mode == "remove")
                    {
                        ircBan.UnbanMessage    = banMessage;
                        ircBan.UnbannerAccount = nick.Account;
                        ircBan.UnbannedAt      = DateTime.Now;
                    }
                    if (searchType == "mask")
                    {
                        ircBan.Mask = search;
                    }
                    ircBan.Save();

                    if (mode == "add")
                    {
                        conn.SendPrivmsg(target, String.Format("{0}{2}{1}: {3} `{4}` has been banned from accessing {5} features, and their existing mugshot has been hidden from the site.", "\x02", "\x0f", nick.DisplayName, searchType.Capitalise(), search, conn.Server.BotNick));
                    }
                    else
                    {
                        conn.SendPrivmsg(target, String.Format("{0}{2}{1}: {3} `{4}` ban on accessing {5} has been deactivated.", "\x02", "\x0f", nick.DisplayName, searchType.Capitalise(), search, conn.Server.BotNick));
                    }
                    return;
                }
            } catch (Exception e) {
                logger.Error(e);
                conn.SendPrivmsg(nick.Name, "Aieee! The bees! The BEEES! They're chasing me away!!! (Get TwoWholeWorms!)");
            }
        }
예제 #2
0
        public override void HandleCommand(IrcLine line, Nick nick, Channel channel)
        {
            try {
                if (!isOp(nick))
                {
                    conn.SendPrivmsg(nick.Name, String.Format("Sorry, {0}, but that command doesn't exist. Try !help.", nick.DisplayName));
                    return;
                }

                string target = nick.Name;
                if (channel != null && channel.AllowCommandsInChannel)
                {
                    target = channel.Name;
                }

                Regex r = new Regex(@"^!searchlog ?");
                line.Args = r.Replace(line.Args, "").Trim();
                if (line.Args.Length <= 0)   // Whaaaat??
                {
                    conn.SendPrivmsg(target, String.Format("Usage(1): !searchlog <search> - search examples: id:1 nick:{0} $a:{1}, #lumbricus, \"Magnus Magnusson\"", nick.DisplayName, nick.Account.Name));
                }
                else
                {
                    string[] argBits;
                    string   search     = line.Args;
                    string   searchType = "string";
                    long     searchId   = 0;

                    if (line.Args.StartsWith("id:"))
                    {
                        if (line.Args.Contains(" "))
                        {
                            conn.SendPrivmsg(target, String.Format("\x02{0}\x0f: ID searches cannot contain spaces.", nick.DisplayName));
                            return;
                        }
                        argBits = line.Args.Split(':');
                        search  = argBits[1];
                        Int64.TryParse(search, out searchId);
                        if (searchId < 1)
                        {
                            conn.SendPrivmsg(target, String.Format("\x02{0}\x0f: ID must be > 0.", nick.DisplayName));
                            return;
                        }
                        searchType = "id";
                    }

                    if (line.Args.StartsWith("nick:"))
                    {
                        if (line.Args.Contains(" "))
                        {
                            conn.SendPrivmsg(target, String.Format("\x02{0}\x0f: Nick searches cannot contain spaces.", nick.DisplayName));
                            return;
                        }
                        argBits    = line.Args.Split(':');
                        search     = argBits[1];
                        searchType = "nick";
                    }

                    if (line.Args.StartsWith("$a:"))
                    {
                        if (line.Args.Contains(" "))
                        {
                            conn.SendPrivmsg(target, String.Format("\x02{0}\x0f: Account searches cannot contain spaces.", nick.DisplayName));
                            return;
                        }
                        argBits    = line.Args.Split(':');
                        search     = argBits[1];
                        searchType = "account";
                    }

                    if (line.Args.StartsWith("#"))
                    {
                        if (line.Args.Contains(" "))
                        {
                            conn.SendPrivmsg(target, String.Format("\x02{0}\x0f: Channel searches cannot contain spaces.", nick.DisplayName));
                            return;
                        }
                        search     = line.Args;
                        searchType = "channel";
                    }

                    if (searchType == "string")
                    {
                        if (!line.Args.StartsWith("\"") || !line.Args.EndsWith("\"") || line.Args.Count(f => f == '\"') != 2)
                        {
                            conn.SendPrivmsg(target, String.Format("Usage(2): !searchlog <search> - search examples: id:1 nick:{0} $a:{1}, #lumbricus, \"Magnus Magnusson\"", nick.DisplayName, nick.Account.Name));
                            return;
                        }

                        if (line.Args.Trim().Replace("%", "").Length < 7)
                        {
                            conn.SendPrivmsg(target, String.Format("\x02{0}\x0f: Text searches must be at least 5 characters long, not including wildcards.", nick.DisplayName));
                            return;
                        }

                        search = line.Args.Substring(1, (line.Args.Length - 2));
                    }

                    Log ignoreLogLine = Log.Fetch(nick);

                    long    totalLines    = 0;
                    Log     logLine       = null;
                    Account searchAccount = null;
                    Nick    searchNick    = null;
                    Channel searchChannel = null;
                    switch (searchType)
                    {
                    case "id":
                        logLine    = Log.Fetch(searchId);
                        totalLines = (logLine == null ? 0 : 1);
                        if (logLine != null)
                        {
                            if (logLine.Channel != null)
                            {
                                searchChannel = Channel.Fetch(logLine.Channel.Id);
                            }
                        }
                        else
                        {
                            conn.SendPrivmsg(target, String.Format("\x02{0}\x0f: Log entry id `{1}` does not exist.", nick.DisplayName, searchId));
                            return;
                        }
                        break;

                    case "string":
                        if (search.Contains("\""))
                        {
                            search = search.Replace("\"", "");
                        }
                        totalLines = Log.FetchTotal(search);
                        logLine    = Log.Fetch(search, ignoreLogLine, channel);
                        if (logLine != null)
                        {
                            if (logLine.Channel != null)
                            {
                                searchChannel = Channel.Fetch(logLine.Channel.Id);
                            }
                        }
                        else
                        {
                            conn.SendPrivmsg(target, String.Format("\x02{0}\x0f: No results for search `{1}`.", nick.DisplayName, search));
                            return;
                        }
                        break;

                    case "account":
                        searchAccount = Account.Fetch(search.ToLower(), conn.Server);
                        if (searchAccount == null)
                        {
                            conn.SendPrivmsg(target, String.Format("\x02{0}\x0f: There is no account `{1}` in the database", nick.DisplayName, search));
                            return;
                        }
                        if (searchAccount.MostRecentNick != null)
                        {
                            searchNick = searchAccount.MostRecentNick;
                            totalLines = Log.FetchTotal(searchNick);
                            logLine    = Log.Fetch(searchNick, ignoreLogLine, channel);
                        }
                        else
                        {
                            totalLines = Log.FetchTotal(searchAccount);
                            logLine    = Log.Fetch(searchAccount, ignoreLogLine, channel);
                        }
                        if (logLine != null)
                        {
                            if (logLine.Channel != null)
                            {
                                searchChannel = Channel.Fetch(logLine.Channel.Id);
                            }
                        }
                        else
                        {
                            conn.SendPrivmsg(target, String.Format("\x02{0}\x0f: $a:{1} is not in the log (?!)", nick.DisplayName, searchAccount.Name));
                            return;
                        }
                        break;

                    case "nick":
                        searchNick = Nick.Fetch(search.ToLower(), conn.Server);
                        if (searchNick == null)
                        {
                            conn.SendPrivmsg(target, String.Format("\x02{0}\x0f: There is no nick `{1}` in the database", nick.DisplayName, search));
                            return;
                        }
                        if (searchNick.Account != null)
                        {
                            searchAccount = searchNick.Account;
                        }
                        totalLines = Log.FetchTotal(searchNick);
                        logLine    = Log.Fetch(searchNick, ignoreLogLine, channel);
                        if (logLine != null)
                        {
                            if (logLine.Channel != null)
                            {
                                searchChannel = Channel.Fetch(logLine.Channel.Id);
                            }
                        }
                        else
                        {
                            conn.SendPrivmsg(target, String.Format("\x02{0}\x0f: nick:{1} is not in the log (?!)", nick.DisplayName, searchNick.DisplayName));
                            return;
                        }
                        break;

                    case "channel":
                        searchChannel = Channel.Fetch(search.ToLower(), conn.Server);
                        if (searchChannel == null)
                        {
                            conn.SendPrivmsg(target, String.Format("\x02{0}\x0f: There is no channel `{1}` in the database", nick.DisplayName, search));
                            return;
                        }
                        totalLines = Log.FetchTotal(searchChannel);
                        logLine    = Log.Fetch(searchChannel, ignoreLogLine);
                        if (logLine == null)
                        {
                            conn.SendPrivmsg(target, String.Format("\x02{0}\x0f: {1} is not in the log (?!)", nick.DisplayName, searchChannel.Name));
                            return;
                        }
                        break;
                    }

                    if (logLine == null)
                    {
                        conn.SendPrivmsg(target, String.Format("\x02{0}\x0f: This message should never appear, what the HELL did you DO to me?! D:", nick.DisplayName));
                        return;
                    }

                    string response = totalLines + " found, latest: " + (searchChannel != null ? searchChannel.Name : conn.Server.BotNick) + " [" + logLine.LoggedAt.ToString("u") + "] " + logLine.Line;
                    conn.SendPrivmsg(target, response);
                }
            } catch (Exception e) {
                logger.Error(e);
                conn.SendPrivmsg(nick.Name, "Oof… My spleen…! I can't do that right now. :(");
            }
        }
예제 #3
0
        public override void HandleCommand(IrcLine line, Nick nick, Channel channel)
        {
            try {
                if (nick.Account == null || !isOp(nick))
                {
                    conn.SendPrivmsg(nick.Name, String.Format("Sorry, {0}, but the !seen command doesn't exist. Try !help.", nick.DisplayName));
                    return;
                }

                string target = nick.Name;
                if (channel != null && channel.AllowCommandsInChannel)
                {
                    target = channel.Name;
                }

                Regex r = new Regex(@"^!seen ?");
                line.Args = r.Replace(line.Args, "").Trim();
                if (line.Args.Length <= 0)   // Whaaaat??
                {
                    conn.SendPrivmsg(target, String.Format("Usage: !seen <search> - use $a:account to search for an account (eg, !seen $a:{0})", nick.Account.Name));
                }
                else
                {
                    string[] argBits = line.Args.Split(' ');
                    if (argBits.Length > 1)
                    {
                        conn.SendPrivmsg(target, String.Format("Usage: !seen <search> - use $a:account to search for an account (eg, !seen $a:{0})", nick.Account.Name));
                        return;
                    }

                    argBits = argBits[0].Split(':');
                    string search     = argBits[0];
                    string searchType = "nick";
                    if (argBits.Length == 2)
                    {
                        if (argBits[0] != "$a")
                        {
                            conn.SendPrivmsg(target, String.Format("Usage: !seen <search> - use $a:account to search for an account (eg, !seen $a:{0})", nick.Account.Name));
                            return;
                        }
                        search     = argBits[1];
                        searchType = "account";
                    }

                    Nick      ircNick    = null;
                    Account   ircAccount = null;
                    Channel   ircChannel = null;
                    SeenModel ircSeen    = null;
                    if (searchType == "account")
                    {
                        ircAccount = Account.Fetch(search.ToLower(), conn.Server);
                        if (ircAccount != null)
                        {
                            ircSeen = SeenModel.FetchByAccountId(ircAccount.Id);
                            if (ircSeen != null)
                            {
                                if (ircSeen.Nick != null)
                                {
                                    ircNick = ircSeen.Nick;
                                }
                                if (ircSeen.Channel != null)
                                {
                                    ircChannel = ircSeen.Channel;
                                }
                            }
                        }
                    }
                    else
                    {
                        ircNick = Nick.Fetch(search.ToLower(), conn.Server);
                        if (ircNick != null)
                        {
                            ircSeen = SeenModel.FetchByNickId(ircNick.Id);
                            if (ircSeen != null)
                            {
                                if (ircSeen.Account != null)
                                {
                                    ircAccount = ircSeen.Account;
                                }
                                if (ircSeen.Channel != null)
                                {
                                    ircChannel = ircSeen.Channel;
                                }
                            }
                        }
                    }

                    if (ircSeen == null)
                    {
                        conn.SendPrivmsg(target, String.Format("There is no seen data in the database about {0} `{1}`.", searchType, search));
                    }
                    else
                    {
                        string seenNick    = (ircNick != null ? ircNick.DisplayName : "Unknown Nick");
                        string seenAccount = (ircAccount != null ? ircAccount.Name : "Unknown Account");
                        string seenChannel = (ircChannel != null ? ircChannel.Name : "a private query window");

                        conn.SendPrivmsg(target, String.Format("{1}{0}{2}{1} ($a:{0}{3}{1}): First seen {0}{4}{1}, last seen {0}{5}{1} in {1}{0}{6}{1}.", "\x02", "\x0f", seenNick, seenAccount, ircSeen.FirstSeenAt.ToString("u"), ircSeen.LastSeenAt.ToString("u"), seenChannel));
                    }
                }
            } catch (Exception e) {
                logger.Error(e);
                conn.SendPrivmsg(nick.Name, "Oof… My spleen…! I can't do that right now. :(");
            }
        }
예제 #4
0
        public override void HandleCommand(IrcLine line, Nick nick, Channel channel)
        {
            try {
                if (!isOp(nick))
                {
                    conn.SendPrivmsg(nick.Name, String.Format("Sorry, {0}, but that command doesn't exist. Try !help.", nick.DisplayName));
                    return;
                }

                string target = nick.Name;
                if (channel != null && channel.AllowCommandsInChannel)
                {
                    target = channel.Name;
                }

                Regex r = new Regex(@"^!baninfo ?");
                line.Args = r.Replace(line.Args, "").Trim();
                if (line.Args.Length <= 0)   // Whaaaat??
                {
                    conn.SendPrivmsg(target, String.Format("Usage(1): !baninfo <search> - Prefix search with $a: to search for an account, or mask: to search for a ban string, eg !baninfo $a:{0} !baninfo mask:*!*@*.no", nick.Account.Name));
                }
                else
                {
                    string[] argBits = line.Args.Split(' ');
                    if (argBits.Length > 1)
                    {
                        conn.SendPrivmsg(target, String.Format("Usage(2): !baninfo <search> - Prefix search with $a: to search for an account, or mask: to search for a ban string, eg !baninfo $a:{0} !baninfo mask:*!*@*.no", nick.Account.Name));
                        return;
                    }

                    argBits = argBits[0].Split(':');
                    string search     = argBits[0];
                    string searchType = "nick";
                    if (argBits.Length > 2 || (argBits.Length == 2 && argBits[0] != "$a" && argBits[0] != "mask"))
                    {
                        conn.SendPrivmsg(target, String.Format("Usage(3): !baninfo <search> - Prefix search with $a: to search for an account, or mask: to search for a ban string, eg !baninfo $a:{0} !baninfo mask:*!*@*.no", nick.Account.Name));
                        return;
                    }
                    if (argBits.Length == 2)
                    {
                        if (argBits[0] == "mask")
                        {
                            search     = argBits[1];
                            searchType = "mask";
                        }
                        else if (argBits[0] == "$a")
                        {
                            search     = argBits[1];
                            searchType = "account";
                        }
                        else
                        {
                            conn.SendPrivmsg(target, String.Format("Usage(4): !baninfo <search> - Prefix search with $a: to search for an account, or mask: to search for a ban string, eg !baninfo $a:{0} !baninfo mask:*!*@*.no", nick.Account.Name));
                            return;
                        }
                    }

                    Account    bannedAccount = null;
                    Nick       bannedNick    = null;
                    List <Ban> ircBans       = new List <Ban>();
                    switch (searchType)
                    {
                    case "account":
                        bannedAccount = Account.Fetch(search.ToLower(), conn.Server);
                        if (bannedAccount == null)
                        {
                            conn.SendPrivmsg(target, String.Format("There is no account `{0}` in the database", search));
                            return;
                        }
                        bannedNick         = bannedAccount.MostRecentNick;
                        bannedNick.Account = bannedAccount;
                        ircBans            = Ban.Fetch(bannedNick).ToList();
                        break;

                    case "nick":
                        bannedNick = Nick.Fetch(search.ToLower(), conn.Server);
                        if (bannedNick == null)
                        {
                            conn.SendPrivmsg(target, String.Format("There is no nick `{0}` in the database", search));
                            return;
                        }
                        bannedAccount = bannedNick.Account;
                        ircBans       = Ban.Fetch(bannedNick).ToList();
                        break;

                    case "mask":
                        Ban ircBan = Ban.Fetch(conn.Server, search);
                        if (ircBan == null)
                        {
                            conn.SendPrivmsg(target, String.Format("There is no ban on mask `{0}` in the database", search));
                            return;
                        }
                        if (ircBan.Account != null)
                        {
                            bannedAccount = ircBan.Account;
                        }
                        if (ircBan.Nick != null)
                        {
                            bannedNick = ircBan.Nick;
                        }

                        if (bannedAccount != null && bannedNick == null && bannedAccount.MostRecentNick != null)
                        {
                            bannedNick = bannedAccount.MostRecentNick;
                        }
                        if (bannedNick != null && bannedAccount == null && bannedNick.Account != null)
                        {
                            bannedAccount = bannedNick.Account;
                        }

                        if (ircBan != null)
                        {
                            ircBans.Add(ircBan);
                        }
                        break;
                    }

                    if (ircBans.Count < 1)
                    {
                        if (bannedNick != null && bannedAccount != null)
                        {
                            conn.SendPrivmsg(target, String.Format("\x02{0}\x0f: {2} ($a:{1}) is not banned.", nick.DisplayName, bannedAccount.Name, bannedNick.DisplayName));
                        }
                        else if (bannedAccount != null)
                        {
                            conn.SendPrivmsg(target, String.Format("\x02{0}\x0f: $a:{1} is not banned.", nick.DisplayName, bannedAccount.Name));
                        }
                        else if (bannedNick != null)
                        {
                            conn.SendPrivmsg(target, String.Format("\x02{0}\x0f: `{1}` is not banned.", nick.DisplayName, bannedNick.DisplayName));
                        }
                        else
                        {
                            conn.SendPrivmsg(target, String.Format("\x02{0}\x0f: This message should never appear, what the HELL did you DO to me?! D:", nick.DisplayName));
                        }
                        return;
                    }

                    int i = 0;
                    foreach (Ban ircBan in ircBans)
                    {
                        string response = String.Format("\x02{0}\x0f: #{1}", nick.DisplayName, ircBan.Id);
                        if (searchType == "account")
                        {
                            response += " $a:" + bannedAccount.Name;
                            if (bannedNick != null)
                            {
                                response += " (" + bannedNick.DisplayName + ")";
                            }
                        }
                        else
                        {
                            response += " " + bannedNick.DisplayName;
                            if (bannedAccount != null)
                            {
                                response += " ($a:" + bannedAccount.Name + ")";
                            }
                        }

                        Channel bannedChannel = ircBan.Channel;
                        response += " " + conn.Server.BotNick + ((ircBan.IsMugshotBan || (bannedChannel != null && ircBan.IsActive)) ? ":" : ":un") + "banned";
                        if (bannedChannel != null)
                        {
                            response += " " + bannedChannel.Name + (!ircBan.IsActive ? ":un" : ":") + "banned";
                        }
                        response += " ban:[" + ircBan.CreatedAt.ToString("u");

                        if (!string.IsNullOrEmpty(ircBan.Mask))
                        {
                            response += " mask:" + ircBan.Mask;
                        }

                        Account cantankerousOp = ircBan.BannerAccount;
                        if (cantankerousOp != null)
                        {
                            if (cantankerousOp.MostRecentNick != null)
                            {
                                response += " op:" + cantankerousOp.MostRecentNick.DisplayName;
                            }
                            else
                            {
                                response += " op:$a:" + cantankerousOp.Name;
                            }
                        }
                        if (!string.IsNullOrWhiteSpace(ircBan.BanMessage))
                        {
                            response += " reason:" + ircBan.BanMessage;
                        }
                        response += "]";

                        if (ircBan.UnbannerAccount != null)
                        {
                            Account unbanner = ircBan.UnbannerAccount;

                            response += " unban:[" + ircBan.UnbannedAt.Value.ToString("u");
                            if (unbanner != null)
                            {
                                if (unbanner.MostRecentNick != null)
                                {
                                    response += " op:" + unbanner.MostRecentNick.DisplayName;
                                }
                                else
                                {
                                    response += " op:$a:" + unbanner.Name;
                                }
                            }
                            if (!string.IsNullOrWhiteSpace(ircBan.UnbanMessage))
                            {
                                response += " msg:" + ircBan.UnbanMessage;
                            }
                            response += "]";
                        }
                        if (i > 2)
                        {
                            Thread.Sleep(2000);        // Wait 2 secs between sending commands after 3, in case there's loads of bans to send
                        }
                        conn.SendPrivmsg(target, response);
                        i++;

                        if (i > 5)
                        {
                            break;
                        }
                    }
                }
            } catch (Exception e) {
                logger.Error(e);
                conn.SendPrivmsg(nick.Name, "Oof… My spleen…! I can't do that right now. :(");
            }
        }