Skip to content

Commit

Permalink
Refactor to fit with new method for initing interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeFoodPixels committed Aug 11, 2014
1 parent f54760d commit a212ba2
Showing 1 changed file with 31 additions and 11 deletions.
42 changes: 31 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,36 @@
var hangoutsBot = require("hangouts-bot");
var bot = new hangoutsBot("", "");
module.exports = function(){

module.exports = function(api){
this.name = 'hangouts';

bot.on('online', function() {
api.addMessageSender('hangouts', function(message, to){
bot.sendMessage(to, message);
});
});
this.defaultPrefs = [{
name: 'username',
type: 'text',
value: ''
},{
name: 'password',
type: 'password',
value: ''
}];

bot.on('message', function(from, message) {
api.messageRecieved(from, 'hangouts', message)
});
this.init = function(){
var self = this;
var hangoutsBot = require("hangouts-bot");
this.getPrefs().done(function(prefs){
var bot = new hangoutsBot(prefs.username, prefs.password);
bot.on('online', function() {
self.api.addMessageSender('hangouts', function(message, to){
bot.sendMessage(to, message);
});
});

bot.on('message', function(from, message) {
self.api.messageRecieved(from, 'hangouts', message)
});
})

}

return this;
}


0 comments on commit a212ba2

Please sign in to comment.