public Results ProcessCommand(string command) { Results r = new Results (); Console.WriteLine ("Session.ProcessComman ({0})", command); r.Message = "Your command was not handled by any command object installed on this system!"; return r; }
public override Results Execute(string[] parameters) { // http://duckduckgo.com/api.html string duckduckgo = "http://api.duckduckgo.com/?q={0}&format=json&pretty=1"; string google = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q={0}"; string searchurl = google; string encoded = System.Web.HttpUtility.HtmlEncode (parameters[0].Substring (1)); this.url = string.Format (searchurl, encoded.Replace(" ", "+")); WebRequest request = WebRequest.Create (url); HttpWebResponse response = (HttpWebResponse)request.GetResponse (); this.status = response.StatusDescription; Stream dataStream = response.GetResponseStream (); TextReader reader = new StreamReader (dataStream); string buf = reader.ReadToEnd (); reader.Close (); dataStream.Close (); response.Close (); this.response = buf; Results r = new Results (); r.Message = buf; return r; }