How does a bot read the chat window?
How does a bot read the chat window?
There are several methods for sending text to the chat, but I haven't found any that can read the chat.
This is done via the message() method in the LuxAgent interface, which is called in various circumstances (someone said something in the chat, or you just got attacked, or you just got eliminated). To read the chat do something like this:
Code: Select all
String message(String type, Object data) {
if(!type.equals("chat")) return null;
java.util.List lData = (java.util.List)data; //in this case data is a List object
//not java.awt.List though!
//the contents of the list are the sender and the message
String sender = (String)lData.get(0);
String message = (String)lData.get(1);
if(sender.equals("SunTzu")) board.sendChat("Yes, sir!");
if(message.contains(name())) board.sendChat("That's me!!");
return null;
}
- blackj3sus
- Lux Messiah
- Posts: 3223
- Joined: Fri May 05, 2006 12:27 pm
- Location: sillysoft.net/roman-battles
- Contact:
Who is online
Users browsing this forum: No registered users and 147 guests