private void HandleIrcCommand(string message) { var IMessage = new IRCMessage(); IMessage.ServerId = _serverid; IMessage.ServerName = _servername; string[] IrcCommand = message.Split(SchumixBase.Space); IrcCommand[0] = IrcCommand[0].Remove(0, 1, SchumixBase.Colon); IMessage.Hostmask = IrcCommand[0]; if (IrcCommand.Length > 2) { IMessage.Channel = sUtilities.SqlEscape(IrcCommand[2]); } string[] userdata = IMessage.Hostmask.Split('!'); IMessage.Nick = sUtilities.SqlEscape(userdata[0]); if (userdata.Length > 1) { string[] hostdata = userdata[1].Split('@'); IMessage.User = hostdata[0]; IMessage.Host = hostdata[1]; } string opcode = IrcCommand[1]; IMessage.Info = IrcCommand; IMessage.Args = IrcCommand.SplitToString(3, SchumixBase.Space); IMessage.Args = IMessage.Args.Remove(0, 1, SchumixBase.Colon); IMessage.SetMessageType(); if (IrcMethodMap.ContainsKey(opcode)) { IrcMethodMap[opcode].Method.Invoke(IMessage); return; } else { if (IrcCommand[0] == "PING") { sSender.Pong(IrcCommand[1].Remove(0, 1, SchumixBase.Colon)); return; } else if (IrcCommand[0] == "ERROR") { NetworkQuit = true; return; } else { if (ConsoleLog.CLog) { Log.Notice("HandleIrcCommand", sLConsole.GetString("Received unhandled opcode: {0}"), opcode); } } } }
/// <summary> /// Ha a ConsoleLog be van kapcsolva, akkor /// kiírja a console-ra az IRC szerverről fogadott információkat. /// </summary> protected void HandleNotice(IRCMessage sIRCMessage) { if (sIgnoreNickName.IsIgnore(sIRCMessage.Nick)) { return; } sIRCMessage.MessageType = MessageType.Notice; if (ConsoleLog.CLog) { Log.SetForegroundColor(ConsoleColor.Red); if (sIRCMessage.Nick.IsServ()) { Log.Write(sLConsole.GetString("[SERVER] ")); } else { Log.Write("[{0}] ", sIRCMessage.Nick); } Log.SetForegroundColor(ConsoleColor.Yellow); Log.Write("{0}\n", sIRCMessage.Args); Log.LogInFile("{0}{1}", sIRCMessage.Nick.IsServ() ? sLConsole.GetString("[SERVER] ") : string.Format("[{0}] ", sIRCMessage.Nick), sIRCMessage.Args); Log.SetForegroundColor(ConsoleColor.Gray); } if (sIRCMessage.Nick.IsServ(Serv.NickServ)) { if (sIRCMessage.Args.Contains("Password incorrect.")) { sMyNickInfo.ChangeIdentifyStatus(true); Log.Error("NickServ", sLConsole.GetString("Bad identify password!")); ConnectAllChannel(); } else if (sIRCMessage.Args.Contains("You are already identified.")) { Log.Warning("NickServ", sLConsole.GetString("Already identified!")); } else if (sIRCMessage.Args.Contains("Password accepted - you are now recognized.")) { sMyNickInfo.ChangeIdentifyStatus(true); Log.Success("NickServ", sLConsole.GetString("Identify password accepted.")); } var registered = new Regex("Nick (.+) isn't registered."); if (sIRCMessage.Args.Contains("Your nick isn't registered.") || (!sMyNickInfo.IsIdentify && registered.IsMatch(sIRCMessage.Args))) { Log.Warning("NickServ", sLConsole.GetString("Your nick isn't registered!")); ChannelPrivmsg = sMyNickInfo.NickStorage; sMyNickInfo.ChangeIdentifyStatus(true); ConnectAllChannel(); } if (IsOnline) { sIRCMessage.SetMessageType(); if (sIRCMessage.Args.Contains("Is online from:") || sIRCMessage.Args.Contains("is currently online.")) { sIRCMessage.Channel = OnlinePrivmsg; sSendMessage.SendChatMessage(sIRCMessage, sLConsole.MessageHandler("Text11", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName))); IsOnline = false; } else if (sIRCMessage.Args.Contains("isn't registered.")) { sIRCMessage.Channel = OnlinePrivmsg; sSendMessage.SendChatMessage(sIRCMessage, sLConsole.MessageHandler("Text12", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName))); IsOnline = false; } else if (sIRCMessage.Args.Contains("Last seen time:") || sIRCMessage.Args.Contains("Last seen:")) { sIRCMessage.Channel = OnlinePrivmsg; sSendMessage.SendChatMessage(sIRCMessage, sLConsole.MessageHandler("Text13", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName)), sIRCMessage.Args.Contains("Last seen time:") ? sIRCMessage.Args.Remove(0, "Last seen time: ".Length, "Last seen time: ") : sIRCMessage.Args.Remove(0, "Last seen: ".Length, "Last seen: ")); IsOnline = false; } sIRCMessage.MessageType = MessageType.Notice; } } if (sIRCMessage.Nick.IsServ(Serv.HostServ)) { if (sIRCMessage.Args.Contains("You need to register before a vhost can be assigned to you.")) { Log.Warning("HostServ", sLConsole.GetString("Nick isnt registered, so the vhost still off!")); ConnectAllChannel(); } } if (sIRCMessage.Nick.IsServ(Serv.HostServ) && IRCConfig.List[sIRCMessage.ServerName].UseHostServ) { if (sIRCMessage.Args.Contains("Your vhost of") && !sMyNickInfo.IsVhost) { ChannelPrivmsg = sMyNickInfo.NickStorage; ConnectAllChannel(); } } sIRCMessage.Channel = sIRCMessage.Nick; HandleCommand(sIRCMessage); }
public static void SetMessageType(this IRCMessage sIRCMessage) { sIRCMessage.SetMessageType(IRCConfig.List[sIRCMessage.ServerName].MessageType.ToLower()); }