From ba2ab323e30f4e3215a50921d454e370267ce803 Mon Sep 17 00:00:00 2001 From: reality Date: Mon, 14 Jan 2013 13:10:16 +0000 Subject: [PATCH] Do the [#133] --- modules/dent/dent.js | 30 +++++++++++++++++++++--------- modules/quotes/quotes.js | 5 +++++ 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/modules/dent/dent.js b/modules/dent/dent.js index 3d5844e..120b082 100644 --- a/modules/dent/dent.js +++ b/modules/dent/dent.js @@ -1,28 +1,40 @@ var request = require('request'); + _ = require('underscore')._; var dent = function(dbot) { - var commands = { - '~dent': function(event) { - var username = dbot.config.dent.username; - var password = dbot.config.dent.password; - var auth = "Basic " + + var api = { + 'post': function(content) { + var username = dbot.config.dent.username, + password = dbot.config.dent.password, + info, + auth = "Basic " + new Buffer(username + ":" + password).toString("base64"); + request.post({ 'url': 'http://identi.ca/api/statuses/update.json?status=' + - event.input[1], + content, 'headers': { 'Authorization': auth } }, function(error, response, body) { - event.reply('Status posted (probably).'); - }); + console.log(body); + }.bind(this)); + } + }; + + var commands = { + '~dent': function(event) { + api.post(event.input[1]); + event.reply('Dent posted (probably).'); } }; commands['~dent'].regex = [/^~dent (.+)$/, 2]; return { - 'commands': commands + 'name': 'dent', + 'commands': commands, + 'api': api }; }; diff --git a/modules/quotes/quotes.js b/modules/quotes/quotes.js index 96524c5..70cb9c1 100644 --- a/modules/quotes/quotes.js +++ b/modules/quotes/quotes.js @@ -260,6 +260,11 @@ var quotes = function(dbot) { 'category': key, 'count': quotes[key].length })); + + // TODO hook + if(_.has(dbot.api, 'dent')) { + dbot.api.dent.post(key + ': ' + text); + } } },