A Telegram Bot which works as a Janet REPL.
It will evaluate your messages and send the results back as replies.
Build,
$ git clone https://github.com/meinside/telegram-janet-repl-bot.git
$ cd telegram-janet-repl-bot
$ jpm deps
$ jpm build
then create a config file:
$ cp config.json.sample config.json
and edit it:
{
"token": "your:telegram-bot-token-here",
"interval_seconds": 1,
"allowed_telegram_usernames": ["allowed_telegram_username1", "allowed_telegram_username2"],
"is_verbose": false
}
Now run with:
$ build/repl-bot config.json
Create a systemd service file:
$ vi /etc/systemd/system/telegram-janet-repl-bot.service
and fill it with:
[Unit]
Description=Telegram Janet REPL Bot
After=syslog.target
After=network.target
[Service]
Type=simple
WorkingDirectory=/dir/to/telegram-janet-repl-bot
ExecStart=/path/to/telegram-janet-repl-bot/build/repl-bot /path/to/telegram-janet-repl-bot/config.json
Restart=always
RestartSec=5
DynamicUser=yes
ReadOnlyPaths=/
MemoryLimit=100M
NoExecPaths=/bin /sbin /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin
[Install]
WantedBy=multi-user.target
then make it autostart on reboots:
$ sudo systemctl enable telegram-janet-repl-bot.service
and start/stop it:
$ sudo systemctl start telegram-janet-repl-bot
$ sudo systemctl restart telegram-janet-repl-bot
$ sudo systemctl stop telegram-janet-repl-bot
- Functions/macros that print 'something' to stdout/stderr may return their ordinary results with the 'something' appended to them.
doc
macro doesn't work as expected. Usedoc-of
function instead.
This bot accepts messages only from allowed telegram usernames,
but is not free from bad messages, (eg. intentional infinite loops, malicious shell commands, etc.)
so be careful not to blow up your servers :-)