imjoshdean / mascot-bot

Beatz Bot is BronyCon's Slack assistant, at your service!
MIT License
5 stars 3 forks source link

Mascot Bot

Mascot Bot is the future BronyCon Slack assistant currently under development. Developed in ES6 with Babel, and running on Node v6.7.0 or higher.

Setup

  1. Create a bot user in your Slack account.
  2. Install Mascot-Bot on any computer or server.
  3. Use the API token (xoxb-a-b) to execute the bot.

Installing

git clone git@github.com:imjoshdean/mascot-bot.git
cd mascot-bot
yarn // npm install if you aren't using yarn yet

Running Mascot Bot

Where xoxb-a-b is your Slack bot API token:

SLACK_TOKEN=xoxb-a-b npm run start-dev

Optional User Environment Options

Mascot Bot

Mascot Bot extends SlackBot. So all settings, properties, functions available to SlackBot are available to MascotBot including the following.

Settings

{
  behavior: BehaviorClass,
  settings: {}
}

Functions

Behavior

Behaviors are extended custom functionality of Mascot Bot. Think of them like widgets or modules. These are useful for providing any number of features, such as custom interations with users or fetching and outputing data with commands (more on that later.

Settings

These settings should be implemented in the constructor function before calling the parent constructor function, otherwise they will not be applied.

Properties

Functions

Usage

import { MascotBot, Behavior } from 'mascot-bot';

class GreetBehavior extends Behavior {
  constructor(settings = {}) {
    settings.name = 'Greet Behavior';

    super(settings);

    this.addCommand('hello', 'Say hello back whenever someone types !hello');
  }

  execute(command, message, channel, data) {
    switch (command) {
    case 'hello':
      this.bot.postMessage(channel, `Hello to you too, <@${data.user}>!`, {
        icon_emoji: ':wave:'
      });
      break;
    default:
      break;
    }
  }
}

const bot = new MascotBot({
  name: 'Blank Bot',
  behaviors: [
    GreetBehavior
  ]
});

bot.initialize();