public override PluginArgs InputText(PluginArgs args) { if (args.Command.StartsWith("!google")) { String search = args.Command.Substring(8); search = search.Replace(" ", "%20"); search = search.Replace("&", "&"); string url = "http://www.google.ca/search?q=" + search; args.Command = "/say " + args.Command; OnCommand(args); ParseArgs pa = new ParseArgs { args = args, url = url, self = true }; BackgroundWorker bgw = new BackgroundWorker(); bgw.DoWork += new DoWorkEventHandler(Bgw_DoWork); bgw.RunWorkerAsync(pa); //ParseGoogleResults(args, url, true); args.Command = ""; } return(base.InputText(args)); }
public override PluginArgs CtcpMessage(PluginArgs args) { //args.Extra -- ctcp message AddMonitorMessage(args.Nick, "CTCP : " + args.Extra, false, args.Connection.ServerSetting.ID); return(args); }
public override PluginArgs InputText(PluginArgs args) { // args.Command = what was written // args.Nick is current channel, or Console // args.Extra Window Type (Channel/Query/Console) args = CheckScripts(args, "Input Text"); if (args.Extra == "Channel") { // does it start with /me , /describe System.Diagnostics.Debug.WriteLine("Channel Command:" + args.Command); args = CheckScripts(args, "Self Channel Message"); } else if (args.Extra == "Query") { System.Diagnostics.Debug.WriteLine("Query Command:" + args.Command); args = CheckScripts(args, "Self Query Message"); } return(args); }
public override void Initialize() { if (CurrentVersion < 90020140221) { //send back a message that we need to update! PluginArgs a = new PluginArgs(); a.Command = "/echo Channel Monitor Plugin v1.3 requires IceChat 9 RC 8.22 or newer (" + CurrentVersion + ")"; OnCommand(a); this.Enabled = false; return; } settingsFile = CurrentFolder + System.IO.Path.DirectorySeparatorChar + "IceChatChannelMonitor.xml"; LoadSettings(); panel = new Panel(); panel.Height = 150; panel.Dock = DockStyle.Bottom; listMonitor = new ListView(); columnTime = new ColumnHeader(); columnChannel = new ColumnHeader(); columnMessage = new ColumnHeader(); columnServerID = new ColumnHeader(); columnTime.Width = 175; columnTime.Text = "Time"; columnChannel.Width = 150; columnChannel.Text = "Channel/Nick"; columnMessage.Width = 1000; columnMessage.Text = "Message"; columnServerID.Width = 0; //hidden listMonitor.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { columnTime, columnChannel, columnMessage, columnServerID }); listMonitor.View = System.Windows.Forms.View.Details; listMonitor.FullRowSelect = true; listMonitor.Font = new System.Drawing.Font("Verdana", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); listMonitor.Dock = DockStyle.Fill; panel.Controls.Add(listMonitor); if (CurrentVersion > 90220150213) { listMonitor.DoubleClick += new EventHandler(listMonitor_DoubleClick); } m_EnableMonitor = new ToolStripMenuItem(); m_EnableMonitor.Text = "Toggle Monitor"; m_EnableMonitor.Checked = true; m_EnableMonitor.Click += new EventHandler(OnEnableMonitor_Click); }
private string CheckNickHighlite(PluginArgs args) { string nick = args.Nick; string host = args.Host; string color = args.Extra; foreach (HighLiteItem hli in iceChatNickHighLites.listHighLites) { if (hli.Enabled) { string match = hli.Match; string hostMatch = hli.MatchHost; //match = match.Replace("$me", args.Connection.ServerSetting.NickName); string me = args.Connection.ServerSetting.NickName; me = me.Replace(@"\", @"\\"); me = me.Replace(@"[", @"\["); me = me.Replace(@"]", @"\]"); me = me.Replace(@"{", @"\{"); me = me.Replace(@"}", @"\}"); me = me.Replace(@"^", @"\^"); me = me.Replace(@"|", @"\|"); match = match.Replace("$me", me); hostMatch = hostMatch.Replace("$host", args.Connection.ServerSetting.LocalHost); hostMatch = hostMatch.Replace("$ident", args.Connection.ServerSetting.IdentName); hostMatch = hostMatch.Replace("$fullhost", args.Connection.ServerSetting.CurrentNickName + "!" + args.Connection.ServerSetting.LocalHost); if (match.Length > 0) { try { if (Regex.IsMatch(nick, match, RegexOptions.IgnoreCase)) { color = hli.Color.ToString(); } } catch { } } else if (hostMatch.Length > 0) { try { if (Regex.IsMatch(host, hostMatch, RegexOptions.IgnoreCase)) { color = hli.Color.ToString(); } } catch { } } } } return(color); }
public override PluginArgs InputText(PluginArgs args) { if (args.Command.StartsWith("/?")) { string command = args.Command.Substring(3); scriptObject.ExecuteStatement(command); args.Command = ""; } else if (args.Command.StartsWith("/!")) { string command = args.Command.Substring(3); if (command.IndexOf(' ') == -1) { object[] param = { }; RunScript(command, param); } else { //parse the params string ps = command.Split(new char[] { ' ' }, 2)[1]; command = command.Split(new char[] { ' ' }, 2)[0]; string[] param = ps.Split(new char[] { '|' }); object[] p = new object[param.Length]; for (int i = 0; i < param.Length; i++) { System.Diagnostics.Debug.WriteLine(i + ":" + param[i]); //param[i] = (object)param[i]; //convert to type Integer if possible int result; if (Int32.TryParse(param[i].ToString(), out result)) { //param[i] = (Int32)param[i]; p[i] = Convert.ToInt32(param[i]); } else { p[i] = param[i]; } } System.Diagnostics.Debug.WriteLine("/! parse:" + command); System.Diagnostics.Debug.WriteLine(p.GetType()); System.Diagnostics.Debug.WriteLine(p); RunScript(command, p); } args.Command = ""; } else { object[] param = { args.Command }; RunScript("OUTTEXT", param); } return(args); }
//args.Connection -- current connection //args.Extra -- command data public PluginArgs InputText(PluginArgs args) { string data = args.Extra; int indexOfSpace = data.IndexOf(" "); string command = ""; if (indexOfSpace > 0) { command = data.Substring(0, indexOfSpace); data = data.Substring(command.Length + 1); } else { command = data; data = ""; } if (command.ToLower() == "/mp3") { if (data.Length > 0) { if (File.Exists(data)) { //MessageBox.Show("exists"); mciSendString("open \"" + data + "\" ALIAS MediaFile TYPE MpegVideo", null, 0, IntPtr.Zero); mciSendString("play MediaFile", null, 0, IntPtr.Zero); } else if (File.Exists(currentFolder + System.IO.Path.DirectorySeparatorChar + "Sounds" + System.IO.Path.DirectorySeparatorChar + data)) { mciSendString("open \"" + currentFolder + System.IO.Path.DirectorySeparatorChar + "Sounds" + System.IO.Path.DirectorySeparatorChar + data + "\" ALIAS MediaFile TYPE MpegVideo", null, 0, IntPtr.Zero); mciSendString("play MediaFile", null, 0, IntPtr.Zero); } else { if (data.ToLower().Equals("stop")) { //stop playing the music mciSendString("stop MediaFile", null, 0, IntPtr.Zero); } if (data.ToLower().Equals("pause")) { mciSendString("pause MediaFile", null, 0, IntPtr.Zero); } if (data.ToLower().Equals("play")) { mciSendString("play MediaFile", null, 0, IntPtr.Zero); } } } args.Extra = ""; } return(args); }
public override PluginArgs NickListDraw(PluginArgs args) { //args.Nick == nickname //args.Host == nickhighlitesFile host //args.Extra == color number to change to args.Extra = CheckNickHighlite(args); return(args); }
private void Script_ParseCommandCurrent(string command) { System.Diagnostics.Debug.WriteLine("parsecc:" + command); IceChat.IRCConnection c = null; PluginArgs args = new PluginArgs(c); args.Extra = "current"; args.Command = (String)command; OnCommand(args); }
private void listMonitor_DoubleClick(object sender, EventArgs e) { //use the /switch #channel serverID to open that channel //will require icechat 9.03+ if (listMonitor.SelectedItems.Count == 1) { ListViewItem lvi = listMonitor.SelectedItems[0]; PluginArgs a = new PluginArgs(); a.Command = "/switch " + lvi.SubItems[1].Text + " " + lvi.SubItems[3].Text; OnCommand(a); } }
public override void NewWindow(PluginArgs args) { switch (args.Extra) { case "Channel": CheckScripts(args, "New Channel"); break; case "Query": CheckScripts(args, "New Private"); break; } }
private void Script_ParseCommand(string command, object ServerNumber) { System.Diagnostics.Debug.WriteLine("parsec:" + command); //how do I get the connection from a server ID if (Connections.ContainsKey(ServerNumber)) { IceChat.IRCConnection c = (IceChat.IRCConnection)Connections[ServerNumber]; PluginArgs args = new PluginArgs(c); args.Command = command; OnCommand(args); } }
public override PluginArgs ChannelPart(PluginArgs args) { if (args.Nick == args.Connection.ServerSetting.NickName) { //remove the channel from the list cMonitor newChan = new cMonitor(args.Connection, StripColorCodes(args.Channel)); if (monitoredChannels.IndexOf(newChan) > -1) { monitoredChannels.Remove(newChan); AddMonitorMessage(args.Channel, "Stopped Monitoring channel:" + monitoredChannels.Count, false, args.Connection.ServerSetting.ID); } } return(args); }
public override void Initialize() { if (this.CurrentVersion < 9020140221) { //need a newer version PluginArgs a = new PluginArgs(); a.Command = "/echo Highlite Plugin v2.9 requires IceChat 9 RC 8.22 or newer"; OnCommand(a); this.Enabled = false; return; } highlitesFile = CurrentFolder + System.IO.Path.DirectorySeparatorChar + "IceChatHighLites.xml"; LoadHighLites(); }
public override PluginArgs ChannelAction(PluginArgs args) { cMonitor newChan = new cMonitor(args.Connection, StripColorCodes(args.Channel)); if (monitoredChannels.IndexOf(newChan) > -1) { string message = StripColorCodes(args.Message); if (message.IndexOf(args.Connection.ServerSetting.CurrentNickName) > -1) { AddMonitorMessage(args.Channel, message, true, args.Connection.ServerSetting.ID); } else { AddMonitorMessage(args.Channel, message, false, args.Connection.ServerSetting.ID); } } return(args); }
public override PluginArgs ChannelJoin(PluginArgs args) { if (args.Nick == args.Connection.ServerSetting.NickName) { //add the channel to the list //check if this channel is on Monitor settings bool disabled = false; if (monitorChannels.ChannelExist(args.Channel) != null) { if (monitorChannels.ChannelExist(args.Channel).Enabled == false) { disabled = true; } } if (disabled == false) { cMonitor newChan = new cMonitor(args.Connection, StripColorCodes(args.Channel)); monitoredChannels.Add(newChan); AddMonitorMessage(args.Channel, "Started Monitoring channel:" + monitoredChannels.Count, false, args.Connection.ServerSetting.ID); } if (monitorChannels.ChannelExist(args.Channel) != null) { monitorChannels.UpdateChannel(args.Channel, !disabled); } else { MonitorItem c = new MonitorItem { Channel = args.Channel, Enabled = !disabled }; monitorChannels.AddChannel(c); } SaveSettings(); } return(args); }
//declare all the necessary events public override PluginArgs ChannelMessage(PluginArgs args) { //check if monitoring is enabled for this channel cMonitor newChan = new cMonitor(args.Connection, StripColorCodes(args.Channel)); if (monitoredChannels.IndexOf(newChan) > -1) { //check if nick is said string message = StripColorCodes(args.Message); if (message.IndexOf(args.Connection.ServerSetting.CurrentNickName) > -1) { AddMonitorMessage(args.Channel, message, true, args.Connection.ServerSetting.ID); } else { AddMonitorMessage(args.Channel, message, false, args.Connection.ServerSetting.ID); } } return(args); }
//if you want to add a new method to override, use public override public override PluginArgs ChannelMessage(PluginArgs args) { if (args.Extra.StartsWith("!google")) { String search = args.Extra.Substring(8); search = search.Replace(" ", "%20"); search = search.Replace("&", "&"); string url = "http://www.google.ca/search?q=" + search; ParseArgs pa = new ParseArgs(); pa.args = args; pa.url = url; pa.self = false; //ParseGoogleResults(args, url, false); BackgroundWorker bgw = new BackgroundWorker(); bgw.DoWork += new DoWorkEventHandler(bgw_DoWork); bgw.RunWorkerAsync(pa); } return(base.ChannelMessage(args)); }
/// <summary> /// A User Quit the Server /// </summary> /// <param name="connection">Which Connection it came from</param> /// <param name="user">Which Nick quit the Server</param> /// <param name="reason">Quit Reason</param> private void OnServerQuit(IRCConnection connection, string nick, string host, string reason) { PluginArgs args = null; string msg = GetMessageFormat("Server Quit"); msg = msg.Replace("$nick", nick); msg = msg.Replace("$host", host); msg = msg.Replace("$reason", reason); args = new PluginArgs(mainTabControl.GetTabPage("Console").TextWindow, "", nick, host, msg); args.Extra = reason; args.Connection = connection; foreach (IPluginIceChat ipc in loadedPlugins) { if (ipc.Enabled == true) args = ipc.ServerQuit(args); } foreach (IceTabPage t in mainTabControl.TabPages) { if (t.Connection == connection) { if (t.WindowStyle == IceTabPage.WindowType.Channel) { if (t.NickExists(nick) == true) { if (iceChatOptions.QuitEventLocation == 0) { //send it to the channel t.TextWindow.AppendText(args.Message, 1); t.LastMessageType = ServerMessageType.QuitServer; } t.RemoveNick(nick); } } if (t.WindowStyle == IceTabPage.WindowType.Query) { if (t.TabCaption == nick) { t.TextWindow.AppendText(args.Message, 1); t.LastMessageType = ServerMessageType.QuitServer; } } } } if (iceChatOptions.QuitEventLocation == 1) { //send the message to the Console if (args != null) mainTabControl.GetTabPage("Console").AddText(connection, args.Message, 1, false); } }
/// <summary> /// Received a Server Notice /// </summary> /// <param name="connection"></param> /// <param name="message"></param> private void OnServerNotice(IRCConnection connection, string message) { string msg = GetMessageFormat("Server Notice"); if (connection.ServerSetting.RealServerName.Length > 0) msg = msg.Replace("$server", connection.ServerSetting.RealServerName); else msg = msg.Replace("$server", connection.ServerSetting.ServerName); msg = msg.Replace("$message", message); PluginArgs args = new PluginArgs(mainTabControl.GetTabPage("Console").TextWindow, "", "", connection.ServerSetting.RealServerName, msg); args.Extra = message; args.Connection = connection; foreach (IPluginIceChat ipc in loadedPlugins) { if (ipc.Enabled == true) args = ipc.ServerNotice(args); } mainTabControl.GetTabPage("Console").AddText(connection, args.Message, 1, false); if (!connection.ServerSetting.DisableSounds) PlaySoundFile("conmsg"); }
/// <summary> /// Received a Server/Connection Error /// </summary> /// <param name="connection">Which Connection it came from</param> /// <param name="message">Error Message</param> private void OnServerError(IRCConnection connection, string message, bool current) { string[] msgs = message.Split('\n'); foreach (string msg in msgs) { if (msg.Length > 0) { //goes to the console string error = GetMessageFormat("Server Error"); if (connection.ServerSetting.RealServerName.Length > 0) error = msg.Replace("$server", connection.ServerSetting.RealServerName); else error = msg.Replace("$server", connection.ServerSetting.ServerName); error = error.Replace("$message", msg); PluginArgs args = new PluginArgs(mainTabControl.GetTabPage("Console").TextWindow, "", "",connection.ServerSetting.RealServerName, error); args.Extra = message; args.Connection = mainTabControl.GetTabPage("Console").Connection; foreach (IPluginIceChat ipc in loadedPlugins) { if (ipc.Enabled == true) ipc.ServerError(args); } mainTabControl.GetTabPage("Console").AddText(connection, error, 4, false); mainTabControl.GetTabPage("Console").LastMessageType = ServerMessageType.ServerMessage; if (current == true) { if (CurrentWindowType != IceTabPage.WindowType.Console) CurrentWindowMessage(connection, error, 4, false); } else { //send it to all open channels foreach (IceTabPage t in FormMain.Instance.TabMain.TabPages) { if (t.WindowStyle == IceTabPage.WindowType.Channel) { if (t.Connection == connection) { t.TextWindow.AppendText(error, 4); t.LastMessageType = ServerMessageType.ServerMessage; } } else if (t.WindowStyle == IceTabPage.WindowType.Query) { if (t.Connection == connection) { t.TextWindow.AppendText(error, 4); t.LastMessageType = ServerMessageType.ServerMessage; } } } } if (!connection.ServerSetting.DisableSounds) PlaySoundFile("conmsg"); } } }
private void OnServerConnect(IRCConnection connection, string address) { string msg = FormMain.Instance.GetMessageFormat("Server Connect"); if (connection.ServerSetting.UseBNC) msg = msg.Replace("$serverip", address).Replace("$server", connection.ServerSetting.BNCIP).Replace("$port", connection.ServerSetting.BNCPort) + " (BNC Connection)"; else msg = msg.Replace("$serverip", address).Replace("$server", connection.ServerSetting.ServerName).Replace("$port", connection.ServerSetting.ServerPort); OnServerMessage(connection, msg); PluginArgs args = new PluginArgs(mainTabControl.GetTabPage("Console").TextWindow, "", connection.ServerSetting.NickName , "", msg); args.Connection = connection; foreach (IPluginIceChat ipc in loadedPlugins) { if (ipc.Enabled == true) ipc.ServerConnect(args); } }
/// <summary> /// Received a Query/Private Message /// </summary> /// <param name="connection">Which Connection it came from</param> /// <param name="nick">Nick who sent the message</param> /// <param name="message">Query Message</param> private void OnQueryMessage(IRCConnection connection, string nick, string host, string message) { if (!mainTabControl.WindowExists(connection, nick, IceTabPage.WindowType.Query) && iceChatOptions.DisableQueries) return; if (!mainTabControl.WindowExists(connection, nick, IceTabPage.WindowType.Query)) AddWindow(connection, nick, IceTabPage.WindowType.Query); IceTabPage t = GetWindow(connection, nick, IceTabPage.WindowType.Query); if (t != null) { string msg = GetMessageFormat("Private Message"); msg = msg.Replace("$nick", nick).Replace("$host", host); msg = msg.Replace("$message", message); PluginArgs args = new PluginArgs(t.TextWindow, "", nick, host, msg); args.Extra = message; args.Connection = connection; foreach (IPluginIceChat ipc in loadedPlugins) { if (ipc.Enabled == true) args = ipc.QueryMessage(args); } if (args.Message.Contains(connection.ServerSetting.NickName)) { //check if sounds are disabled for this window if (!t.DisableSounds) PlaySoundFile("nickchan"); } t.TextWindow.AppendText(msg, 1); //make the tabcaption proper case if (t.TabCaption != nick) t.TabCaption = nick; t.LastMessageType = ServerMessageType.Message; if (!t.DisableSounds) PlaySoundFile("privmsg"); } }
public override PluginArgs ChannelMessage(PluginArgs args) { args.Message = CheckTextHighLite(args); return(args); }
/// <summary> /// You have Joined a Channel /// </summary> /// <param name="connection">Which Connection it came from</param> /// <param name="channel">Which Channel you joined</param> private void OnChannelJoinSelf(IRCConnection connection, string channel) { //check if channel window already exists IceTabPage t = GetWindow(connection, channel, IceTabPage.WindowType.Channel); if (t == null) { t = AddWindow(connection, channel, IceTabPage.WindowType.Channel); PluginArgs args = new PluginArgs(t.TextWindow, channel, connection.ServerSetting.NickName, "", ""); args.Connection = connection; foreach (IPluginIceChat ipc in loadedPlugins) { if (ipc.Enabled == true) ipc.ChannelJoin(args); } serverTree.Invalidate(); } else { PluginArgs args = new PluginArgs(t.TextWindow, channel, connection.ServerSetting.NickName, "", ""); args.Connection = connection; foreach (IPluginIceChat ipc in loadedPlugins) { if (ipc.Enabled == true) ipc.ChannelJoin(args); } serverTree.Invalidate(); } }
public override PluginArgs QueryAction(PluginArgs args) { args = CheckScripts(args, "Private Action"); return(args); }
public override PluginArgs QueryMessage(PluginArgs args) { args = CheckScripts(args, "Private Message"); return(args); }
public override PluginArgs ChannelAction(PluginArgs args) { args = CheckScripts(args, "Channel Action"); return(args); }
private string CheckTextHighLite(PluginArgs args) { //parse out any identifiers for the channel/nick, etc string message = args.Message; try { foreach (HighLiteItem hli in iceChatHighLites.listHighLites) { if (hli.Enabled) { string match = hli.Match; // if $me is part of the match string substitute with the current nickname. // Some characters that are allowed in nicknames carry significance in regex. // These are - \ [ ] { } ^ | // We need to escape them with \ before using the nickname in the regex match string me = args.Connection.ServerSetting.CurrentNickName; me = me.Replace(@"\", @"\\"); me = me.Replace(@"[", @"\["); me = me.Replace(@"]", @"\]"); me = me.Replace(@"{", @"\{"); me = me.Replace(@"}", @"\}"); me = me.Replace(@"^", @"\^"); me = me.Replace(@"|", @"\|"); //me = me.Replace(@"-", @"\-"); Don't need this because it has significance only between [ and ] which are already escaped match = match.Replace("$me", me); if (Regex.IsMatch(message, match, RegexOptions.IgnoreCase)) { //check include list if (hli.NicksInclude != null && hli.NicksInclude.Length > 0) { bool nickFound = false; foreach (string ni in hli.NicksInclude) { //string n = EscapeNick(ni); //if (Regex.IsMatch(args.Nick, "\\b" + n + "\\b", RegexOptions.IgnoreCase)) if (Regex.IsMatch(args.Nick, ni, RegexOptions.IgnoreCase)) { nickFound = true; } } if (nickFound == false) { continue; } } //check exclude list if (hli.NicksExclude != null && hli.NicksExclude.Length > 0) { bool nickFound = false; foreach (string ni in hli.NicksExclude) { //string n = EscapeNick(ni); if (Regex.IsMatch(args.Nick, ni, RegexOptions.IgnoreCase)) { nickFound = true; } } if (nickFound == true) { continue; } } message = message.Replace(args.Extra, "" + hli.Color.ToString("00") + args.Extra); if (hli.FlashTab == true) { if (args.Channel.Length > 0) { args.Command = "/flash " + args.Channel; } else if (args.Nick.Length > 0) { args.Command = "/flash " + args.Nick; } OnCommand(args); } if (hli.Sound != null) { if (hli.Sound.Length > 0) { args.Command = "/cplay " + args.Channel + " " + hli.Sound; OnCommand(args); } } if (hli.Command != null) { if (hli.Command.Length > 0) { args.Command = hli.Command.Replace("$message", args.Extra); args.Command = args.Command.Replace("$match", hli.Match); args.Command = args.Command.Replace("$chan", args.Channel); args.Command = args.Command.Replace("$nick", args.Nick); OnCommand(args); } } break; } } } } catch (Exception ex) { //message = ex.Message; System.Diagnostics.Debug.WriteLine(ex.Message); } return(message); }
private PluginArgs CheckScripts(PluginArgs args, string eventType) { foreach (ScriptItem scr in iceChatScripts.listScripts) { string command = ""; if (scr.Enabled && eventType == scr.ScriptEvent) { switch (scr.ScriptEvent) { case "Channel Message": case "Channel Action": //use a regex match of sorts down the road Regex regChannel = new Regex(scr.ChannelMatch, RegexOptions.IgnoreCase); if (args.Channel != null && regChannel.IsMatch(args.Channel)) { Regex regMatch = new Regex(scr.TextMatch, RegexOptions.IgnoreCase); if (regMatch.IsMatch(args.Extra)) { command = scr.Command.Replace("$chan", args.Channel); command = command.Replace("$match", scr.TextMatch); command = command.Replace("$message", args.Extra); command = command.Replace("$nick", args.Nick); args.Command = command; if (OnCommand != null) { OnCommand(args); } } } break; case "Private Message": case "Private Action": Regex regChannel2 = new Regex(scr.ChannelMatch, RegexOptions.IgnoreCase); if (args.Channel != null && regChannel2.IsMatch(args.Channel)) { Regex regMatch = new Regex(scr.TextMatch, RegexOptions.IgnoreCase); if (regMatch.IsMatch(args.Extra)) { command = scr.Command.Replace("$chan", args.Channel); command = command.Replace("$nick", args.Nick); command = command.Replace("$match", scr.TextMatch); command = command.Replace("$message", args.Extra); args.Command = command; if (OnCommand != null) { OnCommand(args); } } } break; case "Channel Join": Regex regChannel3 = new Regex(scr.ChannelMatch, RegexOptions.IgnoreCase); if (args.Channel != null && regChannel3.IsMatch(args.Channel)) { Regex regMatch = new Regex(scr.TextMatch, RegexOptions.IgnoreCase); //args.Extra = account if (regMatch.IsMatch(args.Nick) || regMatch.IsMatch(args.Host) || (args.Extra.Length > 0 && regMatch.IsMatch(args.Extra))) { command = scr.Command.Replace("$chan", args.Channel); command = command.Replace("$nick", args.Nick); command = command.Replace("$host", args.Host); command = command.Replace("$account", args.Extra); command = command.Replace("$match", scr.TextMatch); args.Command = command; if (OnCommand != null) { OnCommand(args); } } } break; case "Channel Kick": Regex regChannel4 = new Regex(scr.ChannelMatch, RegexOptions.IgnoreCase); if (args.Channel != null && regChannel4.IsMatch(args.Channel)) { command = scr.Command.Replace("$chan", args.Channel); command = command.Replace("$nick", args.Nick); command = command.Replace("$match", scr.TextMatch); command = command.Replace("$message", args.Extra); args.Command = command; if (OnCommand != null) { OnCommand(args); } } break; case "Channel Invite": Regex regChannel5 = new Regex(scr.ChannelMatch, RegexOptions.IgnoreCase); if (args.Channel != null && regChannel5.IsMatch(args.Channel)) { command = scr.Command.Replace("$chan", args.Channel); command = command.Replace("$nick", args.Nick); command = command.Replace("$match", scr.TextMatch); args.Command = command; if (OnCommand != null) { OnCommand(args); } } break; case "Channel Part": Regex regChannel6 = new Regex(scr.ChannelMatch, RegexOptions.IgnoreCase); if (args.Channel != null && regChannel6.IsMatch(args.Channel)) { command = scr.Command.Replace("$chan", args.Channel); command = command.Replace("$nick", args.Nick); command = command.Replace("$match", scr.TextMatch); command = command.Replace("$message", args.Extra); args.Command = command; if (OnCommand != null) { OnCommand(args); } } break; case "IceChat Startup": args.Command = scr.Command; if (OnCommand != null) { OnCommand(args); } break; case "New Channel": Regex regChannel7 = new Regex(scr.ChannelMatch, RegexOptions.IgnoreCase); if (args.Channel != null && regChannel7.IsMatch(args.Channel)) { command = scr.Command.Replace("$chan", args.Channel); args.Command = command; if (OnCommand != null) { OnCommand(args); } } break; case "New Private": Regex regChannel8 = new Regex(scr.ChannelMatch, RegexOptions.IgnoreCase); if (args.Channel != null && regChannel8.IsMatch(args.Channel)) { command = scr.Command.Replace("$nick", args.Channel); args.Command = command; if (OnCommand != null) { OnCommand(args); } } break; } } } return(args); }
private void ParseGoogleResults(PluginArgs args, String url, bool self) { System.Net.WebClient web = new System.Net.WebClient(); string html = web.DownloadString(url); string previousLink = ""; // put a max timer on this int tickCount = System.Environment.TickCount; if (html.Length > 0) { //int searchDiv = html.IndexOf("Search Results"); // //int searchDiv = html.IndexOf("id=\"topstuff\""); // All Results int searchDiv = html.IndexOf("id=\"main\""); System.Diagnostics.Debug.WriteLine("searchDiv:" + searchDiv); if (searchDiv > -1) { //System.Diagnostics.Debug.WriteLine(html.Substring(searchDiv)); //do a loop int counter = 0; PluginArgs a = new PluginArgs(args.Connection); do { // class="g" nolonger int i = html.IndexOf("<div class=\"jfp3ef\"", searchDiv); System.Diagnostics.Debug.WriteLine("search g:" + i + ":" + counter); if (i > 0) { //counter++; if (System.Environment.TickCount - tickCount > 10000) { break; } int x = html.IndexOf("<a href=\"/url?q=", i + 1) + 16; int y = html.IndexOf("\"", x + 1); System.Diagnostics.Debug.WriteLine("x=" + x); //extract the url System.Diagnostics.Debug.WriteLine("link=" + html.Substring(x, y - x)); string link = html.Substring(x, y - x); //now cut off the link to the 1st & link = link.Substring(0, link.IndexOf("&")); link = link.Replace("%3F", "?"); link = link.Replace("%3D", "="); int y2 = html.IndexOf(">", y) + 1; //int y2 = html.IndexOf("AP7Wnd\">", y) + 8; int z = html.IndexOf("</a>", y2); System.Diagnostics.Debug.WriteLine("z:" + html.Substring(y2, z - y2)); // z:<div class="BNeawe vvjwJb AP7Wnd">How // z:<div class="BNeawe vvjwJb AP7Wnd">IceChat IRC Client :: IRC Client Extra-Ordinaire :: The Chat Cool ...</div><div class="BNeawe UPmit AP7Wnd">https://icechat.net</div> // z:<span class="XLloXe AP7Wnd">Downloads</span> // z:<img class="lhgpye" alt="" src="data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" style="max-width:72px;max-height:72px" id="dimg_11" data-deferred="1"> string desc = html.Substring(y2, z - y2); int zz = desc.IndexOf("AP7Wnd\">"); if (zz > -1) { desc = desc.Substring(zz + 8); int z2 = desc.IndexOf("</"); if (z2 > -1) { desc = desc.Substring(0, z2); } } else { desc = ""; } desc = desc.Replace("<em>", ""); desc = desc.Replace("</em>", ""); desc = desc.Replace("<b>", ""); desc = desc.Replace("</b>", ""); desc = desc.Replace("&", "&"); searchDiv = html.IndexOf("<div class=\"jfp3ef\"", z) - 1; System.Diagnostics.Debug.WriteLine("zSearchDiv:" + z + ":" + searchDiv); if (desc.Length > 0) { if (!link.StartsWith("/search?q=")) { if (link != previousLink) { counter++; if (self == false) { a.Command = "/notice " + args.Nick + " " + link + " : " + desc; OnCommand(a); } else { a.Command = "/echo " + link + " : " + desc; OnCommand(a); } previousLink = link; } } } System.Diagnostics.Debug.WriteLine(link); } System.Diagnostics.Debug.WriteLine(searchDiv + ":" + html.Length); if (searchDiv >= html.Length || i == -1) { break; } } while (counter < 5); } else { //System.Diagnostics.Debug.WriteLine(html); } } }
/// <summary> /// Received Whois Data on a Nick /// </summary> /// <param name="connection">Which Connection it came from</param> /// <param name="nick">The nick whois data is from</param> /// <param name="data">The Whois data</param> private void OnWhoisData(IRCConnection connection, string nick, string data) { string msg = GetMessageFormat("User Whois"); msg = msg.Replace("$nick", nick); msg = msg.Replace("$data", data); PluginArgs args = new PluginArgs(mainTabControl.GetTabPage("Console").TextWindow, "", nick, "", msg); args.Connection = connection; foreach (IPluginIceChat ipc in loadedPlugins) { if (ipc.Enabled == true) ipc.WhoisUser(args); } if (iceChatOptions.WhoisEventLocation == 2) //hide the event return; //check if there is a query window open IceTabPage t = GetWindow(connection, nick, IceTabPage.WindowType.Query); if (t != null) { if (iceChatOptions.WhoisEventLocation == 0) { t.TextWindow.AppendText(msg, 1); t.LastMessageType = ServerMessageType.Message; } else { mainTabControl.GetTabPage("Console").AddText(connection, msg, 1, false); } } else { if (iceChatOptions.WhoisEventLocation == 0) //send whois data to the current window CurrentWindowMessage(connection, msg, 1, false); else mainTabControl.GetTabPage("Console").AddText(connection, msg, 1, false); } }
/// <summary> /// When a User Invites you to a Channel /// </summary> /// <param name="connection">Which connection it came from</param> /// <param name="channel">The channel you are being invited to</param> /// <param name="nick">The nick who invited you</param> /// <param name="host">The host of the nick who invited you</param> private void OnChannelInvite(IRCConnection connection, string channel, string nick, string host) { string msg = GetMessageFormat("Channel Invite"); msg = msg.Replace("$channel", channel).Replace("$nick", nick).Replace("$host", host); mainTabControl.GetTabPage("Console").AddText(connection, msg, 1, false); if (!connection.ServerSetting.DisableSounds) PlaySoundFile("conmsg"); PluginArgs args = new PluginArgs(mainTabControl.GetTabPage("Console").TextWindow, channel, nick, host, msg); args.Connection = connection; foreach (IPluginIceChat ipc in loadedPlugins) { if (ipc.Enabled == true) ipc.ChannelInvite(args); } }
public override PluginArgs ChannelInvite(PluginArgs args) { args = CheckScripts(args, "Channel Invite"); return(args); }
/// <summary> /// You where Kicked from a Channel /// </summary> /// <param name="connection">Which Connection it came from</param> /// <param name="channel">Which Channel you were kicked from</param> /// <param name="reason">Kick Reason</param> /// <param name="kickUser">Full User Host of who kicked you</param> private void OnChannelKickSelf(IRCConnection connection, string channel, string reason, string kickUser) { try { IceTabPage t = GetWindow(connection, channel, IceTabPage.WindowType.Channel); if (iceChatOptions.ChannelOpenKick) { if (t != null) { t.ClearNicks(); t.IsFullyJoined = false; t.GotNamesList = false; t.GotWhoList = false; if (CurrentWindow == t) nickList.Header = t.TabCaption + ":0"; FormMain.Instance.NickList.Invalidate(); } } else { RemoveWindow(connection, channel, IceTabPage.WindowType.Channel); } string nick = NickFromFullHost(kickUser); string host = HostFromFullHost(kickUser); string msg = GetMessageFormat("Self Channel Kick"); msg = msg.Replace("$nick", connection.ServerSetting.NickName); msg = msg.Replace("$kicker", nick); msg = msg.Replace("$host", host); msg = msg.Replace("$channel", channel); msg = msg.Replace("$reason", reason); PluginArgs args = new PluginArgs(mainTabControl.GetTabPage("Console").TextWindow, channel, nick, connection.ServerSetting.NickName, msg); args.Extra = reason; args.Connection = connection; foreach (IPluginIceChat ipc in loadedPlugins) { if (ipc.Enabled == true) { System.Diagnostics.Debug.WriteLine(ipc.Name); args = ipc.ChannelKick(args); } } if (iceChatOptions.ChannelOpenKick) { if (t != null) t.TextWindow.AppendText(args.Message, 1); else mainTabControl.GetTabPage("Console").AddText(connection, args.Message, 1, false); } else mainTabControl.GetTabPage("Console").AddText(connection, args.Message, 1, false); } catch (Exception e) { WriteErrorFile(connection, "OnKickSelf", e); } }
public override PluginArgs ChannelKick(PluginArgs args) { args = CheckScripts(args, "Channel Kick"); return(args); }
/// <summary> /// Received a Query/Private Message action /// </summary> /// <param name="connection">Which Connection it came from</param> /// <param name="nick">Nick who sent the action</param> /// <param name="message">Query Action Message</param> private void OnQueryAction(IRCConnection connection, string nick, string host, string message) { if (!mainTabControl.WindowExists(connection, nick, IceTabPage.WindowType.Query) && iceChatOptions.DisableQueries) return; if (!mainTabControl.WindowExists(connection, nick, IceTabPage.WindowType.Query)) AddWindow(connection, nick, IceTabPage.WindowType.Query); IceTabPage t = GetWindow(connection, nick, IceTabPage.WindowType.Query); if (t != null) { string msg = GetMessageFormat("Private Action"); msg = msg.Replace("$nick", nick).Replace("$host", host); msg = msg.Replace("$message", message); PluginArgs args = new PluginArgs(t.TextWindow, "", nick, host, msg); args.Extra = message; args.Connection = connection; foreach (IPluginIceChat ipc in loadedPlugins) { if (ipc.Enabled == true) args = ipc.QueryAction(args); } t.TextWindow.AppendText(args.Message, 1); //make the tabcaption proper case if (t.TabCaption != nick) t.TabCaption = nick; t.LastMessageType = ServerMessageType.Action; } }
public override void MainProgramLoaded() { PluginArgs args = new PluginArgs(); CheckScripts(args, "IceChat Startup"); }
private void OnRawServerOutgoingData(IRCConnection connection, string data) { //check if a Debug Window is open IceTabPage t = GetWindow(null, "Debug", IceTabPage.WindowType.Debug); if (t != null) t.TextWindow.AppendText("-" + connection.ServerSetting.ID + ":" + data, 1); PluginArgs args = new PluginArgs(connection); args.Message = data; foreach (IPluginIceChat ipc in loadedPlugins) { if (ipc.Enabled == true) ipc.ServerRaw(args); } }
public override PluginArgs CtcpMessage(PluginArgs args) { //args.Extra -- ctcp message AddMonitorMessage(args.Nick, "CTCP : " + args.Extra); return args; }
private void OnServerDisconnect(IRCConnection connection) { string msg = GetMessageFormat("Server Disconnect"); msg = msg.Replace("$serverip", connection.ServerSetting.ServerIP); msg = msg.Replace("$port", connection.ServerSetting.ServerPort); if (connection.ServerSetting.RealServerName.Length > 0) msg = msg.Replace("$server",connection.ServerSetting.RealServerName); else msg = msg.Replace("$server", connection.ServerSetting.ServerName); foreach (IceTabPage t in mainTabControl.TabPages) { if (t.WindowStyle == IceTabPage.WindowType.Channel || t.WindowStyle == IceTabPage.WindowType.Query) { if (t.Connection == connection) { t.ClearNicks(); t.IsFullyJoined = false; t.GotNamesList = false; t.GotWhoList = false; t.TextWindow.AppendText(msg, 1); t.LastMessageType = ServerMessageType.ServerMessage; if (CurrentWindow == t) nickList.Header = t.TabCaption + ":0"; } } } OnServerMessage(connection, msg); PlaySoundFile("dropped"); PluginArgs args = new PluginArgs(mainTabControl.GetTabPage("Console").TextWindow, "", connection.ServerSetting.NickName, "", msg); args.Connection = connection; foreach (IPluginIceChat ipc in loadedPlugins) { if (ipc.Enabled == true) ipc.ServerDisconnect(args); } }
private void Plugin_OnCommand(PluginArgs e) { if (e.Command != null) { if (e.Connection != null) ParseOutGoingCommand(e.Connection, e.Command); else { if (e.Extra == "current") ParseOutGoingCommand(inputPanel.CurrentConnection, e.Command); else ParseOutGoingCommand(null, e.Command); } } }
/// <summary> /// A User changed their Nick Name /// </summary> /// <param name="connection">Which Connection it came from</param> /// <param name="oldnick">Original Nick Name</param> /// <param name="newnick">New Nick Name</param> private void OnChangeNick(IRCConnection connection, string oldnick, string newnick, string host) { try { string network = ""; if (connection.ServerSetting.NetworkName.Length > 0) network = " (" + connection.ServerSetting.NetworkName + ")"; if (CurrentWindowType == IceTabPage.WindowType.Console) { if (inputPanel.CurrentConnection == connection) { StatusText(inputPanel.CurrentConnection.ServerSetting.NickName + " connected to " + inputPanel.CurrentConnection.ServerSetting.RealServerName + network); if (connection.ServerSetting.NickName == newnick) { string msg = GetMessageFormat("Self Nick Change"); msg = msg.Replace("$nick", oldnick).Replace("$newnick", newnick).Replace("$host", host); ; mainTabControl.GetTabPage("Console").AddText(connection, msg, 1, false); } } } string cmsg = ""; if (connection.ServerSetting.NickName == newnick) cmsg = GetMessageFormat("Self Nick Change"); else cmsg = GetMessageFormat("Channel Nick Change"); cmsg = cmsg.Replace("$nick", oldnick).Replace("$newnick", newnick).Replace("$host", host); ; PluginArgs args = new PluginArgs(mainTabControl.GetTabPage("Console").TextWindow, "", oldnick, newnick, cmsg); args.Connection = connection; foreach (IPluginIceChat ipc in loadedPlugins) { if (ipc.Enabled == true) ipc.NickChange(args); } foreach (IceTabPage t in mainTabControl.TabPages) { if (t.Connection == connection) { if (t.WindowStyle == IceTabPage.WindowType.Channel) { if (t.NickExists(oldnick)) { if (connection.ServerSetting.NickName == newnick) { string msg = GetMessageFormat("Self Nick Change"); msg = msg.Replace("$nick", oldnick).Replace("$newnick", newnick).Replace("$host", host); ; t.TextWindow.AppendText(msg, 1); //update status bar as well if current channel if ((inputPanel.CurrentConnection == connection) && (CurrentWindowType == IceTabPage.WindowType.Channel)) { if (CurrentWindow == t) StatusText(t.Connection.ServerSetting.NickName + " in " + t.TabCaption + " [" + t.ChannelModes + "] {" + t.Connection.ServerSetting.RealServerName + "}" + network); } } else { string msg = GetMessageFormat("Channel Nick Change"); msg = msg.Replace("$nick", oldnick).Replace("$newnick", newnick).Replace("$host", host); t.TextWindow.AppendText(msg, 1); } User u = t.GetNick(oldnick); string nick = newnick; if (u != null) { for (int i = 0; i < u.Level.Length; i++) { if (u.Level[i]) { if (!nick.StartsWith(connection.ServerSetting.StatusModes[1][i].ToString())) nick = connection.ServerSetting.StatusModes[1][i] + nick; break; } } t.RemoveNick(oldnick); t.AddNick(nick, true); t.LastMessageType = ServerMessageType.Other; } if (nickList.CurrentWindow == t) nickList.RefreshList(t); } } else if (t.WindowStyle == IceTabPage.WindowType.Query) { if (t.TabCaption == oldnick) { t.TabCaption = newnick; if (connection.ServerSetting.NickName == newnick) { string msg = GetMessageFormat("Self Nick Change"); msg = msg.Replace("$nick", oldnick).Replace("$newnick", newnick).Replace("$host", host); ; t.TextWindow.AppendText(msg, 1); } else { string msg = GetMessageFormat("Channel Nick Change"); msg = msg.Replace("$nick", oldnick); msg = msg.Replace("$newnick", newnick); msg = msg.Replace("$host", host); t.TextWindow.AppendText(msg, 1); } if ((inputPanel.CurrentConnection == connection) && (CurrentWindowType == IceTabPage.WindowType.Query)) { if (CurrentWindow == t) StatusText(t.Connection.ServerSetting.NickName + " in private chat with " + t.TabCaption + " on {" + t.Connection.ServerSetting.RealServerName + "}" + network); } if (nickList.CurrentWindow == t) nickList.RefreshList(t); this.serverTree.Invalidate(); this.mainTabControl.Invalidate(); } } } } } catch (Exception e) { WriteErrorFile(connection, "OnChangeNick Error:" + oldnick + ":" + newnick ,e); } }
/// <summary> /// Channel Mode Changed /// </summary> /// <param name="connection">Which Connection it came from</param> /// <param name="modeSetter">Who set the mode(s)</param> /// <param name="channel">Channel which mode change is for</param> /// <param name="fullmode">All the modes and parameters</param> private void OnChannelMode(IRCConnection connection, string modeSetter, string modeSetterHost, string channel, string fullmode) { try { string mode = ""; string parameter = ""; if (fullmode.IndexOf(' ') == -1) { mode = fullmode; } else { mode = fullmode.Substring(0, fullmode.IndexOf(' ')); parameter = fullmode.Substring(fullmode.IndexOf(' ') + 1); } string msg = GetMessageFormat("Channel Mode"); msg = msg.Replace("$modeparam", parameter); msg = msg.Replace("$mode", mode); msg = msg.Replace("$nick", modeSetter); msg = msg.Replace("$host", modeSetterHost); msg = msg.Replace("$channel", channel); IceTabPage chan = GetWindow(connection, channel, IceTabPage.WindowType.Channel); if (chan != null) { PluginArgs args = new PluginArgs(chan, channel, modeSetter, modeSetterHost, msg); args.Extra = fullmode; args.Connection = connection; foreach (IPluginIceChat ipc in loadedPlugins) { if (ipc.Enabled == true) ipc.ChannelMode(args); } if (modeSetter != channel) { if (iceChatOptions.ModeEventLocation == 0) { chan.TextWindow.AppendText(msg, 1); chan.LastMessageType = ServerMessageType.Other; } else if (iceChatOptions.ModeEventLocation == 1) { //send it to the console mainTabControl.GetTabPage("Console").AddText(connection, msg, 1, false); } } else { chan.ChannelModes = fullmode.Trim(); } string[] parameters = parameter.Split(new char[] { ' ' }); bool addMode = false; int modelength = mode.Length; string temp; IEnumerator parametersEnumerator = parameters.GetEnumerator(); parametersEnumerator.MoveNext(); for (int i = 0; i < modelength; i++) { switch (mode[i]) { case '-': addMode = false; break; case '+': addMode = true; break; case 'b': //handle bans seperately temp = (string)parametersEnumerator.Current; parametersEnumerator.MoveNext(); break; default: //check if it's a status mode which can vary by server //temp = (string)parametersEnumerator.Current; bool isChecked = false; for (int j = 0; j < connection.ServerSetting.StatusModes[0].Length; j++) { if (mode[i] == connection.ServerSetting.StatusModes[0][j]) { temp = (string)parametersEnumerator.Current; //make sure its not an address if (temp.IndexOf("@") == -1) { chan.UpdateNick(temp, connection.ServerSetting.StatusModes[1][j].ToString(), addMode); parametersEnumerator.MoveNext(); isChecked = true; } break; } } if (!isChecked) { for (int j = 0; j < connection.ServerSetting.ChannelModeAddress.Length ; j++) { if (mode[i] == connection.ServerSetting.ChannelModeAddress[j]) { temp = (string)parametersEnumerator.Current; chan.UpdateNick(temp, connection.ServerSetting.ChannelModeAddress[j].ToString(), addMode); parametersEnumerator.MoveNext(); isChecked = true; break; } } } if (!isChecked) { for (int j = 0; j < connection.ServerSetting.ChannelModeParam.Length; j++) { if (mode[i] == connection.ServerSetting.ChannelModeParam[j]) { temp = (string)parametersEnumerator.Current; chan.UpdateChannelMode(mode[i], temp, addMode); parametersEnumerator.MoveNext(); isChecked = true; break; } } } if (!isChecked) { for (int j = 0; j < connection.ServerSetting.ChannelModeParamNotRemove.Length; j++) { if (mode[i] == connection.ServerSetting.ChannelModeParamNotRemove[j]) { if (addMode) { temp = (string)parametersEnumerator.Current; chan.UpdateChannelMode(mode[i], temp, addMode); parametersEnumerator.MoveNext(); } else { chan.UpdateChannelMode(mode[i], addMode); } isChecked = true; break; } } } if (!isChecked) { for (int j = 0; j < connection.ServerSetting.ChannelModeNoParam.Length; j++) { if (mode[i] == connection.ServerSetting.ChannelModeNoParam[j]) { chan.UpdateChannelMode(mode[i], addMode); break; } } } /* //check if the mode has a parameter (CHANMODES= from 005) if (connection.ServerSetting.ChannelModeParam.Contains(mode[i].ToString())) { //even though mode l requires a param to add it, it does not to remove it //if (!addMode && mode[i] != 'l') { //mode has parameter temp = (string)parametersEnumerator.Current; parametersEnumerator.MoveNext(); } chan.UpdateChannelMode(mode[i], temp, addMode); } else //check if it is an actual channel mode, and not a user mode if (connection.ServerSetting.ChannelModeNoParam.Contains(mode[i].ToString())) chan.UpdateChannelMode(mode[i], addMode); */ break; } } if (inputPanel.CurrentConnection == connection) { string network = ""; if (connection.ServerSetting.NetworkName.Length > 0) network = " (" + connection.ServerSetting.NetworkName + ")"; if (mainTabControl.CurrentTab == chan) StatusText(connection.ServerSetting.NickName + " in " + chan.TabCaption + " [" + chan.ChannelModes + "] {" + chan.Connection.ServerSetting.RealServerName + "}" + network); } } } catch (Exception e) { WriteErrorFile(connection, "OnChannelMode", e); } }
private void OnServerPreConnect(IRCConnection connection) { PluginArgs args = new PluginArgs(connection); foreach (IPluginIceChat ipc in loadedPlugins) { if (ipc.Enabled == true) ipc.ServerPreConnect(args); } }
private void ParseGoogleResults(PluginArgs args, String url, bool self) { System.Net.WebClient web = new System.Net.WebClient(); string html = web.DownloadString(url); // put a max timer on this int tickCount = System.Environment.TickCount; if (html.Length > 0) { //int searchDiv = html.IndexOf("Search Results"); // int searchDiv = html.IndexOf("id=\"topstuff\">"); System.Diagnostics.Debug.WriteLine("searchDiv:" + searchDiv); if (searchDiv > -1) { System.Diagnostics.Debug.WriteLine(html.Substring(searchDiv)); //do a loop int counter = 0; PluginArgs a = new PluginArgs(args.Connection); do { int i = html.IndexOf("<div class=\"g\"", searchDiv); System.Diagnostics.Debug.WriteLine("search g:" + i + ":" + counter); if (i > 0) { //counter++; if (System.Environment.TickCount - tickCount > 10000) { break; } int x = html.IndexOf("<a href=\"/url?q=", i + 1) + 16; int y = html.IndexOf("\"", x + 1); //System.Diagnostics.Debug.WriteLine(x); //extract the url System.Diagnostics.Debug.WriteLine("link=" + html.Substring(x, y - x)); string link = html.Substring(x, y - x); //now cut off the link to the 1st & link = link.Substring(0, link.IndexOf("&")); link = link.Replace("%3F", "?"); link = link.Replace("%3D", "="); int y2 = html.IndexOf(">", y) + 1; int z = html.IndexOf("</a>", y2); System.Diagnostics.Debug.WriteLine(html.Substring(y2, z - y2)); string desc = html.Substring(y2, z - y2); desc = desc.Replace("<em>", ""); desc = desc.Replace("</em>", ""); desc = desc.Replace("<b>", ""); desc = desc.Replace("</b>", ""); desc = desc.Replace("&", "&"); searchDiv = html.IndexOf("<div class=\"g\"", z) - 1; if (!link.StartsWith("/search?q=")) { counter++; if (self == false) { a.Command = "/notice " + args.Nick + " " + link + " : " + desc; OnCommand(a); } else { a.Command = "/echo " + link + " : " + desc; OnCommand(a); } } System.Diagnostics.Debug.WriteLine(link); } System.Diagnostics.Debug.WriteLine(searchDiv + ":" + html.Length); if (searchDiv >= html.Length || i == -1) { break; } } while (counter < 5); } } }
/// <summary> /// Received a User Notice /// </summary> /// <param name="connection">Which Connection it came from</param> /// <param name="nick">The Nick who sent the Notice</param> /// <param name="message">The Notice message</param> private void OnUserNotice(IRCConnection connection, string nick, string message) { if (message.ToUpper().StartsWith("DCC CHAT")) { if (FormMain.Instance.IceChatOptions.DCCChatIgnore) return; } string msg = GetMessageFormat("User Notice"); if (connection.ServerSetting.RealServerName.Length > 0) msg = msg.Replace("$server", connection.ServerSetting.RealServerName); else msg = msg.Replace("$server", connection.ServerSetting.ServerName); msg = msg.Replace("$nick", nick); msg = msg.Replace("$message", message); PluginArgs args = new PluginArgs(CurrentWindow.TextWindow, "", nick, "", msg); args.Extra = message; args.Connection = connection; foreach (IPluginIceChat ipc in loadedPlugins) { if (ipc.Enabled == true) args = ipc.UserNotice(args); } CurrentWindowMessage(connection, args.Message, 1, false); PlaySoundFile("notice"); }
/// <summary> /// Channel Topic Changed /// </summary> /// <param name="connection">Which Connection it came from</param> /// <param name="channel">Which Channel the Topic changed for</param> /// <param name="nick">Nick who changed the Topic</param> /// <param name="topic">New Channel Topic</param> private void OnChannelTopic(IRCConnection connection, string channel, string nick, string host, string topic) { IceTabPage t = GetWindow(connection, channel, IceTabPage.WindowType.Channel); if (t != null) { t.ChannelTopic = topic; if (nick.Length > 0) { string msg = GetMessageFormat("Channel Topic Change"); msg = msg.Replace("$nick", nick); msg = msg.Replace("$host", host); msg = msg.Replace("$channel", channel); msg = msg.Replace("$topic", topic); if (iceChatOptions.TopicEventLocation == 0) { //send it to the channel t.TextWindow.AppendText(msg, 1); t.LastMessageType = ServerMessageType.Other; } else if (iceChatOptions.TopicEventLocation == 1) { //send it to the console mainTabControl.GetTabPage("Console").AddText(connection, msg, 1, false); } PluginArgs args = new PluginArgs(t, channel, nick, host, msg); args.Connection = connection; foreach (IPluginIceChat ipc in loadedPlugins) { if (ipc.Enabled == true) ipc.ChannelTopic(args); } } else { string msgt = GetMessageFormat("Channel Topic Text"); msgt = msgt.Replace("$channel", channel); msgt = msgt.Replace("$topic", topic); t.TextWindow.AppendText(msgt, 1); t.LastMessageType = ServerMessageType.Other; PluginArgs args = new PluginArgs(t, channel, nick, host, msgt); args.Connection = connection; foreach (IPluginIceChat ipc in loadedPlugins) { if (ipc.Enabled == true) ipc.ChannelTopic(args); } } } }
/// <summary> /// Received a Channel Action /// </summary> /// <param name="connection">Which Connection it came from</param> /// <param name="channel">Which Channel it is from</param> /// <param name="nick">Nick who sent the action</param> /// <param name="message">Channel action</param> private void OnChannelAction(IRCConnection connection, string channel, string nick, string host, string message) { IceTabPage t = GetWindow(connection, channel, IceTabPage.WindowType.Channel); if (t != null) { string msg = GetMessageFormat("Channel Action"); msg = msg.Replace("$nick", nick).Replace("$channel", channel); msg = msg.Replace("$color", ""); msg = msg.Replace("$message", message); PluginArgs args = new PluginArgs(t.TextWindow, channel, nick, host, msg); args.Extra = message; args.Connection = connection; foreach (IPluginIceChat ipc in loadedPlugins) { if (ipc.Enabled == true) args = ipc.ChannelAction(args); } if (iceChatOptions.ChannelActionEventLocation == 0) { //send it to the channel t.TextWindow.AppendText(args.Message, 1); t.LastMessageType = ServerMessageType.Action; } else if (iceChatOptions.ChannelActionEventLocation == 1) { //send it to the console mainTabControl.GetTabPage("Console").AddText(connection, args.Message, 1, false); } } }
/// <summary> /// Received a CTCP Message /// </summary> /// <param name="connection">Which Connection it came from</param> /// <param name="nick">The Nick who sent the CTCP Message</param> /// <param name="ctcp">The CTCP Message</param> private void OnCtcpMessage(IRCConnection connection, string nick, string ctcp, string message) { //we need to send a ctcp reply string msg = GetMessageFormat("Ctcp Request"); msg = msg.Replace("$nick", nick); msg = msg.Replace("$ctcp", ctcp); PluginArgs args = new PluginArgs(mainTabControl.GetTabPage("Console").TextWindow, "", nick,"", msg); args.Extra = ctcp; args.Connection = connection; foreach (IPluginIceChat ipc in loadedPlugins) { if (ipc.Enabled == true) args = ipc.CtcpMessage(args); } //check if CTCP's are enabled if (connection.ServerSetting.DisableCTCP) return; CurrentWindowMessage(connection, args.Message, 7, false); switch (ctcp) { case "VERSION": SendData(connection, "NOTICE " + nick + " :" + ((char)1).ToString() + "VERSION " + ProgramID + " " + VersionID + " : " + GetOperatingSystemName() + ((char)1).ToString()); break; case "PING": SendData(connection, "NOTICE " + nick + " :" + ((char)1).ToString() + "PING " + System.Environment.TickCount.ToString() + ((char)1).ToString()); break; case "TIME": SendData(connection, "NOTICE " + nick + " :" + ((char)1).ToString() + "TIME " + System.DateTime.Now.ToString() + ((char)1).ToString()); break; case "USERINFO": SendData(connection, "NOTICE " + nick + " :" + ((char)1).ToString() + "USERINFO IceChat IRC Client : Download at http://www.icechat.net" + ((char)1).ToString()); break; case "CLIENTINFO": SendData(connection, "NOTICE " + nick + " :" + ((char)1).ToString() + "CLIENTINFO This client supports: UserInfo, Finger, Version, Source, Ping, Time and ClientInfo" + ((char)1).ToString()); break; case "SOURCE": SendData(connection, "NOTICE " + nick + " :" + ((char)1).ToString() + "SOURCE " + FormMain.ProgramID + " " + FormMain.VersionID + " http://www.icechat.net" + ((char)1).ToString()); break; case "FINGER": SendData(connection, "NOTICE " + nick + " :" + ((char)1).ToString() + "FINGER Stop fingering me" + ((char)1).ToString()); break; } }
/// <summary> /// A User Joined a Channel /// </summary> /// <param name="connection">Which Connection it came from</param> /// <param name="channel">Which Channel was Joined</param> /// <param name="user">Full User Host of who Joined</param> /// <param name="refresh">Whether to Refresh the Nick List</param> private void OnChannelJoin(IRCConnection connection, string channel, string nick, string host, bool refresh) { IceTabPage t = GetWindow(connection, channel, IceTabPage.WindowType.Channel); if (t != null) { if (refresh) { string msg = GetMessageFormat("Channel Join"); msg = msg.Replace("$nick", nick).Replace("$channel", channel).Replace("$host", host); PluginArgs args = new PluginArgs(t.TextWindow, channel, nick, host, msg); args.Connection = connection; foreach (IPluginIceChat ipc in loadedPlugins) { if (ipc.Enabled == true) args = ipc.ChannelJoin(args); } if (iceChatOptions.JoinEventLocation == 0) { //send to the channel window t.TextWindow.AppendText(args.Message, 1); t.LastMessageType = ServerMessageType.JoinChannel; } else if (iceChatOptions.JoinEventLocation == 1) { //send to the console mainTabControl.GetTabPage("Console").AddText(connection, args.Message, 1, false); } } t.AddNick(nick, refresh); } }
/// <summary> /// Show a reply to a CTCP Message we have sent out /// </summary> /// <param name="connection"></param> /// <param name="nick"></param> /// <param name="ctcp"></param> /// <param name="message"></param> private void OnCtcpReply(IRCConnection connection, string nick, string ctcp, string message) { //we got a ctcp reply string msg = GetMessageFormat("Ctcp Reply"); msg = msg.Replace("$nick", nick); msg = msg.Replace("$ctcp", ctcp); msg = msg.Replace("$reply", message); PluginArgs args = new PluginArgs(mainTabControl.GetTabPage("Console").TextWindow, "", nick, "", msg); args.Extra = ctcp; args.Connection = connection; foreach (IPluginIceChat ipc in loadedPlugins) { if (ipc.Enabled == true) args = ipc.CtcpReply(args); ; } CurrentWindowMessage(connection, args.Message, 7, false); }
/// <summary> /// A User was kicked from a Channel /// </summary> /// <param name="connection">Which Connection it came from</param> /// <param name="channel">Which Channel the User was Kicked from</param> /// <param name="nick">Nickname of who was Kicked</param> /// <param name="reason">Kick Reason</param> /// <param name="kickUser">Full User Host of Who kicked the User</param> private void OnChannelKick(IRCConnection connection, string channel, string nick, string reason, string kickUser) { IceTabPage t = GetWindow(connection, channel, IceTabPage.WindowType.Channel); if (t != null) { string kickNick = NickFromFullHost(kickUser); string kickHost = HostFromFullHost(kickUser); string msg = GetMessageFormat("Channel Kick"); msg = msg.Replace("$nick", kickNick); msg = msg.Replace("$host", kickHost); msg = msg.Replace("$kickee", nick); msg = msg.Replace("$channel", channel); msg = msg.Replace("$reason", reason); PluginArgs args = new PluginArgs(iceChatOptions.KickEventLocation == 0 ? t.TextWindow : mainTabControl.GetTabPage("Console").TextWindow, channel, nick, "", msg); args.Connection = connection; foreach (IPluginIceChat ipc in loadedPlugins) { if (ipc.Enabled == true) args = ipc.ChannelKick(args); } if (iceChatOptions.KickEventLocation == 0) { //send it to the channel t.TextWindow.AppendText(args.Message, 1); t.LastMessageType = ServerMessageType.Other; } else if (iceChatOptions.KickEventLocation == 1) { //send to the console mainTabControl.GetTabPage("Console").AddText(connection, args.Message, 1, false); } t.RemoveNick(nick); } }
private void OnDCCChat(IRCConnection connection, string nick, string host, string port, string ip) { //check if we have disabled DCC Chats, do we auto-accept or ask to allow if (iceChatOptions.DCCChatIgnore) return; if (!iceChatOptions.DCCChatAutoAccept) { //check if on System Tray if (notifyIcon.Visible) return; //ask for the dcc chat DialogResult askDCC = MessageBox.Show(nick + "@" + host + " wants a DCC Chat, will you accept?", "DCC Chat Request", MessageBoxButtons.YesNo); if (askDCC == DialogResult.No) return; } if (!mainTabControl.WindowExists(connection, nick, IceTabPage.WindowType.DCCChat)) AddWindow(connection, nick, IceTabPage.WindowType.DCCChat); IceTabPage t = GetWindow(connection, nick, IceTabPage.WindowType.DCCChat); if (t != null) { string msg = GetMessageFormat("DCC Chat Request"); msg = msg.Replace("$nick", nick).Replace("$host", host); msg = msg.Replace("$port", port).Replace("$ip", ip); PluginArgs args = new PluginArgs(t.TextWindow, "", nick, host, msg); args.Connection = connection; foreach (IPluginIceChat ipc in loadedPlugins) { //new dcc chat started if (ipc.Enabled == true) args = ipc.DCCChatOpen(args); } t.TextWindow.AppendText(args.Message, 1); t.StartDCCChat(nick, ip, port); t.LastMessageType = ServerMessageType.Other; } }
/// <summary> /// Received a Channel Message /// </summary> /// <param name="connection">Which Connection it came from</param> /// <param name="channel">Which Channel it is from</param> /// <param name="nick">Nick who sent the message</param> /// <param name="message">Channel Message</param> private void OnChannelMessage(IRCConnection connection, string channel, string nick, string host, string message) { IceTabPage t = GetWindow(connection, channel, IceTabPage.WindowType.Channel); if (t != null) { string msg = GetMessageFormat("Channel Message"); msg = msg.Replace("$nick", nick).Replace("$channel", channel).Replace("$host", host); //assign $color to the nickname color //get the user mode for the nickname if (msg.Contains("$color") && t.NickExists(nick)) { User u = t.GetNick(nick); if (iceChatColors.RandomizeNickColors) msg = msg.Replace("$color", ((char)3).ToString() + u.nickColor); else { for (int i = 0; i < u.Level.Length; i++) { if (u.Level[i]) { if (connection.ServerSetting.StatusModes[0][i] == 'q') msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelOwnerColor.ToString("00")); else if (connection.ServerSetting.StatusModes[0][i] == 'a') msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelAdminColor.ToString("00")); else if (connection.ServerSetting.StatusModes[0][i] == 'o') msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelOpColor.ToString("00")); else if (connection.ServerSetting.StatusModes[0][i] == 'h') msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelHalfOpColor.ToString("00")); else if (connection.ServerSetting.StatusModes[0][i] == 'v') msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelVoiceColor.ToString("00")); else msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelOwnerColor.ToString("00")); break; } } if (msg.Contains("$color")) msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelRegularColor.ToString("00")); } } else { //System.Diagnostics.Debug.WriteLine("$color:" + t.NickExists(nick) + ":" + msg); msg = msg.Replace("$color", string.Empty); } //check if the nickname exists if (t.NickExists(nick)) msg = msg.Replace("$status", t.GetNick(nick).ToString().Replace(nick, "")); else msg = msg.Replace("$status", ""); msg = msg.Replace("$message", message); PluginArgs args = new PluginArgs(t.TextWindow, channel, nick, host, msg); args.Extra = message; args.Connection = connection; foreach (IPluginIceChat ipc in loadedPlugins) { if (ipc.Enabled == true) args = ipc.ChannelMessage(args); } args.Message = args.Message.Replace("$message", message); if (args.Message.Contains(connection.ServerSetting.NickName)) { //check if sounds are disabled for this window if (!t.DisableSounds) PlaySoundFile("nickchan"); } if (iceChatOptions.ChannelMessageEventLocation == 0) { //send it to the channel t.TextWindow.AppendText(args.Message, 1); t.LastMessageType = ServerMessageType.Message; if (!t.DisableSounds) PlaySoundFile("chanmsg"); } else if (iceChatOptions.ChannelMessageEventLocation == 1) { //send it to the console mainTabControl.GetTabPage("Console").AddText(connection, args.Message, 1, false); } } }
public override PluginArgs QueryAction(PluginArgs args) { args.Message = CheckTextHighLite(args); return(args); }
/// <summary> /// Received a Channel Notice /// </summary> /// <param name="connection">The connection the notice was received on</param> /// <param name="nick">The nick who sent the notice</param> /// <param name="host">The host of the nick who sent the notice</param> /// <param name="status">The status char that the notice was sent to</param> /// <param name="channel">The channel the notice was sent to</param> /// <param name="notice">The notice message</param> private void OnChannelNotice(IRCConnection connection, string nick, string host, char status, string channel, string message) { IceTabPage t = GetWindow(connection, channel, IceTabPage.WindowType.Channel); if (t != null) { string msg = GetMessageFormat("Channel Notice"); msg = msg.Replace("$nick", nick); msg = msg.Replace("$host", host); if (status == '0') msg = msg.Replace("$status", ""); else msg = msg.Replace("$status", status.ToString()); msg = msg.Replace("$channel", channel); msg = msg.Replace("$message", message); PluginArgs args = new PluginArgs(t, channel, nick, host, msg); args.Connection = connection; foreach (IPluginIceChat ipc in loadedPlugins) { if (ipc.Enabled == true) args = ipc.ChannelNotice(args); } t.TextWindow.AppendText(args.Message, 1); t.LastMessageType = ServerMessageType.Message; } }
private void OnBuddyList(IRCConnection connection, string[] buddies) { PluginArgs args = new PluginArgs(connection); foreach (BuddyListItem b in connection.ServerSetting.BuddyList) { if (b.IsOnSent && !b.IsOnReceived) { bool isFound = false; foreach (string buddy in buddies) { //this nick is connected if (b.Nick.ToLower() == buddy.ToLower()) { b.Connected = true; b.IsOnReceived = true; isFound = true; args.Nick = b.Nick; args.Extra = "online"; foreach (IPluginIceChat ipc in loadedPlugins) { if (ipc.Enabled == true) ipc.BuddyList(args); } } } if (!isFound) { b.Connected = false; b.IsOnReceived = true; args.Nick = b.Nick; args.Extra = "offline"; foreach (IPluginIceChat ipc in loadedPlugins) { if (ipc.Enabled == true) ipc.BuddyList(args); } } } } if (connection.buddiesIsOnSent == connection.ServerSetting.BuddyList.Length) { //reset all the isonsent values foreach (BuddyListItem buddy in connection.ServerSetting.BuddyList) { buddy.IsOnSent = false; buddy.IsOnReceived = false; } connection.buddiesIsOnSent = 0; //send a user event to refresh the buddy list for this server this.buddyList.ClearBuddyList(connection); foreach (BuddyListItem buddy in connection.ServerSetting.BuddyList) { this.buddyList.UpdateBuddy(connection, buddy); } } }
/// <summary> /// Parse out command written in Input Box or sent from Plugin /// </summary> /// <param name="connection">Which Connection it is for</param> /// <param name="data">The Message to Parse</param> public void ParseOutGoingCommand(IRCConnection connection, string data) { try { data = data.Replace("", ((char)3).ToString()); PluginArgs args = new PluginArgs(connection); args.Command = data; foreach (IPluginIceChat ipc in loadedPlugins) { if (ipc.Enabled == true) args = ipc.InputText(args); } data = args.Command; if (data.Length == 0) return; if (data.StartsWith("//")) { //parse out identifiers ParseOutGoingCommand(connection, ParseIdentifiers(connection, data, data)); return; } if (data.StartsWith("/")) { int indexOfSpace = data.IndexOf(" "); string command = ""; string temp = ""; if (indexOfSpace > 0) { command = data.Substring(0, indexOfSpace); data = data.Substring(command.Length + 1); } else { command = data; data = ""; } //check for aliases foreach (AliasItem a in iceChatAliases.listAliases) { if (a.AliasName == command) { if (a.Command.Length == 1) { data = ParseIdentifierValue(a.Command[0], data); ParseOutGoingCommand(connection, ParseIdentifiers(connection, data, data)); } else { //it is a multulined alias, run multiple commands foreach (string c in a.Command) { data = ParseIdentifierValue(c, data); ParseOutGoingCommand(connection, ParseIdentifiers(connection, data, data)); } } return; } } switch (command.ToLower()) { case "/makeexception": throw new Exception("IceChat 9 Test Exception Error"); case "/addlines": for (int i = 0; i < 250; i++) { string msg = i.ToString() + ". The quick brown fox jumps over the lazy dog and gets away with it"; CurrentWindowMessage(connection, msg, 4, true); } break; case "/background": case "/bg": //change background image for a window(s) if (data.Length > 0) { //bg windowtype imagefile //bg windowtype windowname imagefile //if imagefile is blank, erase background image string window = data.Split(' ')[0]; string file = ""; if (data.IndexOf(' ') > -1) file = data.Substring(window.Length + 1); switch (window.ToLower()) { case "nicklist": break; case "serverlist": break; case "console": //check if the file is a URL if (file.StartsWith("http://")) { System.Net.HttpWebRequest myRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(file); myRequest.Method = "GET"; System.Net.HttpWebResponse myResponse = (System.Net.HttpWebResponse)myRequest.GetResponse(); mainTabControl.GetTabPage("Console").CurrentConsoleWindow().BackGroundImageURL = myResponse.GetResponseStream(); } else { if (file.Length > 0 && File.Exists(picturesFolder + System.IO.Path.DirectorySeparatorChar + file)) mainTabControl.GetTabPage("Console").CurrentConsoleWindow().BackGroundImage = (picturesFolder + System.IO.Path.DirectorySeparatorChar + file); else mainTabControl.GetTabPage("Console").CurrentConsoleWindow().BackGroundImage = ""; } break; case "channel": //get the channel name if (file.IndexOf(' ') > -1) { string channel = file.Split(' ')[0]; //if channel == "all" do it for all file = file.Substring(channel.Length + 1); if (channel.ToLower() == "all") { foreach (IceTabPage t in mainTabControl.TabPages) { if (t.WindowStyle == IceTabPage.WindowType.Channel) { if (file.StartsWith("http://")) { System.Net.HttpWebRequest myRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(file); myRequest.Method = "GET"; System.Net.HttpWebResponse myResponse = (System.Net.HttpWebResponse)myRequest.GetResponse(); t.TextWindow.BackGroundImageURL = myResponse.GetResponseStream(); } else { if (File.Exists(picturesFolder + System.IO.Path.DirectorySeparatorChar + file)) t.TextWindow.BackGroundImage = (picturesFolder + System.IO.Path.DirectorySeparatorChar + file); else t.TextWindow.BackGroundImage = ""; } } } } else { IceTabPage t = GetWindow(connection, channel, IceTabPage.WindowType.Channel); if (t != null) { if (file.StartsWith("http://")) { System.Net.HttpWebRequest myRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(file); myRequest.Method = "GET"; System.Net.HttpWebResponse myResponse = (System.Net.HttpWebResponse)myRequest.GetResponse(); t.TextWindow.BackGroundImageURL = myResponse.GetResponseStream(); } else { if (File.Exists(picturesFolder + System.IO.Path.DirectorySeparatorChar + file)) t.TextWindow.BackGroundImage = (picturesFolder + System.IO.Path.DirectorySeparatorChar + file); else t.TextWindow.BackGroundImage = ""; } } } } else { //only a channel name specified, no file, erase the image //if file == "all" clear em all if (file.ToLower() == "all") { foreach (IceTabPage t in mainTabControl.TabPages) { if (t.WindowStyle == IceTabPage.WindowType.Channel) t.TextWindow.BackGroundImage = ""; } } else { IceTabPage t = GetWindow(connection, file, IceTabPage.WindowType.Channel); if (t != null) t.TextWindow.BackGroundImage = ""; } } break; case "query": break; case "window": if (file.IndexOf(' ') > -1) { string windowName = file.Split(' ')[0]; file = file.Substring(windowName.Length + 1); IceTabPage t = GetWindow(connection, windowName, IceTabPage.WindowType.Window); if (t != null) { if (file.StartsWith("http://")) { System.Net.HttpWebRequest myRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(file); myRequest.Method = "GET"; System.Net.HttpWebResponse myResponse = (System.Net.HttpWebResponse)myRequest.GetResponse(); t.TextWindow.BackGroundImageURL = myResponse.GetResponseStream(); } else { if (File.Exists(picturesFolder + System.IO.Path.DirectorySeparatorChar + file)) t.TextWindow.BackGroundImage = (picturesFolder + System.IO.Path.DirectorySeparatorChar + file); else t.TextWindow.BackGroundImage = ""; } } } else { IceTabPage t = GetWindow(connection, file, IceTabPage.WindowType.Window); if (t != null) t.TextWindow.BackGroundImage = ""; } break; } } break; case "/unloadplugin": if (data.Length > 0) { //get the plugin name, and look for it in the menu items ToolStripMenuItem menuItem = null; foreach (ToolStripMenuItem t in pluginsToolStripMenuItem.DropDownItems) if (t.ToolTipText.ToLower() == data.ToLower()) menuItem = t; if (menuItem != null) { //match IPluginIceChat plugin = (IPluginIceChat)menuItem.Tag; plugin.OnCommand -= new OutGoingCommandHandler(Plugin_OnCommand); loadedPlugins.Remove(plugin); menuItem.Click -= new EventHandler(OnPluginMenuItemClick); pluginsToolStripMenuItem.DropDownItems.Remove(menuItem); //AppDomain.Unload(plugin.domain); //plugin.domain = null; plugin.Dispose(); WindowMessage(null, "Console", "Unloaded Plugin - " + plugin.Name, 4, true); } } break; case "/statusplugin": if (data.Length > 0 && data.IndexOf(' ') > 0) { string[] values = data.Split(new char[] { ' ' }, 2); ToolStripMenuItem menuItem = null; foreach (ToolStripMenuItem t in pluginsToolStripMenuItem.DropDownItems) if (t.ToolTipText.ToLower() == values[1].ToLower()) menuItem = t; if (menuItem != null) { //match IPluginIceChat plugin = (IPluginIceChat)menuItem.Tag; plugin.Enabled = Convert.ToBoolean(values[0]); if (plugin.Enabled == true) { WindowMessage(null, "Console", "Enabled Plugin - " + plugin.Name + " v" + plugin.Version, 4, true); //remove the icon menuItem.Image = null; } else { WindowMessage(null, "Console", "Disabled Plugin - " + plugin.Name + " v" + plugin.Version, 4, true); menuItem.Image = StaticMethods.LoadResourceImage("CloseButton.png"); } } } break; case "/loadplugin": if (data.Length > 0) { loadPlugin(pluginsFolder + System.IO.Path.DirectorySeparatorChar + data); } break; case "/reload": if (data.Length > 0) { switch (data) { case "alias": case "aliases": CurrentWindowMessage(connection, "Aliases file reloaded", 4, true); LoadAliases(); break; case "popup": case "popups": CurrentWindowMessage(connection, "Popups file reloaded", 4, true); LoadPopups(); break; case "emoticon": case "emoticons": CurrentWindowMessage(connection, "Emoticons file reloaded", 4, true); LoadEmoticons(); break; case "sound": case "sounds": CurrentWindowMessage(connection, "Sounds file reloaded", 4, true); LoadSounds(); break; case "color": case "colors": CurrentWindowMessage(connection, "Colors file reloaded", 4, true); LoadColors(); toolStripMain.BackColor = IrcColor.colors[iceChatColors.ToolbarBackColor]; menuMainStrip.BackColor = IrcColor.colors[iceChatColors.MenubarBackColor]; statusStripMain.BackColor = IrcColor.colors[iceChatColors.StatusbarBackColor]; toolStripStatus.ForeColor = IrcColor.colors[iceChatColors.StatusbarForeColor]; inputPanel.SetInputBoxColors(); channelList.SetListColors(); buddyList.SetListColors(); break; case "font": case "fonts": CurrentWindowMessage(connection, "Fonts file reloaded", 4, true); LoadFonts(); nickList.Font = new Font(iceChatFonts.FontSettings[3].FontName, iceChatFonts.FontSettings[3].FontSize); serverTree.Font = new Font(iceChatFonts.FontSettings[4].FontName, iceChatFonts.FontSettings[4].FontSize); menuMainStrip.Font = new Font(iceChatFonts.FontSettings[7].FontName, iceChatFonts.FontSettings[7].FontSize); break; } } break; /* case "/reloadplugin": if (data.Length > 0) { //get the plugin name, and look for it in the menu items ToolStripMenuItem menuItem = null; foreach (ToolStripMenuItem t in pluginsToolStripMenuItem.DropDownItems) if (t.ToolTipText.ToLower() == data.ToLower()) menuItem = t; if (menuItem != null) { //match IPluginIceChat plugin = (IPluginIceChat)menuItem.Tag; plugin.OnCommand -= new OutGoingCommandHandler(Plugin_OnCommand); loadedPlugins.Remove(plugin); plugin.Dispose(); Type ObjType = null; Assembly ass = null; try { //reload the plugin ass = Assembly.LoadFile(pluginsFolder + System.IO.Path.DirectorySeparatorChar + menuItem.ToolTipText); //System.Diagnostics.Debug.WriteLine(ass.ToString()); if (ass != null) { ObjType = ass.GetType("IceChatPlugin.Plugin"); } else { System.Diagnostics.Debug.WriteLine("assembly is null"); } } catch (Exception ex) { WriteErrorFile(connection, "ReLoadPlugins Cast:", ex); } try { // OK Lets create the object as we have the Report Type if (ObjType != null) { //System.Diagnostics.Debug.WriteLine("create instance of " + args); IPluginIceChat ipi = (IPluginIceChat)Activator.CreateInstance(ObjType); ipi.MainForm = this; ipi.MainMenuStrip = this.MainMenuStrip; ipi.CurrentFolder = currentFolder; WindowMessage(null, "Console", "Re-Loaded Plugin - " + ipi.Name + " v" + ipi.Version + " by " + ipi.Author, 4, true); menuItem.Tag = ipi; ipi.OnCommand += new OutGoingCommandHandler(Plugin_OnCommand); ipi.Initialize(); loadedPlugins.Add(ipi); } else { System.Diagnostics.Debug.WriteLine("obj type is null:" + menuItem.ToolTipText); } } catch (Exception ex) { WriteErrorFile(connection, "ReLoadPlugins", ex); } } } break; */ case "/addtext": if (data.Length > 0) { inputPanel.AppendText(data); FocusInputBox(); } break; case "/ame": //me command for all channels if (connection != null && data.Length > 0) { foreach (IceTabPage t in FormMain.Instance.TabMain.TabPages) { if (t.WindowStyle == IceTabPage.WindowType.Channel) { if (t.Connection == connection) { SendData(connection, "PRIVMSG " + t.TabCaption + " :ACTION " + data + ""); string msg = GetMessageFormat("Self Channel Action"); msg = msg.Replace("$nick", t.Connection.ServerSetting.NickName).Replace("$channel", t.TabCaption); msg = msg.Replace("$message", data); t.TextWindow.AppendText(msg, 1); t.TextWindow.ScrollToBottom(); t.LastMessageType = ServerMessageType.Action; } } } } break; case "/amsg": //send a message to all channels if (connection != null && data.Length > 0) { foreach (IceTabPage t in FormMain.Instance.TabMain.TabPages) { if (t.WindowStyle == IceTabPage.WindowType.Channel) { if (t.Connection == connection) { SendData(connection, "PRIVMSG " + t.TabCaption + " :" + data); string msg = GetMessageFormat("Self Channel Message"); msg = msg.Replace("$nick", t.Connection.ServerSetting.NickName).Replace("$channel", t.TabCaption); //assign $color to the nickname if (msg.Contains("$color")) { User u = CurrentWindow.GetNick(t.Connection.ServerSetting.NickName); for (int i = 0; i < u.Level.Length; i++) { if (u.Level[i]) { if (connection.ServerSetting.StatusModes[0][i] == 'v') msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelVoiceColor.ToString("00")); else if (connection.ServerSetting.StatusModes[0][i] == 'h') msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelHalfOpColor.ToString("00")); else if (connection.ServerSetting.StatusModes[0][i] == 'o') msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelOpColor.ToString("00")); else if (connection.ServerSetting.StatusModes[0][i] == 'a') msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelAdminColor.ToString("00")); else if (connection.ServerSetting.StatusModes[0][i] == 'q') msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelOwnerColor.ToString("00")); else msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelOwnerColor.ToString("00")); break; } } if (msg.Contains("$color")) msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelRegularColor.ToString("00")); } msg = msg.Replace("$status", CurrentWindow.GetNick(t.Connection.ServerSetting.NickName).ToString().Replace(t.Connection.ServerSetting.NickName, "")); msg = msg.Replace("$message", data); t.TextWindow.AppendText(msg, 1); t.TextWindow.ScrollToBottom(); t.LastMessageType = ServerMessageType.Message; } } } } break; case "/anick": if (data.Length > 0) { foreach (IRCConnection c in serverTree.ServerConnections.Values) if (c.IsConnected) SendData(c, "NICK " + data); } break; case "/autojoin": if (connection != null) { if (data.Length == 0) { if (connection.ServerSetting.AutoJoinChannels != null) { foreach (string chan in connection.ServerSetting.AutoJoinChannels) { if (!chan.StartsWith(";")) SendData(connection, "JOIN " + chan); } } } else { if (connection.ServerSetting.AutoJoinChannels == null) { //we have no autojoin channels, so just add it connection.ServerSetting.AutoJoinChannels = new string[1]; connection.ServerSetting.AutoJoinChannels[0] = data; CurrentWindowMessage(connection, data + " is added to the Autojoin List", 7, true); serverTree.SaveServers(serverTree.ServersCollection); } else { //check if it is in the list first bool Exists = false; bool Disabled = false; string[] oldAutoJoin = new string[connection.ServerSetting.AutoJoinChannels.Length]; int i = 0; foreach (string chan in connection.ServerSetting.AutoJoinChannels) { if (chan.ToLower() == data.ToLower()) { //already in the list Exists = true; oldAutoJoin[i] = chan; CurrentWindowMessage(connection, data + " is already in the Autojoin List", 7, true); } else if (chan.ToLower() == (";" + data.ToLower())) { //already in the list, but disabled //so lets enable it Disabled = true; oldAutoJoin[i] = chan.Substring(1); CurrentWindowMessage(connection, data + " is enabled in the Autojoin List", 7, true); } else oldAutoJoin[i] = chan; i++; } if (!Exists) { //add a new item connection.ServerSetting.AutoJoinChannels = new string[connection.ServerSetting.AutoJoinChannels.Length + 1]; i = 0; foreach (string chan in oldAutoJoin) { connection.ServerSetting.AutoJoinChannels[i] = chan; i++; } connection.ServerSetting.AutoJoinChannels[i] = data; CurrentWindowMessage(connection, data + " is added to the Autojoin List", 7, true); serverTree.SaveServers(serverTree.ServersCollection); } else if (Disabled) { connection.ServerSetting.AutoJoinChannels = new string[connection.ServerSetting.AutoJoinChannels.Length]; i = 0; foreach (string chan in oldAutoJoin) { connection.ServerSetting.AutoJoinChannels[i] = chan; } serverTree.SaveServers(serverTree.ServersCollection); } } } } break; case "/autoperform": if (connection != null) { if (connection.ServerSetting.AutoPerform != null) { foreach (string ap in connection.ServerSetting.AutoPerform) { string autoCommand = ap.Replace("\r", String.Empty); if (!autoCommand.StartsWith(";")) ParseOutGoingCommand(connection, autoCommand); } } } break; case "/aaway": foreach (IRCConnection c in serverTree.ServerConnections.Values) { if (c.IsConnected) { ParseOutGoingCommand(c, "/away " + data); } } break; case "/away": if (connection != null) { if (connection.ServerSetting.Away) { connection.ServerSetting.Away = false; ParseOutGoingCommand(connection, "/nick " + connection.ServerSetting.DefaultNick); TimeSpan t = DateTime.Now.Subtract(connection.ServerSetting.AwayStart); string s = t.Seconds.ToString() + " secs"; if (t.Minutes > 0) s = t.Minutes.ToString() + " mins " + s; if (t.Hours > 0) s = t.Hours.ToString() + " hrs " + s; if (t.Days > 0) s = t.Days.ToString() + " days " + s; ParseOutGoingCommand(connection, "/ame is no longer away : Gone for " + s); } else { connection.ServerSetting.Away = true; connection.ServerSetting.DefaultNick = connection.ServerSetting.NickName; connection.ServerSetting.AwayStart = System.DateTime.Now; ParseOutGoingCommand(connection, "/nick " + connection.ServerSetting.AwayNickName); if (data.Length == 0) ParseOutGoingCommand(connection, "/ame is set as away"); else ParseOutGoingCommand(connection, "/ame is set as away : Reason(" + data + ")"); } } break; case "/ban": // /ban #channel nick|address /mode #channel +b host if (connection != null && data.IndexOf(' ') > 0) { string channel = data.Split(' ')[0]; string host = data.Split(' ')[1]; ParseOutGoingCommand(connection, "/mode " + channel + " +b " + host); } break; case "/browser": if (data.Length > 0) { if (data.StartsWith("http")) System.Diagnostics.Process.Start(data); else System.Diagnostics.Process.Start("http://" + data); } break; case "/buddylist": case "/notify": //add a nickname to the buddy list if (connection != null && data.Length > 0 && data.IndexOf(" ") == -1) { //check if the nickname is already in the buddy list if (connection.ServerSetting.BuddyList != null) { foreach (BuddyListItem buddy in connection.ServerSetting.BuddyList) { if (!buddy.Nick.StartsWith(";")) if (buddy.Nick.ToLower() == data.ToLower()) return; else if (buddy.Nick.Substring(1).ToLower() == data.ToLower()) return; } } //add in the new buddy list item BuddyListItem b = new BuddyListItem(); b.Nick = data; BuddyListItem[] buddies = connection.ServerSetting.BuddyList; Array.Resize(ref buddies, buddies.Length + 1); buddies[buddies.Length - 1] = b; connection.ServerSetting.BuddyList = buddies; serverTree.SaveServers(serverTree.ServersCollection); connection.BuddyListCheck(); } break; case "/chaninfo": if (connection != null) { if (data.Length > 0) { IceTabPage t = GetWindow(connection, data, IceTabPage.WindowType.Channel); if (t != null) { FormChannelInfo fci = new FormChannelInfo(t); SendData(connection, "MODE " + t.TabCaption + " +b"); //check if mode (e) exists for Exception List if (connection.ServerSetting.ChannelModeParam.Contains("e")) SendData(connection, "MODE " + t.TabCaption + " +e"); SendData(connection, "TOPIC :" + t.TabCaption); fci.ShowDialog(this); } } else { //check if current window is channel if (CurrentWindowType == IceTabPage.WindowType.Channel) { FormChannelInfo fci = new FormChannelInfo(CurrentWindow); SendData(connection, "MODE " + CurrentWindow.TabCaption + " +b"); //check if mode (e) exists for Exception List if (connection.ServerSetting.ChannelModeParam.Contains("e")) SendData(connection, "MODE " + CurrentWindow.TabCaption + " +e"); SendData(connection, "TOPIC :" + CurrentWindow.TabCaption); fci.ShowDialog(this); } } } break; case "/clear": if (data.Length == 0) { if (CurrentWindowType != IceTabPage.WindowType.Console) CurrentWindow.TextWindow.ClearTextWindow(); else { //find the current console tab window mainTabControl.GetTabPage("Console").CurrentConsoleWindow().ClearTextWindow(); } } else { //find a match if (data == "Console") { mainTabControl.GetTabPage("Console").CurrentConsoleWindow().ClearTextWindow(); return; } else if (data.ToLower() == "all console") { //clear all the console windows and channel/queries foreach (ConsoleTab c in mainTabControl.GetTabPage("Console").ConsoleTab.TabPages) ((TextWindow)c.Controls[0]).ClearTextWindow(); } IceTabPage t = GetWindow(connection, data, IceTabPage.WindowType.Channel); if (t != null) t.TextWindow.ClearTextWindow(); else { IceTabPage q = GetWindow(connection, data, IceTabPage.WindowType.Query); if (q != null) { q.TextWindow.ClearTextWindow(); return; } IceTabPage dcc = GetWindow(connection, data, IceTabPage.WindowType.DCCChat); if (dcc != null) dcc.TextWindow.ClearTextWindow(); } } break; case "/clearall": //clear all the text windows for (int i = mainTabControl.TabPages.Count - 1; i >= 0; i--) { if (mainTabControl.TabPages[i].WindowStyle == IceTabPage.WindowType.Channel || mainTabControl.TabPages[i].WindowStyle == IceTabPage.WindowType.Query) { mainTabControl.TabPages[i].TextWindow.ClearTextWindow(); } else if (mainTabControl.TabPages[i].WindowStyle == IceTabPage.WindowType.Console) { //clear all console windows foreach (ConsoleTab c in mainTabControl.GetTabPage("Console").ConsoleTab.TabPages) { ((TextWindow)c.Controls[0]).ClearTextWindow(); } } } break; case "/close": if (connection != null && data.Length > 0) { //check if it is a channel list window if (data == "Channels") { IceTabPage c = GetWindow(connection, "", IceTabPage.WindowType.ChannelList); if (c != null) RemoveWindow(connection, "", IceTabPage.WindowType.ChannelList); return; } //check if it is a query window IceTabPage q = GetWindow(connection, data, IceTabPage.WindowType.Query); if (q != null) { RemoveWindow(connection, q.TabCaption, IceTabPage.WindowType.Query); return; } //check if it is a dcc chat window IceTabPage dcc = GetWindow(connection, data, IceTabPage.WindowType.DCCChat); if (dcc != null) RemoveWindow(connection, dcc.TabCaption, IceTabPage.WindowType.DCCChat); } else if (connection != null) { //check if current window is channel/query/dcc chat if (CurrentWindowType == IceTabPage.WindowType.Query) RemoveWindow(connection, CurrentWindow.TabCaption, CurrentWindow.WindowStyle); else if (CurrentWindowType == IceTabPage.WindowType.DCCChat) RemoveWindow(connection, CurrentWindow.TabCaption, CurrentWindow.WindowStyle); else if (CurrentWindowType == IceTabPage.WindowType.Channel) { SendData(connection, "PART " + CurrentWindow.TabCaption); RemoveWindow(connection, CurrentWindow.TabCaption, CurrentWindow.WindowStyle); } } else { //check if the current window is the debug window if (CurrentWindowType == IceTabPage.WindowType.Debug) { RemoveWindow(null, "Debug", IceTabPage.WindowType.Debug); } } break; case "/closequery": if (connection != null) { for (int i = mainTabControl.TabPages.Count - 1; i >= 0; i--) { if (mainTabControl.TabPages[i].WindowStyle == IceTabPage.WindowType.Query) { if (mainTabControl.TabPages[i].Connection == connection) { RemoveWindow(connection, mainTabControl.TabPages[i].TabCaption, IceTabPage.WindowType.Query); } } } } break; case "/closeallquery": if (connection != null) { for (int i = mainTabControl.TabPages.Count - 1; i >= 0; i--) { if (mainTabControl.TabPages[i].WindowStyle == IceTabPage.WindowType.Query) { RemoveWindow(connection, mainTabControl.TabPages[i].TabCaption, IceTabPage.WindowType.Query); } } } break; case "/ctcp": if (connection != null && data.IndexOf(' ') > 0) { //ctcp nick ctcptype string nick = data.Substring(0, data.IndexOf(' ')); //get the message string ctcp = data.Substring(data.IndexOf(' ') + 1); string msg = GetMessageFormat("Ctcp Send"); msg = msg.Replace("$nick", nick); ; msg = msg.Replace("$ctcp", ctcp.ToUpper()); CurrentWindowMessage(connection, msg, 7, true); if (ctcp.ToUpper() == "PING") SendData(connection, "PRIVMSG " + nick + " :" + ctcp.ToUpper() + " " + System.Environment.TickCount.ToString() + ""); else SendData(connection, "PRIVMSG " + nick + " " + ctcp.ToUpper() + ""); } break; case "/dcc": if (connection != null && data.IndexOf(' ') > 0) { //get the type of dcc string dccType = data.Substring(0, data.IndexOf(' ')).ToUpper(); //get who it is being sent to string nick = data.Substring(data.IndexOf(' ') + 1); switch (dccType) { case "CHAT": //start a dcc chat if (nick.IndexOf(' ') == -1) //make sure no space in the nick name { //check if we already have a dcc chat open with this person if (!mainTabControl.WindowExists(connection, nick, IceTabPage.WindowType.DCCChat)) { //create a new window AddWindow(connection, nick, IceTabPage.WindowType.DCCChat); IceTabPage t = GetWindow(connection, nick, IceTabPage.WindowType.DCCChat); if (t != null) { t.RequestDCCChat(); string msg = GetMessageFormat("DCC Chat Outgoing"); msg = msg.Replace("$nick", nick); t.TextWindow.AppendText(msg, 1); t.TextWindow.ScrollToBottom(); } } else { mainTabControl.SelectTab(GetWindow(connection, nick, IceTabPage.WindowType.DCCChat)); serverTree.SelectTab(mainTabControl.CurrentTab, false); //see if it is connected or not IceTabPage dcc = GetWindow(connection, nick, IceTabPage.WindowType.DCCChat); if (dcc != null) { if (!dcc.IsConnected) { dcc.RequestDCCChat(); string msg = GetMessageFormat("DCC Chat Outgoing"); msg = msg.Replace("$nick", nick); dcc.TextWindow.AppendText(msg, 1); dcc.TextWindow.ScrollToBottom(); } } } } break; case "SEND": //was a filename specified, if not try and select one string file; if (nick.IndexOf(' ') > 0) { file = nick.Substring(nick.IndexOf(' ') + 1); nick = nick.Substring(0,nick.IndexOf(' ')); //see if the file exists if (!File.Exists(file)) { //file does not exists, just quit //try from the dccsend folder if (File.Exists(iceChatOptions.DCCSendFolder + Path.DirectorySeparatorChar + file)) file=iceChatOptions.DCCSendFolder + Path.DirectorySeparatorChar + file; else return; } } else { //ask for a file name OpenFileDialog dialog = new OpenFileDialog(); dialog.InitialDirectory = iceChatOptions.DCCSendFolder; dialog.CheckFileExists = true; dialog.CheckPathExists = true; if (dialog.ShowDialog() == DialogResult.OK) { //returns the full path System.Diagnostics.Debug.WriteLine(dialog.FileName); file = dialog.FileName; } else return; } //more to it, maybe a file to send if (!mainTabControl.WindowExists(null, "DCC Files", IceTabPage.WindowType.DCCFile)) AddWindow(null, "DCC Files", IceTabPage.WindowType.DCCFile); IceTabPage tt = GetWindow(null, "DCC Files", IceTabPage.WindowType.DCCFile); if (tt != null) ((IceTabPageDCCFile)tt).RequestDCCFile(connection, nick, file); break; } } break; case "/describe": //me command for a specific channel if (connection != null && data.IndexOf(' ') > 0) { //get the channel name string channel = data.Substring(0, data.IndexOf(' ')); //get the message string message = data.Substring(data.IndexOf(' ') + 1); //check for the channel IceTabPage t = GetWindow(connection, channel, IceTabPage.WindowType.Channel); if (t != null) { SendData(connection, "PRIVMSG " + t.TabCaption + " :ACTION " + message + ""); string msg = GetMessageFormat("Self Channel Action"); msg = msg.Replace("$nick", inputPanel.CurrentConnection.ServerSetting.NickName).Replace("$channel", t.TabCaption); msg = msg.Replace("$message", message); t.TextWindow.AppendText(msg, 1); t.TextWindow.ScrollToBottom(); t.LastMessageType = ServerMessageType.Action; } } break; case "/dns": if (data.Length > 0) { if (data.IndexOf(".") > 0) { //dns a host try { System.Net.IPAddress[] addresslist = System.Net.Dns.GetHostAddresses(data); ParseOutGoingCommand(connection, "/echo " + data + " resolved to " + addresslist.Length + " address(es)"); foreach (System.Net.IPAddress address in addresslist) ParseOutGoingCommand(connection, "/echo -> " + address.ToString()); } catch (Exception) { ParseOutGoingCommand(connection, "/echo " + data + " does not resolve (unknown address)"); } } else { //dns a nickname (send a userhost) SendData(connection, "USERHOST " + data); } } break; case "/echo": //currently just echo to the current window if (data.Length > 0) { if (CurrentWindowType == IceTabPage.WindowType.Channel || CurrentWindowType == IceTabPage.WindowType.Query) { string msg = GetMessageFormat("User Echo"); msg = msg.Replace("$message", data); CurrentWindow.TextWindow.AppendText(msg, 1); } else if (CurrentWindowType == IceTabPage.WindowType.Console) { string msg = GetMessageFormat("User Echo"); msg = msg.Replace("$message", data); mainTabControl.GetTabPage("Console").CurrentConsoleWindow().AppendText(msg, 1); } else if (CurrentWindowType == IceTabPage.WindowType.DCCChat) { string msg = GetMessageFormat("User Echo"); msg = msg.Replace("$message", data); CurrentWindow.TextWindow.AppendText(msg, 1); } } break; case "/flash": //used to flash a specific channel or query if (connection != null && data.Length > 0) { string window = data; bool flashWindow = true; if (data.IndexOf(" ") > 0) { window = data.Substring(0, data.IndexOf(' ')); string t = data.Substring(data.IndexOf(' ') + 1); if (t.ToLower() == "off") flashWindow = false; } //check if it is a channel window IceTabPage c = GetWindow(connection, window, IceTabPage.WindowType.Channel); if (c != null) { c.FlashTab = flashWindow; mainTabControl.Invalidate(); serverTree.Invalidate(); } else { //check if it is a query IceTabPage q = GetWindow(connection, window, IceTabPage.WindowType.Query); if (q != null) { q.FlashTab = flashWindow; mainTabControl.Invalidate(); serverTree.Invalidate(); } } } break; case "/flashtray": //check if we are minimized if (this.WindowState == FormWindowState.Minimized) { this.flashTaskBarIconTimer.Enabled = true; this.flashTaskBarIconTimer.Start(); } if (this.notifyIcon.Visible == true) { this.flashTrayIconTimer.Enabled = true; this.flashTrayIconTimer.Start(); //show a message in a balloon if (data.Length > 0) { this.notifyIcon.BalloonTipTitle = "IceChat 9"; this.notifyIcon.BalloonTipText = data; this.notifyIcon.ShowBalloonTip(1000); } } break; case "/font": //change the font of the current window //check if data is a channel if (connection != null && data.Length > 0) { if (data.IndexOf(' ') == -1) { IceTabPage t = GetWindow(connection, data, IceTabPage.WindowType.Channel); if (t != null) { //bring up a font dialog FontDialog fd = new FontDialog(); //load the current font fd.Font = t.TextWindow.Font; if (fd.ShowDialog() != DialogResult.Cancel && fd.Font.Style == FontStyle.Regular) { t.TextWindow.Font = fd.Font; } } } } break; case "/forcequit": if (connection != null) { connection.AttemptReconnect = false; connection.ForceDisconnect(); } break; case "/google": if (data.Length > 0) System.Diagnostics.Process.Start("http://www.google.com/search?q=" + data); else System.Diagnostics.Process.Start("http://www.google.com"); break; case "/hop": if (connection != null && data.Length == 0) { if (CurrentWindowType == IceTabPage.WindowType.Channel) { temp = CurrentWindow.TabCaption; SendData(connection, "PART " + temp); ParseOutGoingCommand(connection, "/timer joinhop 1 1 /join " + temp); } } else { IceTabPage t = GetWindow(connection, data, IceTabPage.WindowType.Channel); if (t != null) { SendData(connection, "PART " + t.TabCaption); ParseOutGoingCommand(connection, "/timer joinhop 1 1 /join " + t.TabCaption); } } break; case "/icechat": if (connection != null) ParseOutGoingCommand(connection, "/me is using " + ProgramID + " " + VersionID); else ParseOutGoingCommand(connection, "/echo using " + ProgramID + " " + VersionID); break; case "/icepath": //To get current Folder and paste it into /me if (connection != null) ParseOutGoingCommand(connection, "/me Build Path = " + Directory.GetCurrentDirectory()); else ParseOutGoingCommand(connection, "/echo Build Path = " + Directory.GetCurrentDirectory()); break; case "/ignore": if (connection != null) { if (data.Length > 0) { //check if just a nick/host , no extra params if (data.IndexOf(" ") == -1) { //check if already in ignore list or not for (int i = 0; i < connection.ServerSetting.IgnoreList.Length;i++ ) { string checkNick = connection.ServerSetting.IgnoreList[i]; if (connection.ServerSetting.IgnoreList[i].StartsWith(";")) checkNick = checkNick.Substring(1); if (checkNick.ToLower() == data.ToLower()) { if (connection.ServerSetting.IgnoreList[i].StartsWith(";")) connection.ServerSetting.IgnoreList[i] = checkNick; else connection.ServerSetting.IgnoreList[i] = ";" + checkNick; serverTree.SaveServers(serverTree.ServersCollection); return; } } //no match found, add the new item to the IgnoreList string[] ignores = connection.ServerSetting.IgnoreList; Array.Resize(ref ignores, ignores.Length + 1); ignores[ignores.Length - 1] = data; connection.ServerSetting.IgnoreList = ignores; serverTree.SaveServers(serverTree.ServersCollection); } } } break; case "/join": if (connection != null && data.Length > 0) SendData(connection, "JOIN " + data); break; case "/kick": if (connection != null && data.Length > 0) { //kick #channel nick reason if (data.IndexOf(' ') > 0) { //get the channel temp = data.Substring(0, data.IndexOf(' ')); //check if temp is a channel or not if (Array.IndexOf(connection.ServerSetting.ChannelTypes, temp[0]) == -1) { //temp is not a channel, substitute with current channel //make sure we are in a channel if (CurrentWindow.WindowStyle == IceTabPage.WindowType.Channel) { temp = CurrentWindow.TabCaption; if (data.IndexOf(' ') > 0) { //there is a kick reason string msg = data.Substring(data.IndexOf(' ') + 1); data = data.Substring(0, data.IndexOf(' ')); SendData(connection, "KICK " + temp + " " + data + " :" + msg); } else { SendData(connection, "KICK " + temp + " " + data); } } } else { data = data.Substring(temp.Length + 1); if (data.IndexOf(' ') > 0) { //there is a kick reason string msg = data.Substring(data.IndexOf(' ') + 1); data = data.Substring(0, data.IndexOf(' ')); SendData(connection, "KICK " + temp + " " + data + " :" + msg); } else { SendData(connection, "KICK " + temp + " " + data); } } } } break; case "/me": //check if in channel, query, etc if (connection != null && data.Length > 0) { if (CurrentWindowType == IceTabPage.WindowType.Channel || CurrentWindowType == IceTabPage.WindowType.Query) { SendData(connection, "PRIVMSG " + CurrentWindow.TabCaption + " :ACTION " + data + ""); string msg = GetMessageFormat("Self Channel Action"); msg = msg.Replace("$nick", inputPanel.CurrentConnection.ServerSetting.NickName).Replace("$channel", CurrentWindow.TabCaption); msg = msg.Replace("$message", data); CurrentWindow.TextWindow.AppendText(msg, 1); CurrentWindow.TextWindow.ScrollToBottom(); CurrentWindow.LastMessageType = ServerMessageType.Action; } else if (CurrentWindowType == IceTabPage.WindowType.DCCChat) { IceTabPage c = GetWindow(connection, CurrentWindow.TabCaption, IceTabPage.WindowType.DCCChat); if (c != null) { c.SendDCCData("ACTION " + data + ""); string msg = GetMessageFormat("DCC Chat Action"); msg = msg.Replace("$nick", inputPanel.CurrentConnection.ServerSetting.NickName); msg = msg.Replace("$message", data); CurrentWindow.TextWindow.AppendText(msg, 1); CurrentWindow.TextWindow.ScrollToBottom(); CurrentWindow.LastMessageType = ServerMessageType.Action; } } } break; case "/mode": if (connection != null && data.Length > 0) SendData(connection, "MODE " + data); break; case "/modex": if (connection != null) SendData(connection, "MODE " + connection.ServerSetting.NickName + " +x"); break; case "/motd": if (connection != null) { connection.ServerSetting.ForceMOTD = true; SendData(connection, "MOTD"); } break; case "/msg": if (connection != null && data.IndexOf(' ') > -1) { string nick = data.Substring(0, data.IndexOf(' ')); string msg2 = data.Substring(data.IndexOf(' ') + 1); if (nick.StartsWith("=")) { //send to a dcc chat window nick = nick.Substring(1); IceTabPage c = GetWindow(connection, nick, IceTabPage.WindowType.DCCChat); if (c != null) { c.SendDCCData(data); string msg = GetMessageFormat("Self DCC Chat Message"); msg = msg.Replace("$nick", c.Connection.ServerSetting.NickName).Replace("$message", data); c.TextWindow.AppendText(msg, 1); } } else { SendData(connection, "PRIVMSG " + nick + " :" + msg2); //get the color for the private message string msg = GetMessageFormat("Self Channel Message"); msg = msg.Replace("$nick", connection.ServerSetting.NickName).Replace("$channel", nick); if (msg.StartsWith("")) { //get the color string color = msg.Substring(0, 6); int result; if (Int32.TryParse(msg.Substring(6, 1), out result)) color += msg.Substring(6, 1); msg = color + "*" + nick + "* " + data.Substring(data.IndexOf(' ') + 1); ; } //check if the nick has a query window open IceTabPage q = GetWindow(connection, nick, IceTabPage.WindowType.Query); if (q != null) { string nmsg = GetMessageFormat("Self Private Message"); nmsg = nmsg.Replace("$nick", connection.ServerSetting.NickName).Replace("$message", msg2); q.TextWindow.AppendText(nmsg, 1); q.LastMessageType = ServerMessageType.Message; if (q != CurrentWindow) CurrentWindowMessage(connection, msg, 1, true); } else CurrentWindowMessage(connection, msg, 1, true); } } break; case "/nick": if (connection != null && data.Length > 0) SendData(connection, "NICK " + data); break; case "/notice": if (connection != null && data.IndexOf(' ') > -1) { string nick = data.Substring(0, data.IndexOf(' ')); string msg = data.Substring(data.IndexOf(' ') + 1); SendData(connection, "NOTICE " + nick + " :" + msg); string nmsg = GetMessageFormat("Self Notice"); nmsg = nmsg.Replace("$nick", nick).Replace("$message", msg); CurrentWindowMessage(connection, nmsg, 1, true); } break; case "/part": if (connection != null && data.Length > 0) { //check if it is a query window IceTabPage q = GetWindow(connection, data, IceTabPage.WindowType.Query); if (q != null) { RemoveWindow(connection, q.TabCaption, IceTabPage.WindowType.Query); return; } else if (CurrentWindowType == IceTabPage.WindowType.Query) { RemoveWindow(connection, CurrentWindow.TabCaption, IceTabPage.WindowType.Query); return; } //is there a part message if (data.IndexOf(' ') > -1) { //check if channel is a valid channel if (Array.IndexOf(connection.ServerSetting.ChannelTypes, data[0]) != -1) { SendData(connection, "PART " + data.Substring(0, data.IndexOf(' ')) + " :" + data.Substring(data.IndexOf(' ') + 1)); RemoveWindow(connection, data.Substring(0, data.IndexOf(' ')), IceTabPage.WindowType.Channel); } else { //not a valid channel, use the current window if (CurrentWindowType == IceTabPage.WindowType.Channel) { SendData(connection, "PART " + CurrentWindow.TabCaption + " :" + data); RemoveWindow(connection, CurrentWindow.TabCaption, IceTabPage.WindowType.Channel); } } } else { //see if data is a valid channel; if (Array.IndexOf(connection.ServerSetting.ChannelTypes, data[0]) != -1) { SendData(connection, "PART " + data); RemoveWindow(connection, data, IceTabPage.WindowType.Channel); } else { if (CurrentWindowType == IceTabPage.WindowType.Channel) { SendData(connection, "PART " + CurrentWindow.TabCaption + " :" + data); RemoveWindow(connection, CurrentWindow.TabCaption, IceTabPage.WindowType.Channel); } } } } else if (connection != null) { //check if current window is channel if (CurrentWindowType == IceTabPage.WindowType.Channel) { SendData(connection, "PART " + CurrentWindow.TabCaption); RemoveWindow(connection, CurrentWindow.TabCaption, IceTabPage.WindowType.Channel); } else if (CurrentWindowType == IceTabPage.WindowType.Query) { RemoveWindow(connection, CurrentWindow.TabCaption, IceTabPage.WindowType.Query); } } break; case "/partall": if (connection != null) { for (int i = mainTabControl.TabPages.Count - 1; i >= 0; i--) { if (mainTabControl.TabPages[i].WindowStyle == IceTabPage.WindowType.Channel) { if (mainTabControl.TabPages[i].Connection == connection) { SendData(connection, "PART " + mainTabControl.TabPages[i].TabCaption); RemoveWindow(connection, mainTabControl.TabPages[i].TabCaption, IceTabPage.WindowType.Channel); } } } } break; case "/ping": if (connection != null && data.Length > 0 && data.IndexOf(' ') == -1) { //ctcp nick ping string msg = GetMessageFormat("Ctcp Send"); msg = msg.Replace("$nick", data); ; msg = msg.Replace("$ctcp", "PING"); CurrentWindowMessage(connection, msg, 7, true); SendData(connection, "PRIVMSG " + data + " :PING " + System.Environment.TickCount.ToString() + ""); } break; case "/play": //play a WAV sound if (data.Length > 4 && data.ToLower().EndsWith(".wav")) { //check if the WAV file exists in the Sounds Folder if (File.Exists(soundsFolder + System.IO.Path.DirectorySeparatorChar + data)) { try { player.SoundLocation = soundsFolder + System.IO.Path.DirectorySeparatorChar + data; player.Play(); } catch { } } //check if the entire path was passed for the sound file else if (File.Exists(data)) { try { player.SoundLocation = @data; player.Play(); } catch { } } } break; case "/query": if (connection != null && data.Length > 0) { string nick = ""; string msg = ""; if (data.IndexOf(" ") > 0) { //check if there is a message added nick = data.Substring(0, data.IndexOf(' ')); msg = data.Substring(data.IndexOf(' ') + 1); } else nick = data; if (!mainTabControl.WindowExists(connection, nick, IceTabPage.WindowType.Query)) AddWindow(connection, nick, IceTabPage.WindowType.Query); mainTabControl.SelectTab(GetWindow(connection, nick, IceTabPage.WindowType.Query)); serverTree.SelectTab(mainTabControl.CurrentTab, false); if (msg.Length > 0) { SendData(connection, "PRIVMSG " + nick + " :" + msg); string nmsg = GetMessageFormat("Self Private Message"); nmsg = nmsg.Replace("$nick", inputPanel.CurrentConnection.ServerSetting.NickName).Replace("$message", msg); CurrentWindow.TextWindow.AppendText(nmsg, 1); CurrentWindow.LastMessageType = ServerMessageType.Message; } } break; case "/quit": if (connection != null) { connection.AttemptReconnect = false; if (data.Length > 0) SendData(connection, "QUIT :" + data); else SendData(connection, "QUIT :" + ParseIdentifiers(connection, connection.ServerSetting.QuitMessage, "")); } break; case "/aquit": case "/quitall": foreach (IRCConnection c in serverTree.ServerConnections.Values) { if (c.IsConnected) { c.AttemptReconnect = false; if (data.Length > 0) SendData(c, "QUIT :" + data); else SendData(c, "QUIT :" + ParseIdentifiers(connection, c.ServerSetting.QuitMessage, "")); } } break; case "/redrawtree": System.Diagnostics.Debug.WriteLine(mainTabControl.CurrentTab.TabCaption); this.serverTree.Invalidate(); break; case "/run": if (data.Length > 0) { if (data.IndexOf("'") == -1) System.Diagnostics.Process.Start(data); else { string cmd = data.Substring(0, data.IndexOf("'")); string arg = data.Substring(data.IndexOf("'") + 1); System.Diagnostics.Process p = System.Diagnostics.Process.Start(cmd, arg); } } break; case "/say": if (connection != null && data.Length > 0) { if (CurrentWindowType == IceTabPage.WindowType.Channel) { SendData(connection, "PRIVMSG " + CurrentWindow.TabCaption + " :" + data); string msg = GetMessageFormat("Self Channel Message"); string nick = inputPanel.CurrentConnection.ServerSetting.NickName; msg = msg.Replace("$nick", nick).Replace("$channel", CurrentWindow.TabCaption); //assign $color to the nickname if (msg.Contains("$color")) { User u = CurrentWindow.GetNick(nick); for (int i = 0; i < u.Level.Length; i++) { if (u.Level[i]) { if (connection.ServerSetting.StatusModes[0][i] == 'v') msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelVoiceColor.ToString("00")); else if (connection.ServerSetting.StatusModes[0][i] == 'h') msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelHalfOpColor.ToString("00")); else if (connection.ServerSetting.StatusModes[0][i] == 'o') msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelOpColor.ToString("00")); else if (connection.ServerSetting.StatusModes[0][i] == 'a') msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelAdminColor.ToString("00")); else if (connection.ServerSetting.StatusModes[0][i] == 'q') msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelOwnerColor.ToString("00")); else msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelOwnerColor.ToString("00")); break; } } if (msg.Contains("$color")) msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelRegularColor.ToString("00")); } msg = msg.Replace("$status", CurrentWindow.GetNick(nick).ToString().Replace(nick, "")); msg = msg.Replace("$message", data); CurrentWindow.TextWindow.AppendText(msg, 1); CurrentWindow.LastMessageType = ServerMessageType.Message; } else if (CurrentWindowType == IceTabPage.WindowType.Query) { SendData(connection, "PRIVMSG " + CurrentWindow.TabCaption + " :" + data); string msg = GetMessageFormat("Self Private Message"); msg = msg.Replace("$nick", inputPanel.CurrentConnection.ServerSetting.NickName).Replace("$message", data); CurrentWindow.TextWindow.AppendText(msg, 1); CurrentWindow.LastMessageType = ServerMessageType.Message; } else if (CurrentWindowType == IceTabPage.WindowType.DCCChat) { CurrentWindow.SendDCCData(data); string msg = GetMessageFormat("Self DCC Chat Message"); msg = msg.Replace("$nick", inputPanel.CurrentConnection.ServerSetting.NickName).Replace("$message", data); CurrentWindow.TextWindow.AppendText(msg, 1); } else if (CurrentWindowType == IceTabPage.WindowType.Console) { WindowMessage(connection, "Console", data, 4, true); } } break; case "/joinserv": //joinserv irc.server.name #channel if (data.Length > 0 && data.IndexOf(' ') > 0) { //check if default nick name has been set if (iceChatOptions.DefaultNick == null || iceChatOptions.DefaultNick.Length == 0) { CurrentWindowMessage(connection, "No Default Nick Name Assigned. Go to Server Settings and set one under the Default Server Settings section.",4 , false); } else { ServerSetting s = new ServerSetting(); //get the server name //if there is a port name. extract it string server = data.Substring(0,data.IndexOf(' ')); string channel = data.Substring(data.IndexOf(' ')+1); if (server.Contains(":")) { s.ServerName = server.Substring(0, server.IndexOf(':')); s.ServerPort = server.Substring(server.IndexOf(':') + 1); if (s.ServerPort.IndexOf(' ') > 0) { s.ServerPort = s.ServerPort.Substring(0, s.ServerPort.IndexOf(' ')); } //check for + in front of port, SSL Connection if (s.ServerPort.StartsWith("+")) { s.ServerPort = s.ServerPort.Substring(1); s.UseSSL = true; } } else { s.ServerName = server; s.ServerPort = "6667"; } s.NickName = iceChatOptions.DefaultNick; s.AltNickName = iceChatOptions.DefaultNick + "_"; s.AwayNickName = iceChatOptions.DefaultNick + "[A]"; s.FullName = iceChatOptions.DefaultFullName; s.QuitMessage = iceChatOptions.DefaultQuitMessage; s.IdentName = iceChatOptions.DefaultIdent; s.IAL = new Hashtable(); s.AutoJoinChannels = new string[] { channel }; s.AutoJoinEnable = true; Random r = new Random(); s.ID = r.Next(50000, 99999); NewServerConnection(s); } } break; case "/server": if (data.Length > 0) { //check if default nick name has been set if (iceChatOptions.DefaultNick == null || iceChatOptions.DefaultNick.Length == 0) { CurrentWindowMessage(connection, "No Default Nick Name Assigned. Go to Server Settings and set one under the Default Server Settings section.", 4, false); } else if (data.StartsWith("id=")) { string serverID = data.Substring(3); foreach (ServerSetting s in serverTree.ServersCollection.listServers) { if (s.ID.ToString() == serverID) { NewServerConnection(s); break; } } } else { ServerSetting s = new ServerSetting(); //get the server name //if there is a port name. extract it if (data.Contains(" ")) { s.ServerName = data.Substring(0, data.IndexOf(' ')); s.ServerPort = data.Substring(data.IndexOf(' ') + 1); if (s.ServerPort.IndexOf(' ') > 0) { s.ServerPort = s.ServerPort.Substring(0, s.ServerPort.IndexOf(' ')); } //check for + in front of port, SSL Connection if (s.ServerPort.StartsWith("+")) { s.ServerPort = s.ServerPort.Substring(1); s.UseSSL = true; s.SSLAcceptInvalidCertificate = true; } } else if (data.Contains(":")) { s.ServerName = data.Substring(0, data.IndexOf(':')); s.ServerPort = data.Substring(data.IndexOf(':') + 1); if (s.ServerPort.IndexOf(' ') > 0) { s.ServerPort = s.ServerPort.Substring(0, s.ServerPort.IndexOf(' ')); } //check for + in front of port, SSL Connection if (s.ServerPort.StartsWith("+")) { s.ServerPort = s.ServerPort.Substring(1); s.UseSSL = true; s.SSLAcceptInvalidCertificate = true; } } else { s.ServerName = data; s.ServerPort = "6667"; } s.NickName = iceChatOptions.DefaultNick; s.AltNickName = iceChatOptions.DefaultNick + "_"; s.AwayNickName = iceChatOptions.DefaultNick + "[A]"; s.FullName = iceChatOptions.DefaultFullName; s.QuitMessage = iceChatOptions.DefaultQuitMessage; s.IdentName = iceChatOptions.DefaultIdent; s.IAL = new Hashtable(); Random r = new Random(); s.ID = r.Next(50000, 99999); NewServerConnection(s); } } break; case "/timers": if (connection != null) { if (connection.IRCTimers.Count == 0) OnServerMessage(connection, "No Timers"); else { foreach (IrcTimer timer in connection.IRCTimers) OnServerMessage(connection, "[ID=" + timer.TimerID + "] [Interval=" + timer.TimerInterval + "] [Reps=" + timer.TimerRepetitions + "] [Count=" + timer.TimerCounter + "] [Command=" + timer.TimerCommand + "]"); } } break; case "/timer": if (connection != null) { if (data.Length != 0) { string[] param = data.Split(' '); if (param.Length == 2) { //check for /timer ID off if (param[1].ToLower() == "off") { connection.DestroyTimer(param[0]); break; } } else if (param.Length > 3) { // param[0] = TimerID // param[1] = Repetitions // param[2] = Interval // param[3+] = Command string timerCommand = String.Join(" ", param, 3, param.GetUpperBound(0) - 2); connection.CreateTimer(param[0], Convert.ToDouble(param[1]), Convert.ToInt32(param[2]), timerCommand); } else { string msg = GetMessageFormat("User Error"); msg = msg.Replace("$message", "/timer [ID] [INTERVAL] [REPS] [COMMAND]"); CurrentWindowMessage(connection, msg, 4, true); } } else { string msg = GetMessageFormat("User Error"); msg = msg.Replace("$message", "/timer [ID] [INTERVAL] [REPS] [COMMAND]"); CurrentWindowMessage(connection, msg, 4, true); } } break; case "/topic": if (connection != null) { if (data.Length == 0) { if (CurrentWindowType == IceTabPage.WindowType.Channel) SendData(connection, "TOPIC :" + CurrentWindow.TabCaption); } else { //check if a channel name was passed string word = ""; if (data.IndexOf(' ') > -1) word = data.Substring(0, data.IndexOf(' ')); else word = data; if (Array.IndexOf(connection.ServerSetting.ChannelTypes, word[0]) != -1) { IceTabPage t = GetWindow(connection, word, IceTabPage.WindowType.Channel); if (t != null) { if (data.IndexOf(' ') > -1) SendData(connection, "TOPIC " + t.TabCaption + " :" + data.Substring(data.IndexOf(' ') + 1)); else SendData(connection, "TOPIC :" + t.TabCaption); } } else { if (CurrentWindowType == IceTabPage.WindowType.Channel) SendData(connection, "TOPIC " + CurrentWindow.TabCaption + " :" + data); } } } break; case "/update": checkForUpdate(); break; case "/userinfo": if (connection != null && data.Length > 0) { FormUserInfo fui = new FormUserInfo(connection); //find the user fui.NickName(data); fui.ShowDialog(this); } break; case "/version": if (connection != null && data.Length > 0) { string msg = GetMessageFormat("Ctcp Send"); msg = msg.Replace("$nick", data); ; msg = msg.Replace("$ctcp", "VERSION"); CurrentWindowMessage(connection, msg, 7, true); SendData(connection, "PRIVMSG " + data + " VERSION"); } else SendData(connection, "VERSION"); break; case "/who": if (connection != null && data.Length > 0) SendData(connection, "WHO " + data); break; case "/whois": if (connection != null && data.Length > 0) SendData(connection, "WHOIS " + data); break; case "/aline": //for adding lines to @windows if (data.Length > 0 && data.IndexOf(" ") > -1) { string window = data.Substring(0, data.IndexOf(' ')); string msg = data.Substring(data.IndexOf(' ') + 1); if (GetWindow(null, window, IceTabPage.WindowType.Window) == null) AddWindow(null, window, IceTabPage.WindowType.Window); IceTabPage t = GetWindow(null, window, IceTabPage.WindowType.Window); if (t != null) t.TextWindow.AppendText(msg, 1); } break; case "/window": if (data.Length > 0) { if (data.StartsWith("@") && data.IndexOf(" ") == -1) { if (GetWindow(null, data, IceTabPage.WindowType.Window) == null) AddWindow(null, data, IceTabPage.WindowType.Window); } } break; case "/quote": case "/raw": if (connection != null && connection.IsConnected) connection.SendData(data); break; default: //parse the outgoing data if (connection != null) SendData(connection, command.Substring(1) + " " + data); break; } } else { //sends a message to the channel if (inputPanel.CurrentConnection != null) { if (inputPanel.CurrentConnection.IsConnected) { //check if the current window is a Channel/Query, etc if (CurrentWindowType == IceTabPage.WindowType.Channel) { SendData(connection, "PRIVMSG " + CurrentWindow.TabCaption + " :" + data); //check if we got kicked out of the channel or not, and the window is still open if (CurrentWindow.IsFullyJoined) { string msg = GetMessageFormat("Self Channel Message"); string nick = inputPanel.CurrentConnection.ServerSetting.NickName; msg = msg.Replace("$nick", nick).Replace("$channel", CurrentWindow.TabCaption); //assign $color to the nickname if (msg.Contains("$color")) { User u = CurrentWindow.GetNick(nick); for (int i = 0; i < u.Level.Length; i++) { if (u.Level[i]) { if (connection.ServerSetting.StatusModes[0][i] == 'v') msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelVoiceColor.ToString("00")); else if (connection.ServerSetting.StatusModes[0][i] == 'h') msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelHalfOpColor.ToString("00")); else if (connection.ServerSetting.StatusModes[0][i] == 'o') msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelOpColor.ToString("00")); else if (connection.ServerSetting.StatusModes[0][i] == 'a') msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelAdminColor.ToString("00")); else if (connection.ServerSetting.StatusModes[0][i] == 'q') msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelOwnerColor.ToString("00")); else msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelOwnerColor.ToString("00")); break; } } if (msg.Contains("$color")) msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelRegularColor.ToString("00")); } msg = msg.Replace("$status", CurrentWindow.GetNick(nick).ToString().Replace(nick, "")); msg = msg.Replace("$message", data); CurrentWindow.TextWindow.AppendText(msg, 1); CurrentWindow.LastMessageType = ServerMessageType.Message; } } else if (CurrentWindowType == IceTabPage.WindowType.Query) { SendData(connection, "PRIVMSG " + CurrentWindow.TabCaption + " :" + data); string msg = GetMessageFormat("Self Private Message"); msg = msg.Replace("$nick", inputPanel.CurrentConnection.ServerSetting.NickName).Replace("$message", data); CurrentWindow.TextWindow.AppendText(msg, 1); CurrentWindow.LastMessageType = ServerMessageType.Message; } else if (CurrentWindowType == IceTabPage.WindowType.DCCChat) { CurrentWindow.SendDCCData(data); string msg = GetMessageFormat("Self DCC Chat Message"); msg = msg.Replace("$nick", inputPanel.CurrentConnection.ServerSetting.NickName).Replace("$message", data); CurrentWindow.TextWindow.AppendText(msg, 1); } else if (CurrentWindowType == IceTabPage.WindowType.Console) { WindowMessage(connection, "Console", data, 4, true); } } else { WindowMessage(connection, "Console", "Error: Not Connected", 4, true); WindowMessage(connection, "Console", data, 4, true); } } else { if (CurrentWindowType == IceTabPage.WindowType.Window) CurrentWindow.TextWindow.AppendText(data, 1); else WindowMessage(null, "Console", data, 4, true); } } } catch (Exception e) { WriteErrorFile(connection, "ParseOutGoingCommand", e); } }
/// <summary> /// You have Parted/Left a Channel /// </summary> /// <param name="connection">Which Connection it came from</param> /// <param name="channel">Which Channel you parted</param> private void OnChannelPartSelf(IRCConnection connection, string channel) { string reason = ""; string msg = GetMessageFormat("Self Channel Part"); msg = msg.Replace("$nick", connection.ServerSetting.NickName).Replace("$channel", channel); msg = msg.Replace("$reason", reason); IceTabPage t = GetWindow(connection, channel, IceTabPage.WindowType.Channel); if (t != null) { t.IsFullyJoined = false; t.GotNamesList = false; t.GotWhoList = false; t.ClearNicks(); } PluginArgs args = new PluginArgs(mainTabControl.GetTabPage("Console").TextWindow, channel, connection.ServerSetting.NickName , "", msg); args.Connection = connection; foreach (IPluginIceChat ipc in loadedPlugins) { if (ipc.Enabled == true) args = ipc.ChannelPart(args); } mainTabControl.GetTabPage("Console").AddText(connection, args.Message, 1, false); if (t != null) RemoveWindow(connection, channel, IceTabPage.WindowType.Channel); }