void Handle354(IrcLine line) { if (line.AccountName == "0") { if (queue.ContainsKey(line.Nick)) { SendPrivmsg(line.Nick, "You must be identified with nickserv to use this command."); queue.Remove(line.Nick); } } else { Channel channel = Server.ConnectedChannels.FirstOrDefault(x => x.Name == line.IrcCommandArgsRaw); Nick ircNick = FetchIrcNick(line.Nick); if (ircNick == null) { if (queue.ContainsKey(line.Nick)) { queue.Remove(line.Nick); } throw new Exception(String.Format("Unable to fetch or create nick `{0}`", line.Nick)); } bool found = false; foreach (Channel c in Server.ConnectedChannels) { if (c.ConnectedNicks.Contains(ircNick) || ircNick.ConnectedChannels.Contains(c)) { found = true; break; } } if (!found) { List <string> channels = new List <string>(); foreach (Channel c in Server.ConnectedChannels) { channels.Add(c.Name); } if (queue.ContainsKey(line.Nick)) { queue.Remove(line.Nick); } logger.Info("Ignoring {0} because they're not in at least one of the following channels: {1}", line.Nick, string.Join(", ", channels)); return; } Account ircAccount = Account.FetchOrCreate(line.AccountName, Server); if (ircAccount == null) { if (queue.ContainsKey(line.Nick)) { queue.Remove(line.Nick); } throw new Exception(String.Format("Unable to fetch or create account `{0}`", line.AccountName)); } if (ircNick.Account == null) { ircNick.Account = ircAccount; ircNick.AccountId = ircAccount.Id; LumbricusContext.db.SaveChanges(); } else if (ircNick.Account.Id != ircAccount.Id && queue.ContainsKey(line.Nick)) { SendPrivmsg(line.Nick, "Sorry, but nick `{0}` is not registered to your services account. Please log in on that account and try again."); SendPrivmsg("TwoWholeWorms", String.Format("Services account `{0}` attempted to access features for nick `{1}` but that nick is registered to services account `{2}`.", ircAccount.Name, ircNick.Name, ircNick.Account.Name)); if (queue.ContainsKey(line.Nick)) { queue.Remove(line.Nick); } return; } Seen.Update(Server, ircNick, ircAccount, channel); if (queue.ContainsKey(line.Nick)) { if (CheckBans(ircNick, ircAccount, line.User, line.Host)) { if (queue.ContainsKey(line.Nick)) { queue.Remove(line.Nick); } return; } foreach (IrcLine queuedLine in queue.Single(x => x.Key == line.Nick).Value) { if (!string.IsNullOrWhiteSpace(queuedLine.Command)) { if (Commands.ContainsKey(queuedLine.Command)) { AbstractCommand command = Commands.Single(x => x.Key == queuedLine.Command).Value; if (command == null) { SendPrivmsg(queuedLine.Nick, String.Format("Sorry, {0}, but I'm unable to do that at this time. Poke TwoWholeWorms to fix me. :(", queuedLine.Nick)); logger.Error("Command `{0}` is registered with a null handler!", queuedLine.Command); } else { command.HandleCommand(queuedLine, ircNick, channel); } } else { SendPrivmsg(queuedLine.Nick, String.Format("Sorry, {0}, but that command does not exist. Try !help.", queuedLine.Nick)); } } // switch (command) { // case "setmugshot": // Command.HandleSetMugshot(ircNick, args, this); // break; // // case "clearmugshot": // Command.HandleClearMugshot(ircNick, args, this); // break; // // case "setinfo": // Command.HandleSetInfo(ircNick, args, this); // break; // // case "clearinfo": // Command.HandleClearInfo(ircNick, args, this); // break; // // case "seen": // Command.HandleSeen(ircNick, args, this, c); // break; // // case "help": // Command.HandleHelp(ircNick, args, this, c); // break; // // case "baninfo": // Command.HandleBanInfo(ircNick, args, this, c); // break; // // case "botban": // Command.HandleBotBan(ircNick, args, this, c); // break; // // case "searchlog": // Command.HandleSearchLog(ircNick, args, this, c); // break; // // case "restart": // Command.HandleUnwrittenAdminCommand(ircNick, args, this, c); // break; // if (channel != null && !channel.AllowCommandsInChannel && queuedLine.IrcCommandArgsRaw != Server.BotNick) { SendPrivmsg(line.Nick, "Also, please try to only interact with me directly through this window. Bot commands in the channel are against channel policy, and some people get really annoyed about it. :("); } } queue.Remove(line.Nick); } } }