www.ululatus.org Open in urlscan Pro
85.13.133.179  Public Scan

URL: http://www.ululatus.org/sleepybot/
Submission: On August 01 via api from NL — Scanned from NL

Form analysis 0 forms found in the DOM

Text Content

ululatus.org



Navigation

 * Home
 * Shuteye
 * SleepyBot .
   * Examples
   * Functions
   * Events
   * Variables
   * Predicates
 * Sleep/jIRCii
 * Contact
 * Links

 + + + 



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)


 * sleepybot.jar (Size: 112K) Contains SleepyBot classes only, requires
   pircbot.jar(1.4.6) and sleep.jar(2.1u3).
 * sleepybot-all.jar (Size: 438K) Contains SleepyBot, PircBot(1.4.6) and
   Sleep(2.1u3) classes.
 * sleepybot-src.zip (Size: 324K) Contains the SleepyBot source files, an ant
   build script and sleep.jar(2.1u3) and pircbot.jar(1.4.6).


Changes


 * added "identify" function that is new in PircBot 1.4.6
 * fixed a typo in the onPing method (it checked for &onVersion instead for
   &onPing)
 * introduced the "bot" environment: the event handling functions and the init
   function of the bot script are no longer added as functions to Sleep's
   environment. They are passed directly to the ScriptedBot class. See the
   example on this page and the examples on the examples page. You may run your
   existing bot scripts without changes with "-Dsleepybot.mode=old-fashioned"
   but it is recommended to change to the new style.


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!


 * sleepybot-1.0.jar (Size: 80K) Contains SleepyBot 1.0 classes only, requires
   pircbot.jar and sleep.jar.
 * sleepybot-1.0-all.jar (Size: 297K) Contains SleepyBot 1.0, PircBot(1.4.4) and
   Sleep(2.0) classes.
 * sleepybot-1.0-src.zip (Size: 256K) Contains the SleepyBot 1.0 source files,
   an ant build script and sleep.jar(2.0) and pircbot.jar(1.4.4).
 * sleepybot-1.0-examples.zip (Size: 2.7K) Contains the SleepyBot 1.0 examples


                                                                               
                                                                               
                                                           

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