Skip to content

DustinTrumps/jokebot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Slack Joke Bot

A simple Slack bot built with Node.js, node-cron, and JokeAPI.

Features

  • /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.

Using It Yourself

git clone https://github.com/DustinTrumps/jokebot
cd jokebot
npm install

Create a .env file

SLACK_BOT_TOKEN=xoxb-your-bot-token
SLACK_APP_TOKEN=xapp-your-app-token

Starting the Bot

Run:

node index.js

Or, to run it as a persistent systemd service:

nano /etc/systemd/system/slackbot.service

Paste 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.target

Note: Running as User=root works 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 updating User= and WorkingDirectory= accordingly.

Quick Commands

systemctl start slackbot.service
systemctl stop slackbot.service
systemctl restart slackbot.service
systemctl status slackbot.service

Joke API

https://jokeapi.dev/

Filtered Categories

  • NSFW
  • Religious
  • Political
  • Racist
  • Sexist
  • Explicit

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages