Just another rewrite of Adjutant to learn Elixir
Has some interop with https://github.com/Th3-M4jor/BnBBackend-EX and private github webook for auto-redeployment of two frontend-projects.
After cloning the repo, the following steps are required to compile:
- create a file named
COOKIE
in the root directory of the repo with a random string as the contents - run
mix deps.get
to install all dependencies - in the
config
directory create a file nameddev.exs
then copy into itexample_config.exs
To run the bot the following extra things will be needed:
- A connection to a postgres database with the following tables:
"Virus"
"NaviCust"
"Battlechip"
- An
Oban
migration for the respective version of the library
- A development sqlite DB for logging and storing state about slash commands
- This can be created by running
mix ecto.create -r Adjutant.Repo.SQLite
- Said DB must then be migrated
mix ecto.migrate -r Adjutant.Repo.SQLite
- This can be created by running
- In
config/dev.exs
thetoken:
config will need an actual bot token
The bot should then be able to be successfully started by running:
iex -S mix
The same above steps for development will need to be run, except with the following changes:
config/dev.exs
will need to be replaced withconfig/prod.exs
- SQLite DB creation and migration will need to be done with the env var
MIX_ENV
set to"prod"
The bot can then be run with MIX_ENV
set to prod, however it is recommended to instead use a mix release
for production use.
To add a new command to the bot, the following steps are required:
- Create a new module for the command in the
lib/commands
directory- it is recommended to namespace the command's module name with
Adjutant.Commands
- it is recommended to namespace the command's module name with
- This new module should
use
theAdjutant.Command.Slash
module- See the documentation for the
Adjutant.Command.Slash
module for more information - Also, see
Adjutant.Command.Slash.BNB.PHB
for a simple example
- See the documentation for the
- Add this new module to the
@commands
list in theAdjutant.Command
module - The bot will take care of creating the command if it doesn't exist at startup
To delete a command, the following steps are required:
- Remove the module from the
@commands
list in theAdjutant.Command
module - Add the module to the
@deleted_commands
list in theAdjutant.Command
module - The bot will take care of deleting the command if its recorded as existing at startup
- Then on future rollouts you can delete the module
To rename a command, you must first delete the command and then add it again with the new name. An alternative option may be considered in the future if this happens often enough.