Slack bot that can execute Rust code
Currently this is only supported for mac/linux based systems.
- You'll have to create an app on slack website
- Enable Socket Mode and subscribe to the following bot events:
message.channels
andapp_mention
. This will generate a bot token for you that typically starts withxoxb-
. You will need it later. - You should also generate an App-Level token with the scope
connections:write
. The generated token will start withxapp-
.
Note: You'll have to have docker and docker-compose installed in order to run this in a container environment.
- Clone this repository to
/opt/
- In the repository folder, create a file called
.env
which will contain 4 environment variables, each on its own line in the format ofkey=value
:
RUSTY_LOG_LEVEL
which controls the logs level. Set it to DEBUG as a default.PLAYGROUND_URL
which should be set to the rust playground current URL. Currently it'shttps://play.rust-lang.org
SLACK_BOT_TOKEN
which is the bot token you've generated before.SLACK_APP_TOKEN
which is the app token you've generated before.
- From the repository folder enter:
make install
- Finally start the bot with
make run
Currently the bot has the following commands supported:
!code
: Entering this following a new line with formatted Rust code (using 3 backticks (`) in slack) will execute the code and will generatestdout
andstderr
along with a playground link to the code.!eval
: As with the previous command you should type it as!eval
followed by new line with formatted rust code using 3 backticks. This is for code that can live insidemain()
- so you don't have to type main's signature itself. It is intended for evaluating simple expressions that do not require extra functions/imports.!help
:!help docs
- will output a link for rust docs!help book
- will output a link for the rust book!help <anything else>
- typing anything other than [docs, books] will display the available commands
@<botname>
: Will generate a nice response from the bot
Some examples:
- Add support for Windows