diff --git a/install b/install index 1cdc62c..3105f0f 100755 --- a/install +++ b/install @@ -14,7 +14,7 @@ then exit 1 fi -npm install feedparser node-units tvdb crypto-js method-override 500px process async wordnik node-uuid underscore request sandbox express moment-timezone moment jade databank databank-redis ent passport passport-local password-hash connect-flash +npm install googlemaps feedparser node-units tvdb crypto-js method-override 500px process async wordnik node-uuid underscore request sandbox express moment-timezone moment jade databank databank-redis ent passport passport-local password-hash connect-flash cd public/ #wget http://twitter.github.com/bootstrap/assets/bootstrap.zip diff --git a/modules/gmaps/gmaps.js b/modules/gmaps/gmaps.js new file mode 100644 index 0000000..c4e278e --- /dev/null +++ b/modules/gmaps/gmaps.js @@ -0,0 +1,29 @@ +/** + * Module Name: Google Maps + * Description: GMaps and ting + */ +var gm = require('googlemaps'), + _ = require('underscore')._; + +var gmaps = function(dbot) { + this.commands = { + '~from': function(event) { + var from = event.input[1], + to = event.input[2], + departureNow = Math.floor((new Date()).getTime()/1000); + + gm.directions(from, to, function(err, result) { + if(!err && result && result.status !== 'ZERO_RESULTS') { + event.reply('If you leave right now, it will take ' + result.routes[0].legs[0].duration.text + ' to get from ' + from + ' to ' + to + ' via public transport.'); + } else { + event.reply('Apparently one cannot get from ' + from + ' to ' + to + ' using public transport. Do you accept the challenge?'); + } + }, 'false', 'transit', null, null,null, null, null, departureNow); + } + }; + this.commands['~from'].regex = [/^from (.*) to (.*)/, 3]; +}; + +exports.fetch = function(dbot) { + return new gmaps(dbot); +};