#!/usr/bin/env node

'use strict';

var Slack = require('slack-client');
var token = process.argv[2];

if (!token) {
  console.error([
    'Usage: feurbot <token>',
    null,
    'To generate a token, create a bot at http://my.slack.com/services/new/bot'
  ].join('\n'));
  process.exit(1);
}

var slack = new Slack(token);

slack.on('message', function (message) {
  if (message.type !== 'message') {
    return;
  }

  if (!/quoi\s*[?!]*$/.test(message.text) && Math.random() < 0.99) {
    return;
  }

  var channel = slack.getChannelGroupOrDMByID(message.channel);
  var before  = 'FEEEEEUUUUUUUR !';
  var after   = Math.random() < .5 ? '(bim !)' : '(boum !)';
  var msg     = channel.send(before);

  setTimeout(function() {
    msg.updateMessage(before + ' ' + after);
  }, 700);
});

slack.on('error', function (err) {
  if (err === 'invalid_auth') {
    console.error('Invalid token, go grab a valid one!')
    process.exit(1);
  }

  console.error(err);
});

slack.login();

@@ -39,16 +39,18 @@
 r Slack 
+  
 = requir
@@ -78,16 +78,18 @@
 r token 
+  
 = proces
@@ -98,16 +98,80 @@
 argv%5B2%5D;
+%0Avar trigger = /(q+u+o+i+%7Ck+o+i+%7Ck+o+a+%7Cc+o+m+e+n+t+)%5Cs*%5B?!%5D*$/;
 %0A%0Aif (!t
@@ -491,23 +491,15 @@
 f (!
-/quoi%5Cs*%5B?!%5D*$/
+trigger
 .tes

Add some more trigger messages