A simple Slack bot built with Node.js, node-cron, and JokeAPI.
- /jokebot-ping - Check if the bot is online and return the response time.
- /jokebot-joke-1p - Get a random one-part joke.
- /jokebot-joke-2p - Get a random two-part joke.
- Daily joke sent automatically to #bot-spam at 9:00 AM PST.
git clone https://github.com/DustinTrumps/jokebot
cd jokebot
npm installSLACK_BOT_TOKEN=xoxb-your-bot-token
SLACK_APP_TOKEN=xapp-your-app-tokenRun:
node index.jsOr, to run it as a persistent systemd service:
nano /etc/systemd/system/slackbot.servicePaste this:
[Unit]
Description=Slack Bot
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=root
Restart=always
RestartSec=5
WorkingDirectory=/root/jokebot
ExecStart=/usr/bin/node index.js
[Install]
WantedBy=multi-user.targetNote: Running as
User=rootworks but isn't best practice for an internet-facing process. Consider creating a dedicated low-privilege user (e.g.useradd -r -s /usr/sbin/nologin jokebot) and updatingUser=andWorkingDirectory=accordingly.
systemctl start slackbot.service
systemctl stop slackbot.service
systemctl restart slackbot.service
systemctl status slackbot.service- NSFW
- Religious
- Political
- Racist
- Sexist
- Explicit