Respond to inworld chat
From libopenmetaverse - libomv - Developer Wiki
Contents |
Prerequisites
The following prerequisites are required in order for you to create your first bot by following this tutorial.
Real World
- This tutorial assumes that you were able to successfully build libsecondlife! If you have not compiled libsl, please follow the instructions on the Getting Started wikipage.
- Also, if you have no experience with the C# (c-sharp) programming language, I highly recommend that you stop now and please follow the list of links to csharp tutorials located here.
- A libsl bot that is able to login successfully. If you don't know how to create a libsl bot, please go to the "How to create a basic libSL bot" wikipage
The Code
Note: We are assuming that our main "GridClient" instance variable is named "Client." If you have a different name for this variable, please substitute the name accordingly
Client.Self.ChatFromSimulator += new EventHandler<ChatEventArgs>(Self_ChatFromSimulator); static void Self_ChatFromSimulator(object sender, ChatEventArgs e) { //process chat here! exaple: client.Self.Chat(e.Message, 0, ChatType.Normal); }
Parameters for ChatEventArgs:
- Message (string) What was said
- AudibleLevel (ChatAudibleLevel) Ranging from Barely, Fully, and Not.
- Type (ChatType) How it was said (see this page on monodoc for the list of ChatTypes)
- SourceType (ChatSourceType) What kind of thing said it (System, Object, or Avatar)
- FromName (string) Whats the name of the person/object that said it
- SourceID (UUID) Whats the key of the person/object that said it
- OwnerID (UUID) If it was an object, who owns it?
- Position (Vector3) Where is the person/object that said it
- Simulator (Simulator) What simulator it came from
Notes
- ChatType.Normal = Saying (20m range).. Do NOT use ChatType.Say, it is an obsolete version and will likely be removed in the near future.
- Try to check to see if the chattype is not "StartTyping" or "StoppTyping" before you process the text.. otherwise you get blank messages