Giter VIP home page Giter VIP logo

gerardbot's Introduction

GérardBot!

Hey! This is a very simple Slack bot based on the excellent slackbots library allowing you to easily add your own services.


Installation

  1. Download and install the latest Node.js version
  2. Clone the repository git clone [email protected]:Karhal/gerardbot.git
  3. Enter the repository cd ~/gerardbot
  4. Install: npm install

Configuration

You'll need a Slack token (https://my.slack.com/services/new/bot) and a bot name. Please check the config.example.js file.

Create a module

The real advantage of Gérardbot is that you can easily create your own modules which will be plugged to you original bot. Let's create a simple HelloWorld module as an example :

lib/modules/helloworld/helloworld.js

var util = require('util');
var config = require('./config.js');
var Module = require('./../../../bin/module.js');

var Helloworld = function Constructor(bot) {
    this.bot = bot;
    this.data = null;
    this.keyWords = config.keywords;
};
util.inherits(Helloworld, Module);

Helloworld.prototype.getAnswer = function() {
      this.bot.postMessage(this.data.channel, 'Hello world!', this.bot.params);
};

lib/modules/helloworld/config.js

var config = {};   
config.keywords = ['hello', 'bonjour'];   
module.exports = config;

That's it !

Usage

  1. Run your application : node bin/bot.js
  2. Connect to your slack
  3. Invite your bot in the channel you want: /invite @yourbot
  4. Say @yourbot hello !
  5. Enjoy

Imgur Module example

lib/modules/imgur/config.js

var config = {};

config.keywords = ['montre moi des', 'sors nous une photo de'];
config.imgurAuth = 'Client-ID xxxxxxxxxxx';

config.subs = {
    'chiens': 'dogs',
    'chat': 'cats',
    'paresseux': 'sloths',
}

module.exports = config;

Imgur Module example

Restaurant Module example

lib/modules/restaurant/config.js

var config = {};

config.myplace = '50.654809,3.071461';
config.googlemaps_api_key = 'xxxxxxxxxxxxxxx';
config.radius = 1000;
config.keywords = ['on mange ou', 'on mange où'];
module.exports = config;

Imgur Module example

gerardbot's People

Contributors

karhal avatar syxxxx avatar

Stargazers

 avatar  avatar  avatar  avatar Tanghe Cédric avatar Galcha avatar Sébastien avatar Julien Labetoulle avatar  avatar Antoine avatar Beze Nicolas avatar Julien M avatar

Watchers

Julien M avatar  avatar  avatar

Forkers

syxxxx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.