[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qexo-general] IRC Bot in Qexo
From: |
Terje Pedersen |
Subject: |
[Qexo-general] IRC Bot in Qexo |
Date: |
Sat, 2 Aug 2003 20:52:16 +0200 |
User-agent: |
KMail/1.5.1 |
I have used the PircBot Java API package found
at http://www.jibble.org/pircbot.php to make myself an IRC Bot in Qexo.
Since its not possible to extend the PircBot class from Qexo I think, you
can't make the complete bot in Qexo but the main class could be made. Here is
an example of a Qexo bot which is using a bot.xml configuration file.
qexobot.xql
declare namespace bot = "class:Qexobot"
let $bot := bot:new()
let $config := doc("bot.xml")/bot
return (
bot:setVerbose($bot,true()),
bot:connect($bot,string($config/server/text())),
if ($config/name) then (bot:changeNick($bot,string($config/name/text())))
else (),
for $c in $config/channel
return bot:joinChannel($bot,string($c/text()))
)
bot.xml:
<bot>
<name>qexobot</name>
<server>irc.someserver.no</server>
<channel>#senikk</channel>
<!-- <channel>#stangaland</channel> -->
</bot>
Qexobot.java:
import org.jibble.pircbot.*;
import gnu.xquery.lang.XQuery;
import java.io.FileReader;
public class Qexobot extends PircBot
{
public Qexobot()
{
this.setName("helper");
}
public void onMessage(String channel, String sender, String login, String
hostname, String message)
{
if (message.equalsIgnoreCase("time"))
{
String time = new java.util.Date().toString();
sendMessage(channel,sender + ": The time is now " + time);
}
else if (message.equalsIgnoreCase("qexo"))
{
XQuery xq = new XQuery();
String send = null;
try {
Object result = xq.eval(new FileReader("test.xql"));
send = result.toString();
}
catch(Throwable identifier) {}
sendMessage(channel,sender + ": " + send);
}
}
}
The last bit of code is just there to test the possibility delivering the
answer from running the test.xql
What I want to do now I think is to make some sort of bot module support for
calling modules written in Qexo, which would make it possible to change the
modules while the bot is still running and it would be easy delivering xml
based content.
And it should also easily be possible to make some sort of Qexo test bot like
you have the Sandbox (http://www.cocoonhive.org/xquery/xqueryform.html) for
the web and "java kawa.repl --xquery" for the command line.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qexo-general] IRC Bot in Qexo,
Terje Pedersen <=