1.1.0 • Published 8 years ago

botkit-chronos v1.1.0

Weekly downloads
5
License
MIT
Repository
github
Last release
8 years ago

botkit-chronos NPM version Dependency Status

A middleware that extracts time information from messages using the chrono library. (WORK IN PROGRESS)

Installation

$ npm install --save botkit-chronos

Usage

var Botkit = require('botkit');
var botkitChronos = require('botkit-chronos');
var controller = Botkit.slackbot({
  debug: false
});
botkitChronos.use(controller);

// The controller will listen on all texts starting with 'meeting on' and are followed by a phrase that contains time related
// content. For example the robot will respond to: 
//
// Meeting on Friday
// Meeting in a month
// Meeting next monday
// Meeting on the 6th of June
//
// When a time phrase is detected its replaced with TS#timestamp

controller.hears(['meeting on TS(.*)'],'direct_message,direct_mention,mention', function(bot, message) {
  console.log(new Date(message.text.match(/meeting on TS(.*)/i)[0]));
});

License

MIT © Alex Psi