/// <summary> /// Get the ELIZA bot client to send and receive messages from. Gets the default bot in the system if not parameters specified. /// /// </summary> /// <param name="scriptName">Optionally retrieve a bot that's available in the system by its name.</param> /// <param name="jsonScriptContent">Optional JSON script for a bot not in the system.</param> /// <returns></returns> public ELIZALib GetElizabothClient(string scriptName = null, string jsonScriptContent = null) { ELIZALib el = null; if (scriptName != null) { if (!GetAvailableScripts().ContainsKey(scriptName)) { throw new InvalidDataException("No such script with the name."); } el = new ELIZALib(GetAvailableScripts()[scriptName]); } if (el == null && jsonScriptContent != null) { try { el = new ELIZALib(jsonScriptContent); } catch (JsonReaderException) { throw new InvalidDataException("Invalid script."); } } if (el == null) { el = new ELIZALib(GetAvailableScripts().First().Value); } return(el); }
// Load ELIZA script file and instantiate our libraries. --Kris public ELIZA() { string json = null; using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("DOCTOR.json")) { using (StreamReader streamReader = new StreamReader(stream)) { json = streamReader.ReadToEnd(); } } Eliza = new ELIZALib(json); Reddit = new RedditAPI("YourAppID", "YourRefreshToken"); ActiveSessions = new Dictionary <string, DateTime>(); }
public Workflow(string[] args) { string json = null; using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ELIZA.DOCTOR.json")) { using (StreamReader streamReader = new StreamReader(stream)) { json = streamReader.ReadToEnd(); } } string appId = args[0]; string refreshToken = args[1]; string accessToken = (args.Length > 2 ? args[2] : null); // Initialize the API library instance. --Kris Eliza = new ELIZALib(json); Reddit = new RedditClient(appId: appId, refreshToken: refreshToken, accessToken: accessToken); ActiveSessions = new Dictionary <string, DateTime>(); }
/// <summary> /// An example ELIZA wrapper class. /// </summary> /// <param name="scriptFile">The path to the JSON file containing the ELIZA script.</param> public ELIZAWrapper(string scriptFile) { eliza = new ELIZALib(File.ReadAllText(scriptFile)); }
/// <summary> /// Get the response to the query from the bot. /// /// </summary> /// <param name="client">The specfied bot client.</param> /// <param name="query">The query to send the bot.</param> /// <returns></returns> public string GetResponse(ELIZALib client, string query) { return(client.GetResponse(query)); }
/// <summary> /// Get the closing line from the bot. /// </summary> /// <param name="client">The specfied bot client.</param> /// <returns></returns> public string GetGoodbye(ELIZALib client) { return(client.Session.GetGoodbye()); }
/// <summary> /// Get the introductory line from the bot. /// /// </summary> /// <param name="client">The specfied bot client.</param> /// <returns></returns> public string GetGreeting(ELIZALib client) { return(client.Session.GetGreeting()); }