Navigation

 + + + 

SleepyBot


SleepyBot - What's that?

SleepyBot is a PircBot implementation which uses Sleep as its scripting language. You do not need to write java code and compile it. You just have to write scripts in Sleep and run them with SleepyBot. All (or almost all?) things you can do with a PircBot can be done with SleepyBot and a bot-script. See Examples

Download: SleepyBot 1.1 (for Sleep 2.1)


Changes


Step by step to your first bot script

First your script needs a function called "init". The init function is the entry point of the script. It is called when the botscript has been parsed without exception into a runnable block. Here you set up the bot as you would do in the constructor of a PircBot. It should contain a call to connectServer(server [, port[, password]]) or a call to a function which contains a call to that function.

bot init {
  setName('MyFirstBot');
  # connects to irc.freenode.net using port 6667 and no password.
  connectServer('irc.freenode.net');
}

Next we do something if our bot has successfully connected to the server: we join a channel at this server. We do this in the "onConnect" function which is called when the bot is connected to the server.

bot init {
  setName('MyFirstBot');
  # connects to irc.freenode.net using port 6667 and no password.
  connectServer('irc.freenode.net');
}

bot onConnect {
  joinChannel('#MyChannel');
}

After joining the channel we want to do something uselful. Your bot tells us the actual time and date if a user typed "!time".

bot init {
  setName('MyFirstBot');
  # connects to irc.freenode.net using port 6667 and no password.
  connectServer('irc.freenode.net'); 
}

bot onConnect {
  joinChannel('#MyChannel');
}

# onMessage($1(channel),$2(sender),$3(login),$4(hostmask),$5(message))
bot onMessage {
  if ( $5 eq '!time') {
  	sendMessage( $1, [[new java.util.Date] toString]);
  }
}

Ok, provided you saved the bot script as "myfirst.bot", we can now run the bot:

  java -jar sleepybot.jar myfirst.bot
  (sleep.jar and pircbot.jar required)

or:

  java -jar sleepybot-all.jar myfirst.bot 


License

SleepyBot is published under the GNU General Public License (GPL)


Download: SleepyBot 1.0 runs with Sleep 2.0 only!


                                                                                                                                                                                                                           

ululatus.org     Valid XHTML 1.0!      Valid CSS!      Last modified 16 Oct 2008 17:32