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.channelsandapp_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
.envwhich will contain 4 environment variables, each on its own line in the format ofkey=value:
RUSTY_LOG_LEVELwhich controls the logs level. Set it to DEBUG as a default.PLAYGROUND_URLwhich should be set to the rust playground current URL. Currently it'shttps://play.rust-lang.orgSLACK_BOT_TOKENwhich is the bot token you've generated before.SLACK_APP_TOKENwhich 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 generatestdoutandstderralong with a playground link to the code.!eval: As with the previous command you should type it as!evalfollowed 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

