Chat Essentials Home

Chat Essentials Forum
 

Home Online Manual GlassBot(R) User Guide Building a GlassBot(R) Build a GlassBot(R) using JDK

In this method we only need Java Development Kit to compile a GlassBot(R). The method consist of  3 steps:

  1. Writing your GlassBot(R)

  2. Executing the javac command

  3. Executing the GlassBot(R)

1. Writing your GlassBot(R)

Make a folder with name "glassbottest" and create TestBot.java in this folder with the below content :

--------------------
package glassbottest;

import com.chatessentials.GlassBot.GlassBot;
import com.chatessentials.GlassRoom.*;
import java.net.URL;

public class TestBot extends GlassBot
{
public void onPrivateMessage (UserMinor sender, String message, URL url)
{
this.sendPrivateMessage(sender.nick + ", you said : " + message, sender.nick);
}

public static void main (String args[])
{
main(new TestBot(), args);
}
}
--------------------

Then, copy GlassBot.jar from "classes" subfolder in the installation folder of GlassRoom to current folder.

2. Executing the javac command

Now, you can compile the bot. Run the below command in your command shell :

javac -classpath GlassBot.jar glassbottest/TestBot.java

Note : If "javac" is not in your path type the complete path of it in the above command. "javac" is located in bin subfolder of JDK installation directory.

3. Executing the GlassBot(R)
First, run the chat server and make sure that it comes up successfully. You have two methods to run your GlassBot(R):
A) You can run it by main() method. In this case enter the below command in your command shell :

java -classpath .;GlassBot.jar glassbottest.testBot 127.0.0.1 -n robo_test

If there is no problem, this message will be appeared : "Bot is initiated."
And you can test the functionality of your Bot by launching a browser and opening the chat page and sending a message to the robo_test user.

B) You can embed this class in your chat server. Copy the glassbottest folder into "classes" subfolder of your chat server in the installation folder.
Use GlassRoom's control panel to add this Bot to system. Note that you must set glassbottest.TestBot as your "class file" don't use "robots." prefix because you didn't use robots directory (package) in this example.
 

Note: The specifications here are related to Borland JBuilder(TM)