It's kind of tough to work on this in regards to development. So there's one of two ways we can go about this.
If you're a member of Redbrick (and We will check if you actually are) then We suggest getting in touch privately and We'll sort you out in regards to development where brickbot is hosted from.
If you aren't a Redbrick member you're obviously still welcome to help out! It's probably easiest for you to work on this by setting up your own Discord server. Once you've done that you'll need to create a bot account. This involves creating a token for your bot. The brickbot code specifies that this token is found at /etc/brickbot.token
but you can change this to anywhere on your local machine for development purposes.
Clone the project with:
From here you can install the dependencies (don't worry there aren't many) like so:
yarn
You can run the bot by using:
node bot.js
You can also run it as a systemd service if you want, checkout the brickbot.service
file and make changes where appropriate.
If you don't want to run on bare-metal, then Docker is your friend and there's docker-compose to utilise by running:
docker-compose up -d
Let's say you have a command you want to add, well this is the section which clarifies how you go about doing that.
All the code for the commands is hosted at 'faas.jamesmcdermott.ie' as a cluster of serverless functions. Each one of these functions can be found on a given http endpoint. You can try this one out with just curl
, it should return a link to a random page on the Redbrick wiki:
curl faas.jamesmcdermott.ie/function/wiki
As said in the README, you can write this in any language! The hosted wiki command is written in Python, the hosted 'isitup' command is written in Bash, and the 'bus' and 'luas' commands actually use a Node.js api to query, which is a little anti-serverless, but also not really. We're digressing. No matter what language you prefer, it can be used to extend brickbot functionality!
So, let's say you have code, in a repo or a gist for example, all you need to do is tell me where that code lives. We'll take care of it from there, we'll just need the location.
Once this part is done it's pretty trivial. Let's run through an example of adding a command called "coinflip".
- Add a
coinflip.js
file in thecommands
directory where the function is insidemodule.exports
. There's a few examples of this. - Your command needs to make http request to the endpoint at which the code is hosted, in this case it's at
faas.jamesmcdermott.ie/function/coinflip
. - Based on the response you get back from the function, add your logic to handle it. there's a function called
receivedMessage.channel.send()
that is used to send your finalised output back to the channel. - If you need to write any command specific helper functions, you can just add them outside of
module.exports
in the same file. - If you need to write a non specific help function, you can add it to
helpers/helpers/js
. - Once it's all done, make sure to add your command to the big switch statement in
bot.js
, otherwise all your work won't get evaluated! While doing this make sure you also add a like help section to the switch statement incommands/help.js
. - Add your command to the function list in
get_test_set_one
(in this file) along with it's expected result of 0 to its respective list. - Add the command and its creator to the list of functions in the
README.md
file.
If you want some configs to be added to the instance of OpenFaaS We're running, you can make a PR here.