// BitchSlapCommand.cs created with MonoDevelop // User: damien at 13:49 28/09/2007 // // To change standard headers go to Edit->Preferences->Coding->Standard Headers // using System; using System.IO; using System.Net; using System.Text.RegularExpressions; using DigitalNetworks.Irc.Bot.Common; namespace DigitalNetworks.Irc.Bot.Plugins { public class BashCommand : ICommand { public string Command { get { return "bash"; } } public string Name { get { return "Bash"; } } public bool Watcher { get { return false; } } public void Process(string line) { string param = Helper.GetParameters(line); int id; HttpWebRequest request; if (int.TryParse(param, out id)) { request = (HttpWebRequest)WebRequest.Create("http://bash.org/?" + id); } else { request = (HttpWebRequest)WebRequest.Create("http://bash.org/?random1"); } WebResponse response = request.GetResponse(); StreamReader sr = new StreamReader(response.GetResponseStream()); string quote = sr.ReadToEnd(); Match match = Regex.Match(quote, @"(?:

)(?.*)(?:

)", RegexOptions.Singleline); Console.WriteLine(match.Success); quote = match.Groups["quote"].Value; quote = quote.Replace("<", "<"); quote = quote.Replace("
", "\n"); quote = quote.Replace(">", ">"); quote = quote.Replace(""e;", "\""); IrcClient.PrivateMessage(quote); } public void ProcessWatch(string line) { } public string GetHelp() { return string.Empty; } } }