All Projects → konecnyna → slack-cat

konecnyna / slack-cat

Licence: GPL-3.0 license
meow

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to slack-cat

slacking
Modern Slack C++ 11 library for communicating with the Web Slack API
Stars: ✭ 58 (+262.5%)
Mutual labels:  slackbot
botkit-heroku-redis-example
Tiny example of running botkit on Heroku with RedisCloud
Stars: ✭ 21 (+31.25%)
Mutual labels:  slackbot
progress
Create Slack progress bars
Stars: ✭ 64 (+300%)
Mutual labels:  slackbot
symfony-slack-bot
Modern and simple bundle for sending customizable messages to Slack via incoming web-hooks for Symfony 3 and 4
Stars: ✭ 21 (+31.25%)
Mutual labels:  slackbot
Powershell-SlackBot
Powershell based Slack Bot using the Real Time Messaging API and WebSockets.
Stars: ✭ 41 (+156.25%)
Mutual labels:  slackbot
slack-logger
Slack logger that sends pretty formatted messages to a Slack channel.
Stars: ✭ 15 (-6.25%)
Mutual labels:  slackbot
slack-metabot
Extract metadata (EXIF) from uploaded files on Slack
Stars: ✭ 15 (-6.25%)
Mutual labels:  slackbot
rota-slackbot
Slackbot that helps manage rotations.
Stars: ✭ 50 (+212.5%)
Mutual labels:  slackbot
fridaybot
Slack bot for https://spb-frontend.slack.com
Stars: ✭ 29 (+81.25%)
Mutual labels:  slackbot
slack-timezone-bot
🤖⏰ Slack bot to show time in users' timezones
Stars: ✭ 51 (+218.75%)
Mutual labels:  slackbot
AWSEstimatedCharges2Slack
Summarise AWS/Billing EstimatedCharges for Slack
Stars: ✭ 18 (+12.5%)
Mutual labels:  slackbot
arXie-Bot
arXie is a Slack bot that browses and filters the arXiv repository for you
Stars: ✭ 29 (+81.25%)
Mutual labels:  slackbot
chessbot
Slack bot for playing chess.
Stars: ✭ 32 (+100%)
Mutual labels:  slackbot
cloud-functions
OpenFaaS social functions
Stars: ✭ 27 (+68.75%)
Mutual labels:  slackbot
slackr
Simple shell command to send or pipe content to slack via webhooks. (To upload snippets or files use: www.github.com/a-sync/slackfu)
Stars: ✭ 41 (+156.25%)
Mutual labels:  slackbot
on-demand-delivery-fastlane-slack
iOS On-Demand delivery architecture via slack/jenkins/fastlane. Demo project for: #PragmaConf2019
Stars: ✭ 18 (+12.5%)
Mutual labels:  slackbot
cakcuk
A Command Bot Interface builder, CLI-based to easily create your CLI commands for your Workspace
Stars: ✭ 13 (-18.75%)
Mutual labels:  slackbot
git-slack-notify
Sends Slack notifications for new commits in Git repositories
Stars: ✭ 12 (-25%)
Mutual labels:  slackbot
inspireNuggetsSlackBot
A simple Slackbot that displays random inspiring techie quotes and jokes for developers/designers.
Stars: ✭ 15 (-6.25%)
Mutual labels:  slackbot
slackcat
Concatenate files(s), or stdin, directly to Slack. 🐈
Stars: ✭ 19 (+18.75%)
Mutual labels:  slackbot

SlackCat

license Build Status

When you want slack to turn into a tire fire while also being productive at the same time.

Getting Started

It's ezpz. You can look at the example implementation here.

  1. Recommended Node Version: lts/carbon (v8.11)
  2. run npm install https://github.com/konecnyna/slack-cat.git --save (this assumes you did an npm init in the directory)
  3. Add the configure the configuration file, database path (useful for backing up data), and path to your modules. If you don't have any modules pass an empty string ''.
  4. Add your slack api key to config.json file in the root dir (See below for example).
  5. node index.js
  6. In Slack invite @SlackCat to a channel or direct message and run ?ping. If everything is working the bot should respond with ?pong.
const SlackCat = require('slack-cat');
const Path = require('path');


const configPath = Path.join(__dirname, 'config.json')
const dbPath = Path.join(__dirname, 'db.sqlite');
const modules = Path.join(__dirname, '/modules');

new SlackCat(modules,configPath, dbPath).start();

Example config.json:

{
    "slack_verification_token": "xxx",
    "slack_access_token": "xxx",
    "darksky_api": "xxx",
    "google_geocode_api": "xxx",
    "pager_duty_api": "xxx",
    "jira_api": {
    	"host": "xxx",
    	"username": "xxx",
    	"password": "xxx"
    },
    "modules_blacklist": [],
    "stock": "xxx",
    "port": 3000,
    "node_env": "production"
}

Modules

Look at the modules in the modules/default folder for examples. If there are core modules that you wouldn't like in slackcat you can add them to the "modules_blacklist".

For example: "modules_blacklist": ["poop"] in config.json file would exclude the ?poop command from slackcat.

Usage:

Assuming the above module was stored in the modules/users/helloworld path

?hellworld or ?hello_world2 would return Hello World!!!

Example Module:

Modules will have an index.js file nested in a folder in the modules directory. The folder name containing in the index.js file will be the default command name.

For example:

├── modules/
│    └── hrviolation/
|        └── index.js

Sending ?hrviolation will trigger the index.js in the hrviolation directory. You can add custom aliases for commands by overriding the aliases() method in BaseModule.

Example Module index.js file:

'use strict';

module.exports = class HelloWorld extends BaseModule {
  handle(data) {
    this.bot.postMessage(
      data.channel,
      'Hello World!!!',
      {
        icon_emoji: ':cat:'
      }
    );
  }

  help() {
    return "Usage: `?helloworld2` should print:\n'Hello World Number 2!!!'";
  }

  aliases() {
    return ['hello_world2']; // Now helloworld (folder name) or helloworld2 will trigger this module.
  }

  getType() {
    [return BaseModule.TYPES.MODULE];
  }
};
Type Desc Required Method
MODULE This is the default type. Use this when making a new cmd and call with ?<your_cmd_name> <args> handle(data)
OVERFLOW_CMD This module type is to handle commands that the router doesn't know how to handle. See handleOverflow(data) for an example. handleReaction(data)
REACTION This module is for handling when a user reacts to a post with an emoji. See the Reactions module for more info. handleReaction(data)
MEMBER_JOINED_CHANNEL This module is for handling when a user joins a channel handleMemberJoin(data)
RAW_INPUT This module is for handling any text being posted in the channel handleRawInput(data)
ENDPOINT This module handling server side createRoutes(data)
DIALOG This creates a dialog for a user to interact with createRoutes(app) onDialogSubmit(data)

Database

Slackcat has the ability to use many types of databases. By default it will use a light weight sqlite3 database however you can define your own:

"db": {
  "host": "postgres-db",
  "port": "5432",
  "dbName": "slackcat",
  "username": "**************",
  "password": "*************",
  "dialect": "postgres"
}

Dialogs

There is some more complexities with setting up dialogs in slack detailed here

Debugging

If you are testing you will often get rate limited. In order to test your cmd from the command line run

node index.js <cmd> <args>

eg: node index.js ?summon test

Will summon a google image matching test keyword.

If you want to test an endpoint module you can pass --with-server to spin up the express debug server.

Environments

NODE_ENV="production" node index.js will start the app in production mode which will use db.sqlite. Otherwise it will use db-dev.sqlite. This is useful in tests as not to corrupt production data.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].