This is the core functionality of the OCTOTROG IRC bot, with a somewhat friendlier API.
The core is event-driven. Plugin modules are able to pass data to each other asynchronously. There is also an "easy" API especially for IRC events.
Nothing special. Some dependencies are for specific plugins and can be skipped:
- SQLite3 (
database
plugin) -- You need the sqlite3 dev headers installed. On Debian/Ubuntu this is packagelibsqlite3-dev
.
In your bootstrap file you can start the bot and load plugins. See example.js
for same.
Assuming your script runs start()
, you can use these command line parameters:
start
: Starts the Octobot daemon.stop
: Stops the Octobot daemon.restart
: You get the picture.
With no parameters, the bot will run normally in the foreground instead of daemonizing.
This documentation is incomplete/missing. More soon, I promise.
TODO: Document plugin events, plugin methods, evt
Prepare an Octobot instance. This is actually an event queue that starts the real bot if necessary. Passing a config
here is equivalent to Octobot.config(config)
.
Sets core bot configuration options. Currently there are no such options!
Loads a plugin with associated options. Plugin modules should be located in a plugins
directory relative to the module that loaded the bot. Relative paths beginning with '.' and absolute paths are also allowed. If no matching plugin is found in any of these places or in the Octobot core plugins, the plugin module will be loaded as if it was require
'd from the startup script.
The following plugins come "included":
irc
main
logger
database
dictionary
A plugin module should export a plain object with these properties. Any extra properties will be added as mixins to the plugin instance when it's created.
name
(string): Plugin name.defaults
(object): Default settings.init
(function): Called after plugin is instantiated and config and event listeners are initialized.destroy
(function): Called on plugin unload, at least in theory, because plugins can't unload yet.listeners
(object): A hash of{ event: listener(evt) }
. Theevt
object enables asynchronous communication between plugins by resolving the event's promise usingevt.resolve()
.prefix
(string): The prefix for IRC commands (e.g. "!"). A shortcut that makes it easier to put IRC commands in a particular prefixed namespace.commands
(object): IRC commands as a hash of{ command: command_options }
wherecommand_options
has the following properties:no_space
(string): Allow the command to run without a space between the command and any parameters?description
(string): Used by the!help
command and also serves as convenient documentation.response
(function): Called with parameters(evt, msg)
whereevt
is the initial event object andmsg
is anode-irc
message object augmented with:reply
(function): Reply directly to the triggering message (either via PRIVMSG or to a channel). Can be used multiple times.replyto
(string): The nick that sent the message (if PRIVMSG) or channel (if not).from
(string): Nick the message came from.to
(string): Where the message was directed (nick or channel).privmsg
(boolean): Was this a PRIVMSG?msg
(string): The text of the IRC message, minus the command itself.text
(string): Full text of the message.params
(array[string]):msg
split by word, for convenience.raw
(object): Thenode-irc
raw message object. See: https://node-irc.readthedocs.org/en/latest/API.html#'raw'