statbot is a simple irc bot which tracks all the joins and parts of users in an irc channel. From that data, charts can be generated which show the best day and hour to catch someone online.
The statbot core is nothing more than an instance of
EventEmitter. It periodically (at the request of various modules) emits one of three unique events, which the various modules subscribe to.
joinis emitted whenever a new user comes online. It has one paramater, the username of the newly joined user.
quitis emitted when a user leaves the channel. Like
join, it has one username parameter.
tickevent is statbot's heartbeat. It's emitted every 1 minute, and has no paramaters.
The actual bot logic is organized into a bunch of modules, found in
src/modules/ Each module has a single defined purpose. That way, the code is nice and clean, plus it's easier to test. Desired modules (listed in
src/statbot.coffee) are each loaded in order, and the function it exports is called, with the bot object and any config settings for that module as an argument. (Yes, this is very similar to the scheme used by hubot).
Server adapters (choose one)
These modules connect to a chat server, and tell statbot to emit the
quit events whenever the corresponding action happens in a chatroom.
irc_botconstructs an irc bot (using node-irc) which sits on an irc server in a list of specified channels.
statrabbithooks into elementary's RabbitBot. If you enable this, make sure to disable
ticker: this module causes statbot to emit the
tickevent as described above.
scribemaintains counters which track how many seconds every user has been online on every hour of every day.
usersmaintains a list of all the users statbot has seen, along with their status (online or offline).
prophetmakes predictions about the probability of a user being online at a given day and hour, using the data gathered by
apiruns a web server to generate online probability graphs using
Extra modules (optional)
loggerjust logs user activity to the console. Useful during debugging.
persistencewrites all counters to disk on every tick, and also restores the last counter dump at bot startup. Enable this if there's any chance whatsoever of the bot crashing. For best results, load after
shnatselimplements logging all actions to datafiles in the format supported by shnatsel's presence-log-parser. Coming soon!
git clone https://github.com/davidboy/statbot.git cd statbot make install
src/config.coffee in your favorite editor and configure to taste. Make sure you change the irc server and nickname.
All set! To run statbot, use either
make run or
For use with RabbitBot
cd /path/to/rabbitbot cd lib git clone https://github.com/davidboy/statbot.git cd statbot make install
src/config.coffee in your favorite editor, and...
- Change the datafile location as shown in the comments.
- Edit the modules array, replacing
- Delete the irc configuration block.
- Modify the rest of the settings to taste.
make compile cd ../..
app.js file, and add the following line:
That's all! Just run RabbitBot as usual, and everything will Just Work.