There was some head scratching because the chat example on the Open Metaverse page (http://lib.openmetaverse.org/wiki/Respond_to_inworld_chat) seems to be out of date - the LL prefix from LLUUID and LLVector3 seem to have been dropped. The AIMLBot also doesn't come with the xml and aiml files needed, but I just took those from Radegast.
As it stands the chat call back is fired whenever anyone starts typing nearby, and when it hears itself. My slap-dash solution is included below:
static void Self_OnChat(string message, ChatAudibleLevel audible,
ChatType type, ChatSourceType sourceType, string fromName,
UUID id, UUID ownerid, Vector3 position)
{
if (message != "")
{
if (fromName != "Test Bot")
{
//process chat here
AIMLbot.Request request = new AIMLbot.Request(message,
myUser, myBot);
AIMLbot.Result reply = myBot.Chat(request);
Client.Self.Chat(reply.Output, 0, ChatType.Normal);
Console.WriteLine(reply.Output);
}
}
}
That's the main component of the chat bot, so you can see that it is very easy to implement.
2 comments:
Hi Lucius,
I found your post on implementing AIML yesterday, and I'm totally intrigued. I would like to get my own AIMLbot working, but I'm having a heck of a time figuring out hwy C# doesn't like your code. I have been using this tutorial: http://hookerbots.com/tutorials/build-a-bot/ and have implmented your code for the 'void Self_OnChat' code in the tutorial. I got the tutorial bot working just fine, I have downloaded the AIMLbot.dll, along with the Radegast AIML_config files and AIML files, placed them in the same folder with the .dll and referenced the .dll in my C# environment. However, i am receiving the following errors:
Error 3: The best overloaded method match for 'AIMLbot.Request.Request(string, AIMLbot.User, AIMLbot.Bot)' has some invalid arguments
Error 4: Argument '3': cannot convert from 'MyBotProgram03.Bot' to 'AIMLbot.Bot'
Error 5: 'MyBotProgram03.Bot' does not contain a definition for 'Chat' and no extension method 'Chat' accepting a first argument of type 'MyBotProgram03.Bot' could be found (are you missing a using directive or an assembly reference?)
The AIMLbot is both referenced and included via:
using AIMLbot;
I have reached out to my developer communities about this and they have been no help so far, so I thought I'd try pinging you about my problem. I've pasted my code here: http://pastebin.com/8vK02Qv6
...in case you're willing to help a n000b out.
Cheers,
~Chipley Chippewa
Hi Chipley,
'myBot' needs to be an AIMLbot object. It might be AIMLbot.bot, as suggested in Error 4, but I can't remember off-hand. I'll try to pull out the source code that I used and check.
Try changing:
static Bot myBot;
to:
static AIMLbot.bot myBot;
Post a Comment