Skip to content

Commit

Permalink
Added reloading
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeFoodPixels committed Aug 18, 2014
1 parent fbfcfb7 commit c73fa4e
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,26 @@ module.exports = 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);
self.bot = new hangoutsBot(prefs.username, prefs.password);
self.bot.on('online', function() {
self.addMessageSender(function(message, to){
self.bot.sendMessage(to, message);
});
});

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

}

this.exit = function(){
if (this.bot) {
this.bot.connection.end();
}
}

return this;
}

Expand Down

0 comments on commit c73fa4e

Please sign in to comment.