DanH42 / mi1kb0t

A multi-platform chat bot
MIT License
43 stars 17 forks source link

mi1kb0t

A multi-platform chat bot

Installation

I'd recommend setting up the bot as a service or running it in a screen/tmux session, but that specific implementation is up to you.

Working with Networks

When the bot is started, it will look in networks.js for a list of networks it should connect to. The arguments each network needs depend on the network itself. The only property required is type, which tells the bot which file in the networks/ directory to use for the connection. You can connect to multiple networks of the same type simply by adding multiple entries of that type. Each item in networks.js is indexed using a unique string of the user's choosing describing that connection. While currently unused, this could be used later to help facilitate cross-network features.

The included networks.js contains an example of a Messenger connection and also a connection to a ZNC IRC bouncer.

Creating Plugins

Plugins consist of a .js file placed in the plugins/ directory that defines a list of callback functions and parameters for when they should be called. The available callback types are:

All listeners except alls should specify a query to be matched against. The query provided should be in all lowercase. The callback will be provided with up to 4 arguments:

Every module should fit into a basic skeleton:

module.exports = {listeners: [/* list of objects */]};

In addition to listeners, you may also specify a callback function called apiReady that will be called once on startup as soon as a connection to a network has been made. This will be called once per network connection (NOT once per startup). The callback function will be passed a copy of the network API for each network connection.

For example, here's a basic module that responds to all messages starting with "Hello":

module.exports = {listeners: [
{   
    type: "startsWith",
    query: "hello",
    callback: function(reply, message){
        reply("Hello, " + message.sender_name + "!");
    }
}
]};

Adding Networks

To add your own custom network support, just add a new .js file in the networks/ directory. The file should export an object with a connect function that will be called on startup. The function will be supplied with 3 arguments:

This project is an eternal work-in-progress. Questions/issues/PRs welcome.