Based on the original OCTOTROG bot written in Perl by shmup: https://github.com/shmup/octotrog
The Perl version wasn't terribly maintainable, so I rewrote it using Node and the nodeirc library, which is much more flexible.
The bot's main function is to send commands from an IRC channel to a pantheon of infobots on another server, and relay the response back.
- Node
- SQLite 3 dev headers (Debian/Ubuntu package
libsqlite3-dev
)
- Edit
octotrog.js
and setserver
andmain_channel
- Run
sqlite3 db/save.db < db/schema.sql
to initialize the database npm install
npm start
This is my first attempt at an IRC bot, please bear with me. I've documented the main functionality here.
See octotrog.js
for an example of instantiating a bot and loading plugins.
bot_options
are in flux and not yet documented.
Currently the bot only looks in the plugins
subdirectory for plugin scripts.
options
is passed to the plugin's initializer.
Core plugin functionality. An attempt (not entirely successful) has been made
to allow plugins to function without directly accessing the ircbot
object.
Therefore, all communication with ircbot
is handled through the core plugin.
The ircbot
instance.
Prints debug info to the Node console log, if bot.debug
is set to true
.
Prints an error to the Node console log, with timestamp.
Bind one or more IRC channels to the plugin. The plugin will then receive
messages from this channel. The say
methods will message these channels as
well.
The core of plugin communication. Used by a plugin to emit an event to itself. The first parameter sent to the event is a function that can be used to (optionally) resolve the event's promise.
Returns a promise for the event.
Calls plugin.emitP
on every plugin that is registered, in the order they were
registered.
Returns a promise that resolves when any plugin's event handler resolves the promise. (This is currently a weakness of the plugin event system.)
Sends a message to each channel the plugin is bound to. An arbitrary number of
sprintf
-style arguments are allowed.
Same as plugin.say
, except a stock bot phrase is used.
Utility function to wrap a string in an IRC color.
These should be defined in your plugin file.
The plugin's name. Currently this is only used for logging.
Called when the plugin is loaded.
Called when the plugin is unloaded. Custom event listeners that weren't bound to the plugin directly should be destroyed here.
The prefix for this plugin's commands. This is to make it easy to change without modifying all of the commands.
The main way to implement IRC commands. This is a hash of commands and command handlers. The following options are implemented:
no_space : boolean
Allow the command to be matched with no space between the command and its parameters.
Defaults to false
(space is required).
description : string
A description of the command. Used by the default !help
command.
response : function(info : object)
The responder function that is called when this command is received. The
info
object contains the following data:
bot : ircbot
- Theircbot
instance.command : string
- The command that was parsed.from : string
- The nick/channel the IRC message arrived from.handler : object
- The command handler.privmsg : boolean
- Was this a PRIVMSG to the bot?text : string
- The full text of the message.to : string
- The nick/channel the IRC message was sent to.message : object
- Themessage
object received fromnode-irc
.msg : string
- The message minus the parsed command.params : array<string>
- This ismsg
split into an array, by spaces.reply : function(text : string)
- A function that can be used to reply to the message.reply_phrase : function(phrase : string, [...params])
- A function that can be used to reply to the message using a bot phrase.
Hash of event names and listeners. These are bound to the plugin on load. Currently you can't bind more than one listener to an event.
Event listeners are called with a resolver function as the first argument, which can be used to resolve the event's promise.
- Main plugin
- Crawl/database plugins
- Phrases
- Transformer
- Expect queue
- Rethink plugin-channel binding
- Rethink event promises
- Find better solution for expect queue
- Separate ircbot repository from Crawl plugin