REPLbot is a Slack bot that allows you to control a REPL from within Slack.

🤖 REPLbot

REPLbot is a Slack bot that allows you to control a REPL from within Slack. It comes with a few REPLs (Go 🥳 , Java, NodeJS, PHP, Python, Ruby, Scala, Kotlin, C++ and Ubuntu/Bash), but you can easily make/bring your own.

replbot demo

Why ...?

I thought it might be a fun way to collaboratively dabble with a REPL in a team. Yes, I could have gone for a terminal in a browser, but there's nothing like having it right there in Slack. Mainly I did it because it was fun though. 😄

How it works

I use tmux and the tmux capture-pane command to run most of the show. It's simple, but effective. In the first iteration I tried using a pseudo terminal (pty) directly, but with all the escape sequences and commands, it was getting kinda tiresome, and I was spending time with stuff that I didn't want to spend time with (though I learned a lot!). And tmux does its job so well.

The actual REPLs are just simple scripts (see script.d folder), so they could be anything you like. I highly recommend using Docker to provide somewhat of an isolation, though you'll probably still need to trust the people using the bot if you give them an entire REPL.

Installation

Install steps:

  1. Make sure tmux and probably also docker are installed. Then install REPLbot using any of the methods below.
  2. Then edit /etc/replbot/config.yml to add Slack bot token. The config also explains how to create a Slack app and acquire this token.
  3. Review the scripts in /etc/replbot/script.d, and make sure that you have Docker installed if you'd like to use them.
  4. If you're running REPLbot as non-root user (such as when you install the deb/rpm), be sure to add the replbot user to the docker group: sudo usermod -G docker -a replbot.
  5. Then just run it with replbot (or systemctl start replbot when using the deb/rpm).

Debian/Ubuntu (from a repository):

curl -sSL https://archive.heckel.io/apt/pubkey.txt | sudo apt-key add -
sudo apt install apt-transport-https
sudo sh -c "echo 'deb [arch=amd64] https://archive.heckel.io/apt debian main' > /etc/apt/sources.list.d/archive.heckel.io.list"  
sudo apt update
sudo apt install replbot

Debian/Ubuntu (manual install):

sudo apt install tmux
wget https://github.com/binwiederhier/replbot/releases/download/v0.1.2/replbot_0.1.2_amd64.deb
dpkg -i replbot_0.1.2_amd64.deb

Fedora/RHEL/CentOS:

# Make sure that "tmux" is installed
rpm -ivh https://github.com/binwiederhier/replbot/releases/download/v0.1.2/replbot_0.1.2_amd64.rpm

Docker:
You can configure the Docker image by mounting a config directory (containing config.yml) to /etc/replbot. To be able to use most of the pre-packaged script.d REPLs (to be mounted to /etc/replbot/script.d), you'll need to give the REPLbot image access to the Docker socket file. This allows the container to spin up other containers on the host. This is a security risk and considered bad practice, but it's the only way.

docker run --rm -it \
  -v /etc/replbot:/etc/replbot \
  -v /var/run/docker.sock:/var/run/docker.sock \
  binwiederhier/replbot

Go:

# Be sure "tmux" is installed
go get -u heckel.io/replbot

Manual install (any x86_64-based Linux):

# Make sure that "tmux" is installed
wget https://github.com/binwiederhier/replbot/releases/download/v0.1.2/replbot_0.1.2_linux_x86_64.tar.gz
sudo tar -C /usr/bin -zxf replbot_0.1.2_linux_x86_64.tar.gz replbot

Contributing

I welcome any and all contributions. Just create a PR or an issue, or talk to me on Slack.

License

Made with ❤️ by Philipp C. Heckel, distributed under the Apache License 2.0.

Owner
Philipp C. Heckel
Principal Engineer at @datto, open source fan, semi-regular blogger, former author of @syncany, German 🇩🇪, fan of 🇬🇧 & 🇺🇸, and a dad 👦
Philipp C. Heckel
Comments
  • Failed to start tmux, installed via rpm

    Failed to start tmux, installed via rpm

    I tried to start up a repl but it immediately failed with the following log output:

    Started replbot server.
    Slack connected as user replbot/U02F6EQ62VD
    [session C5UPSCFP1_1632527569_060800] Starting session
    [session C5UPSCFP1_1632527569_060800] Started REPL session
    [session C5UPSCFP1_1632527569_060800] Failed to start tmux: exit status 1
    [session C5UPSCFP1_1632527569_060800] Closed REPL session
    [session C5UPSCFP1_1632527569_060800] Session exited with error: exit status 1
    

    But when I switch user to the replbot user I'm able to start a tmux session without issue. I don't think this is related to #35, as I'm using the default set of scripts that came installed with the RPM package. I also double-checked the python repl that I used to try it out and it had regular unix line endings.

    Thanks so much for the project! I'm looking forward to playing with it. Right now I'm using it to learn about AWS CDK. I'm hoping to make a reusable stack that anyone can use to stand up a replbot server on an ec2 machine.

  • Update & add some included REPLs, update readme.md

    Update & add some included REPLs, update readme.md

    -Slightly modified some existing REPLs to use official images from Docker Hub. Feel free to leave out this change, Docker Hub pull limits aren't great.

    -Added the following REPLs that we have been using in our server verified that they work without issue (and provide a ton of fun): Alpine, Amazon Linux, Arch Linux, CentOS, Debian & Fedora.

    -Updated readme.md to reflect the added default REPLs.

    These added REPLs are all things we found fun to play around with in our server so figured I'd share, and hopefully save someone a few seconds from having to create their own :smile: With that said, it is super easy to add your own.

  • (Discord) Delete thread on exit

    (Discord) Delete thread on exit

    It creates a fair bit of noise when it doesn't delete the threads when the session is over.

    An option in config.yaml to enable/disable deletion would be a nice companion.

  • Failed to start tmux

    Failed to start tmux

    Ran into another tmux issue with the latest Docker image for REPLbot, however I don't think this one is related to the scripts being in DOS format 😄

    This is a brand new VM running Ubuntu 20.04.3 LTS, latest version of tmux and Docker.

    root@replbot01:~# docker run --rm -it \
    >   -v /etc/replbot:/etc/replbot \
    >   -v /var/run/docker.sock:/var/run/docker.sock \
    >   binwiederhier/replbot
    Unable to find image 'binwiederhier/replbot:latest' locally
    latest: Pulling from binwiederhier/replbot
    ba3557a56b15: Pull complete
    94caa5d1da70: Pull complete
    a10a29983da5: Pull complete
    3d6ccddb7fa4: Pull complete
    ed1bef566495: Pull complete
    201a9d1142eb: Pull complete
    0806b78d1f4d: Pull complete
    2987e14e0ec7: Pull complete
    b6e074b08920: Pull complete
    Digest: sha256:5766d1634030f8bda85441f471a0a5f566bf24acba515c9373ba50d3ae04cccd
    Status: Downloaded newer image for binwiederhier/replbot:latest
    2021/10/02 21:32:03 Discord connected as user REPLbot/880575037789323355
    2021/10/02 22:03:43 [773039894888579092_893981604693831710] Starting session, requested by 451095196118024202
    2021/10/02 22:03:43 [773039894888579092_893981604693831710] Started REPL session
    2021/10/02 22:03:43 [773039894888579092_893981604693831710] Failed to start tmux: command failed: fork/exec /tmp/replbot_773039894888579092_893981604693831710.tmux.script: no such file or directory
    command: /tmp/replbot_773039894888579092_893981604693831710.tmux.script
    command output:
    2021/10/02 22:03:43 [773039894888579092_893981604693831710] Closed REPL session
    2021/10/02 22:03:43 [773039894888579092_893981604693831710] Session exited with error: command failed: fork/exec /tmp/replbot_773039894888579092_893981604693831710.tmux.script: no such file or directory
    

    Let me know if you need any other info! I'll try to dig into this more later when I have some time.

  • Failed to start tmux using Docker

    Failed to start tmux using Docker

    Using the latest Docker image, replbot seems to be unable to start tmux. Also using the latest config and script.d files. I haven't had much time to look into this yet and have not tested using replbot straight from Go or with a direct install, but figured I'd at least document it here. I am using the latest version of Docker and the host is Ubuntu 20.04.3. Let me know if I can provide any more info!

    root@localhost:~# docker run --rm -it \
    >   -v /etc/replbot:/etc/replbot \
    >   -v /var/run/docker.sock:/var/run/docker.sock \
    >   binwiederhier/replbot
    Unable to find image 'binwiederhier/replbot:latest' locally
    latest: Pulling from binwiederhier/replbot
    ba3557a56b15: Pull complete 
    94caa5d1da70: Pull complete 
    a10a29983da5: Pull complete 
    3d6ccddb7fa4: Pull complete 
    ed1bef566495: Pull complete 
    201a9d1142eb: Pull complete 
    0806b78d1f4d: Pull complete 
    2987e14e0ec7: Pull complete 
    cf93861db271: Pull complete 
    Digest: sha256:cc83a8a0613674a70b25d7bf7a23a536b2183a0eed47845f54456696f88f388e
    Status: Downloaded newer image for binwiederhier/replbot:latest
    2021/09/22 17:52:10 Discord connected as user REPLbot
    2021/09/22 17:52:14 [773039894888579092_890294434044993566] Starting session, requested by axite
    2021/09/22 17:52:14 [773039894888579092_890294434044993566] Started REPL session
    2021/09/22 17:52:14 [773039894888579092_890294434044993566] Failed to start tmux: exit status 1
    2021/09/22 17:52:14 [773039894888579092_890294434044993566] Closed REPL session
    2021/09/22 17:52:14 [773039894888579092_890294434044993566] Session exited with error: exit status 1
    
  • Web terminal not working

    Web terminal not working

    ❯ sudo grep ^web-add /etc/replbot/config.yml
    web-address: [redacted]:[redacted]
    
    ❯ ttyd -h 2>&1 | head -1
    ttyd is a tool for sharing terminal over the web
    
    ❯ which ttyd
    /usr/local/bin/ttyd
    

    image

    Also, it looks like it's completely missing from the Slack message http:///uQURnJBV2C.

  • Share your own terminal

    Share your own terminal

    This works, but is cumbersome for the user:

    ssh -N -R 10000:localhost:22 [email protected]
    ssh -t pheckel@localhost -p 10000 tmux a
    
    • Could add SSH server to replbot
    • Can we redirect traffic directly to tmux server instead of going through ssh server on the local side?
  • REPLbot no longer works on Discord

    REPLbot no longer works on Discord

    Tried to spin up REPLbot for another Discord server today and can't seem to get it to work. I've tried with both normal permissions + administrator permissions on the bot as well as the role in the server. In servers, it doesn't seem to send any messages at all when mentioned. It does reply in DMs, but is unable to recognize any commands. Screenshot attached. Screenshot 2022-08-29 004706

This slack-bot collects all @gophers notifications into one slack channel

slack-bot Slack bot copying reference to a ping to notifications channel The bot is designed to listen on messages containing specific tag, copy refer

Apr 11, 2022
A bot based on Telegram Bot API written in Golang allows users to download public Instagram photos, videos, and albums without receiving the user's credentials.

InstagramRobot InstagramRobot is a bot based on Telegram Bot API written in Golang that allows users to download public Instagram photos, videos, and

Dec 16, 2021
RaspChecker - A Telegram bot that allows you to monitor your Raspberry Pi's temperature and shut it down. Written in Golang.

RaspChecker Remotely monitor your Raspberry Pi's temperature and shut it down if you want. All through Telegram. How to set up In order to run the bot

Jan 2, 2022
Bot-template - A simple bot template for creating a bot which includes a config, postgresql database

bot-template This is a simple bot template for creating a bot which includes a c

Sep 9, 2022
A Telegram bot that asks you a question and evaluate the response you provide.
A Telegram bot that asks you a question and evaluate the response you provide.

PiSquared A Telegram bot that asks you a question and evaluate the response you provide. Thanks to the labse_bert model, the evaluation of the answer

Nov 13, 2022
IRC, Slack, Telegram and RocketChat bot written in go
IRC, Slack, Telegram and RocketChat bot written in go

go-bot IRC, Slack & Telegram bot written in Go using go-ircevent for IRC connectivity, nlopes/slack for Slack and Syfaro/telegram-bot-api for Telegram

Dec 20, 2022
Slack Bot Framework

slacker Built on top of the Slack API github.com/slack-go/slack with the idea to simplify the Real-Time Messaging feature to easily create Slack Bots,

Dec 25, 2022
Slack bot core/framework written in Go with support for reactions to message updates/deletes
Slack bot core/framework written in Go with support for reactions to message updates/deletes

Overview Requirements Features Demo The Name Concepts Create Your Own Slackscot Assembling the Parts and Bringing Your slackscot to Life Configuration

Oct 28, 2022
🦎 A slack bot for random gex quotes

?? A slack bot for random gex quotes

Jan 3, 2022
Golang bot that connects to slack using Socketclient to read and write messages.
Golang bot that connects to slack using Socketclient to read and write messages.

?? (not)simple go project ?? Golang bot that connects to slack using Socketclient to read and write messages. ?? Use ?? @SquidBot : Mentions your name

Aug 23, 2022
Snitch - a Slack bot that fetches pending review PRs built in Go
Snitch - a Slack bot that fetches pending review PRs built in Go

Snitch Snitch is a Slack bot that fetches and publish PRs with pendings reviews

Nov 29, 2022
A serverless bot which periodically checks configured BigQuery capacity commitments, reservations and assignments against actual slot consumption of running jobs and reports findings to Slack/Google Chat.
A serverless bot which periodically checks configured BigQuery capacity commitments, reservations and assignments against actual slot consumption of running jobs and reports findings to Slack/Google Chat.

Solution Guide This solution implements a ChatOps-like approach to monitoring slot utilization of Google Cloud BigQuery reservations. As an alternativ

Dec 7, 2022
CultureBot - A slack bot used to act as a companion to new people in tech

Culture Bot A slack bot used to act as a companion to new people in tech. Helps

Feb 6, 2022
This utility allows you to execute Minecraft server commands through the RCON protocol via Telegram chat.

Minecraft RCON by Telegram This utility allows you to execute Minecraft server commands through the RCON protocol via Telegram chat. FAQ When you run

Jul 24, 2022
Dlercloud-telegram-bot - A Telegram bot for managing your Dler Cloud account

Dler Cloud Telegram Bot A Telegram bot for managing your Dler Cloud account. Usa

Dec 30, 2021
Quote-bot - Un bot utilisant l'API Twitter pour tweeter une citation par jour sur la programmation et les mathématiques.

Description Ceci est un simple bot programmé en Golang qui tweet une citation sur la programmation tout les jours. Ce bot est host sur le compte Twitt

Jan 1, 2022
Discord-bot - A Discord bot with golang

JS discord bots Install Clone repo git clone https://github.com/fu-js/discord-bo

Aug 2, 2022
Bot - Telegram Music Bot in Go

Telegram Music Bot in Go An example bot using gotgcalls. Setup Install the serve

Jun 28, 2022
Pro-bot - A telegram bot to play around with the community telegram channels

pro-bot ?? Pro Bot A Telegram Bot to Play Around With The Community Telegram Cha

Jan 24, 2022