A scriptable, configuration powered IRC bot that can handle as many connnections as you want.
- Installing
- Configuring
- API
- Extending Mouse with plugins
- Contributing
- License
Mouse is built on Go, and uses GB to vendor code. You should always be using the most recent version of both.
gb build all
This option is currently not available, but will be once Mouse hits version 1.0.0
, and for each release after that.
Your configuration file can exist at any of the following locations:
/etc/mouse/
$HOME/.mouse/
./
The name of your configuration file should always be mouse
, but the file extension depends on the configuration type that you use.
Mouse uses the Viper library, which allows a variety of configuration types. Your configuration file must be named appropriately and should be one of the following:
mouse.toml
mouse.json
mouse.hcl
mouse.yaml
mouse.properties
Keep in mind that a configuration file named mouse.toml
MUST be a TOML file, and the same goes for every other supported configuration file type.
You can choose to configure Mouse with TOML. Configure your servers like this:
[servers]
[server.a]
nick = "mouse"
# ...
[servers.a.plugins.javascript]
enabled = true
# ...
[server.b]
nick = "mouse"
# ...
You can see a full example at contrib/config-examples/config.toml.
You can choose to configure Mouse with JSON. Configure your servers like this:
{
"servers": {
"a": {
"nick": "mouse",
"plugins": {
"javascript": {
"enabled": true
}
}
},
"b": {
"nick": "mouse"
}
}
}
You can see a full example at contrib/config-examples/config.json.
You can choose to configure Mouse with HCL. Configure your servers like this:
servers "a" {
nick = "mouse"
# ...
plugins "javascript" {
enabled = true
# ...
}
}
servers "b" {
nick = "mouse"
# ...
}
You can see a full example at contrib/config-examples/config.hcl.
You can choose to configure Mouse with YAML. Configure your servers like this:
servers:
a:
nick: mouse
# ...
plugins:
javascript:
enabled: true
# ...
b:
nick: mouse
# ...
You can see a full example at contrib/config-examples/config.yaml.
You can choose to configure Mouse with Java Properties.
servers.a.nick = "mouse"
# ...
servers.a.plugins.javascript.enabled = true
# ...
servers.b.nick = "mouse"
# ...
You can see a full example at contrib/config-examples/config.properties.
All of the following configuration options should be nested in a server block. See above to find a full example of the configuration file type that you're using.
Nick is a string and the name that the bot will use once connected to the IRC server.
nick = "mouse"
User is a string and contains the username of the user.
user = "mouse"
Name is a string and the real name of the bot.
name = "mouse"
Host is a string that specifies what server to connect to. This should not include the port.
host = "irc.fc00.io"
Port is an integer that specifies the port on the IRC server to connect to.
port = 6667
Currently does nothing.
tls = false
Reconnect is a boolean that when true
will try to reconnect to the server if disconnected from.
reconnect = true
Ping is an integer that is the number of seconds we should ping the server for a health check.
ping = 30
Debug is a boolean that prints every IRC event for all connected servers to STDOUT.
debug = false
Channels is an array of strings that represent channels to join once connected to the IRC server. If the channel contains a password, it should be placed after the channel name with a space in between like #c
is in the example below.
channels = [ "#a", "#b", "#c password" ]
All of the following configuration options should be nested in a plugins block named for the plugin language to be configured. See below for more information on plugins.
Enabled is a boolean that enables and disables plugin support for the specific plugin language.
enabled = true
Folders is an array of strings that contains a directory path for plugin files. This does not include a pattern, as the pattern attribute below decides what the pattern is for plugin files. A good use of multiple folders that contain scripts could be certain scripts that only one bot should access, and some scripts that all bots should access.
folders = [ "/home/username/.mouse/scripts/language/" ]
Pattern is a string that contains the pattern for plugin files. This does not include the folder, as the folder attribute above decides where to look for the pattern.
pattern = "*.js"
Events is an array of strings that contain official IRC event types that the plugins should run on.
events = [ "PRIVMSG" ]
Storage is a string that contains the type of storage engine that should be used. Information of which storage enginges, along with how to find an example of a DSN, are available are below:
storage = "sqlite3"
sqlite3
Mouse uses the mattn/go-sqlite3 package for handling SQLite connections. You can find examples of DSN strings there.
mysql
Mouse uses the go-sql-driver/mysql package for handling MySQL connections. You can find examples of DSN strings there.
postgres
Mouse uses the lib/pq package for handling Postgres connections. You can find examples of DSN strings there.
mssql
Mouse uses the denisenkom/go-mssqldb package for handling MsSQL connections. You can find examples of DSN strings there.
All of the following configuration options should be nested in a store block named for the storage engine to be configured.
DSN is a string that contains the data source name that should be used to connect to this specific storage engine.
dsn = "mouse.db"
See the API on GoDoc for the most up to date documentation.
Using the embeddable JavaScript interpreter Otto, we can write plugins that deeply integrate with Mouse.
Coming soon.
The join
function allows your bot to join a new channel. You may also specify a password if the channel has a password set, but that's not required. If there is a password, append it to the channel parameter with a space in between.
/**
* @param string channel
*/
function join(channel)
The part
function allows your bot to part a channel.
/**
* @param string channel
*/
function part(channel)
The cycle
function allows your bot to cycle on a channel. This will leave the channel, and then re-join it.
/**
* @param string channel
*/
function cycle(channel)
The say
function allows your bot to send messages to any buffer that will allow it. When sending to a channel, the channel name must be prefixed with #
, and when sending to a user, it should not be.
/**
* @param string buffer
* @param string message
*/
function say(buffer, message)
The kick
function allows your bot to kick users out of a channel. You may also specify a reason, but that's not required.
/**
* @param string channel
* @param string user
* @param string reason
*/
function kick(channel, user, reason)
The ban
function allows your bot to ban users in a channel. You may also specify a reason, but that's not required.
/**
* @param string channel
* @param string user
* @param string reason
*/
function ban(channel, user, reason)
The unban
function allows your bot to unban users in a channel.
/**
* @param string channel
* @param string user
*/
function unban(channel, user)
The op
function allows your bot to change the mode of a user to +o
in a channel.
/**
* @param string channel
* @param string user
*/
function op(channel, user)
The deop
function allows your bot to change the mode of a user to -o
in a channel.
/**
* @param string channel
* @param string user
*/
function deop(channel, user)
There are variables set at the global scope that can be used in all plugins.
On each event that the plugins are listening for, a new event is populated that is passed in to an event
object in the global scope.
Command is a string that contains the command that triggered this event. The most frequently used command in Mouse plugins is probably "PRIVMSG"
.
event.command
Channel is a string that contains the channel where the event took place. Channel is not just for channels, but also for private messages. If it is a channel, it will be prefixed with #
.
event.channel
Message is a string that contains the message of the event.
event.message
Host is a string that contains the host of the user that triggered this event.
event.host
Nick is a string that contains the nick of the user that triggered this event.
event.nick
User is a string that contains the user of the user that triggered this event.
event.user
The storage
object at the global scope cotains key functionality for using a database with plugins.
The storage.put
function allows your bot to save a key and value to a database. If the key does not exist, it will be created. If the key does exist, it will overwritten.
/**
* @param string key
* @param string val
*/
function put(key, val)
The storage.get
function allows your bot to get a value from a database from a key.
/**
* @param string key
*/
function get(key)
The storage.delete
function allows your bot to delete a row from a database with a key.
/**
* @param string key
*/
function delete(key)
Want to contribute? Do it. Read the contributing guidelines first.
Mouse is licensed under MIT.