// Callback function that's triggered whenever one or more new messages come in. --Kris private void C_UnreadMessagesUpdated(object sender, MessagesUpdateEventArgs e) { if (e.NewMessages.Count > 0) { // Mark all messages as read now so they don't come up multiple times. --Kris Reddit.Account.Messages.MarkAllRead(); foreach (Message message in e.NewMessages) { // If author has an active session, reply to the content. Otherwise, respond with greeting. --Kris string response; if (!ActiveSessions.ContainsKey(message.Author)) { ActiveSessions.Add(message.Author, DateTime.Now); response = Eliza.Session.GetGreeting(); // These greetings are really generic so feel free to replace this with your own custom greeting string. --Kris } else { if (message.Body.Contains("bye", StringComparison.OrdinalIgnoreCase) || message.Body.Contains("farewell", StringComparison.OrdinalIgnoreCase) || message.Body.Equals("exit", StringComparison.OrdinalIgnoreCase) || message.Body.Equals("quit", StringComparison.OrdinalIgnoreCase)) { ActiveSessions.Remove(message.Author); } response = Eliza.GetResponse(message.Body); } // Send the Reddit response. --Kris Reddit.Account.Messages.Compose(message.Author, message.Subject, response); } } }
public string Query(string q) { return(eliza.GetResponse(q)); }
/// <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)); }