______ __ ____ __ / ____/___ _/ /_/ __ )____ / /_ / /_ / __ `/ __/ __ / __ \/ __/ / __/ / /_/ / /_/ /_/ / /_/ / /_ /_/ \__,_/\__/_____/\____/\__/
FatBot is an easy to use and extensible ES6 IRC bot framework.
Note: You are reading the documentation of the ES6 version (v1.x). If you are looking for the v0.3 documentation (
coffeescript
) please refer to the 0.3 branch.
Quick start
Install fatbot via npm
> npm install fatbot
bot.js
Create a file let bot = server: 'freenode' nick: 'fatbot' channels: '#fatbot' '#skinnybot' botDebug: false // Listen to Bot events bot // Listening discussion bot // Connect the bot bot
Launch the bot
> fatbot bot.js
In this example, you are :
- Connecting
mybot
to a built-in server shortcut calledfreenode
and join a channel called#fatbot
- Perform action on events with
Fatbot::on
- Launching the bot with
Fatbot::connnect
method
Note: Since your bot will be launched with babel-node you can write your bot in ES6
Organize your Bot
For large bot projects, you may want to split your functionalities into different files.
You can use Bot::on
with an object literal
bot
// ./lib/hello.js { r} const ontalk = event: 'user:talk' trigger: callback const onprivate = event: 'user:private' trigger: callback
// ./bot.js //... bot bot
Extending the Bot
You can extend the prototype of the Bot
class. For example, the method Bot::hear
is a built-in extension:
Botprototype { this}
Events
You can easily add behaviors to the bot by listening to events :
bot
r
is the Response object.
These are the events thrown by the bot.
Event name | Description | Response |
---|---|---|
client:error |
Error sent by the client | err (isnt Response object) |
self:connected |
Bot is connected to server | server |
self:talk |
Bot is talking | nick, text, client, reply(txt) |
self:join |
Bot is joining a channel | channel, nick, text, client |
user:talk |
User is talking in channel | nick, channel, text, client, reply(txt) |
user:private |
User send pm to the bot | nick, text, client |
user:join |
User join a channel | channel, nick, text, client, reply(txt) |
Change log
2014-10-19 v-1.0.0*
- Rewrite the project into ES6. Nothing has changed in the API
2013-03-17 v0.3.3
- Fix CB when using coffee-script v.1.6.x compiler
2012-12-26 v0.3.2
- You can now add event listeners with objects literal
- You can now add event listeners bundled in arrays
- README.md upadated with new examples
2012-12-26 v0.3.1
- Bot completely rewritten (again)
- Temporary removing sugars in favor of prototype extensions
- Refinery lost in translation ;)
- Simpler code to do such simple things
2012-12-24 v0.2.0
- Bot completely rewritten in coffeescript on top of node and node-irc
- Fatbot is now a standalone framework
- Plugins are now called sugars
- Added sugars factories called refinery helpers
- Merge of node branch into master
- Fist beta working version of the coffeescript version