a basic slackbot, written in js (node).
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Blaine Motsinger da83e14636 updated documentation on listeners 1 year ago
config hard coded user dir 1 year ago
.gitignore a basic working reply 2 years ago
README.md updated documentation on listeners 1 year ago
adventurehound-bot.js updated documentation on listeners 1 year ago
package.json a basic working reply 2 years ago

README.md

adventurehound-bot

SYNOPSIS

Normal usage runs without switches

$ node adventurehound-bot.js

DESCRIPTION

adventurehound-bot is a basic slackbot, written in js (node).

SETUP AND CONFIGURATION

To create the app and bot user through Slack

  • First, click on “add an app” through the Slack client

  • Add the appname - adventurehound-bot

  • Select the workspace - adventurehound

  • Click - create app

  • Click - add a bot user

    • autopopulated details for the bot should be sufficient
    • ensure “always show bot my bot as online” is not selected
  • Click - add bot user

  • Click - OAuth & Permissions

    • authorize the bot to access the channel
    • the bot will not show up in your apps list for the channel, but won't be connected
    • copy the oauth tokens from the slack api page and save them to a safe place
  • Invite the new bot to the channel through Slack /invite @adventurehound-bot

For setup on a Debian server to run the bot persistently

as root

Install the system wide deps and create the user to run adventurehound-bot as.

# apt-get install git curl
# curl -sL https://deb.nodesource.com/setup_10.x | bash -
# apt-get install nodejs
# node --version
v10.12.0
# npm --version
6.4.1
# adduser adventurehound

as adventurehound

Install and configure the project into the adventurehound user's homedir.

$ mkdir ~/git
$ cd git/
$ git clone git@github.com:adventurehound/adventurehound-bot.git
$ cd adventurehound-bot/
$ npm install 

$ touch ~/.adventurehoundbotrc
$ vi ~/.adventurehoundbotrc
{
    "slackToken": "xoxb-1234567890-0987654321-notArealToken"
}

The authentication information is read from the .adventurehoundbotrc file from the user's homedir.

~/.adventurehoundbotrc
{
    "slackToken": "xoxb-1234567890-0987654321-notArealToken"
}

running through systemd

Included within the config/system directory is a service file for basic control via systemd. The settings within the service file use non-generic user and directory settings, and need to be adjusted before enabling and starting the service.

Once you're updated the service file, copy it into /etc/systemd/system/, enable, and start.

# cp /home/adventurehound/git/adventurehound-bot/config/system/adventurehound-bot.service /etc/systemd/system/
# systemctl enable adventurehound-bot.service
Created symlink /etc/systemd/system/multi-user.target.wants/adventurehound-bot.service → /etc/systemd/system/adventurehound-bot.service.
# systemctl start adventurehound-bot.service

After starting you can check the status through systemctl.

# systemctl status adventurehound-bot.service

LISTENERS

direct message keywords

adventurehound-bot is set to respond to the following keywords if sent within a direct message or mention.

hello, hi, hey, thanks, thank you, good

Blaine Motsinger [4:49 PM]
hello @adventurehound-bot

adventurehound-bot APP [4:49 PM]
<pant pant>

joke

Retrieves a joke from the adventurehound-api.

Blaine Motsinger [4:57 PM]
@adventurehound-bot joke

adventurehound-bot APP [4:57 PM]
Why did the scarecrow win an award? Because it was outstanding in it's field.

quote

Retrieves a quote from the adventurehound-api.

Blaine Motsinger [4:58 PM]
@adventurehound-bot quote

adventurehound-bot APP [4:58 PM]
Remember, if the time should come when you have to make a choice between what is right and what is easy, remember what happened to a boy who was good, and kind, and brave, because he strayed across the path of Lord Voldemort. Remember Cedric Diggory. -J.K. Rowling, Harry Potter and the Goblet of Fire

DEPENDENCIES

  • botkit
  • request
  • fs