I am making a C# program that talks to people using AIML, it is using networking so it can talk to multiple people at once.
Here is my get message handler:
private void MessageRecieved(UserMessage message)
{
if (message.getMessageType() == Enumerations.UserMessageType.incomming_text_message)
{
conversationHTML += online[message.getUsername()].FriendlyName + " says: "
+ "<font color=\"Gray\">" + message.getUserPayload() + "</font><br />";
string recvMsg = message.getUserPayload();
string send = getReply(recvMsg);
switchboard.sendMessage(new UserOutgoingMessage("Times New Roman", send));
conversationFrame.DocumentText = conversationHTML;
//}));
}
}
My getReply function which calls the AIML:
private string getReply(string msg)
{
try
{
return bot.getOutput(msg);
}
catch(Exception e)
{
MessageBox.Show(e.ToString() + Environment.NewLine + msg);
return null;
}
}
Now here is my AIML class: I did not program it but I found it. It works well by itself, but for some reason its not working here and I can't pinpoint it.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AIMLbot;
namespace Chatbot
{
class alice
{
private Bot myBot;
private User myUser;
/// <summary>
/// Create a new instance of the ALICE object
/// </summary>
public alice()
{
myBot = new Bot();
myUser = new User("consoleUser", myBot);
}
/// <summary>
/// This initialization can be put in the alice() method
/// but I kept it seperate due to the nature of my program.
/// This method loads all the AIML files located in the \AIML folder
/// </summary>
public void Initialize()
{
myBot.loadSettings();
myBot.isAcceptingUserInput = false;
myBot.loadAIMLFromFiles();
myBot.isAcceptingUserInput = true;
}
/// <summary>
/// This method takes an input string, then finds a response using the the AIMLbot library and returns it
/// </summary>
/// <param name="input">Input Text</param>
/// <returns>Response</returns>
public String getOutput(String input)
{
Request r = new Request(input, myUser, myBot);
Result res = myBot.Chat(r);
return (res.Output);
}
}
}
Here is the error I keep getting: (I typed it out and skipped unimportant things)
System.FormatException ...
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at
System.Number.Parse...
at
System.Double.Parse...
at
System.Convert.ToDouble
at
AIMLbot.Bot.get_TimeOut()
at
AIMLbot.Utils.Node.Evaluate
at
AimlBot.Bot.Chat(request request)
at CHatbot.alice.getOutput(String input) in blabla/Chatbox.cs:line 44 at blabla.GetReply(String msg) in blabla line 102
^ The above is my getReply function at this line: return bot.getOutput(msg);
Msg: hi
I can't seem to find out whats wrong. I was going to make a communication client between another program using pipes to send data, but that would be unnecessary imo