Permalink
Browse files

[beer] Use preferences data (issue #64)

  • Loading branch information...
1 parent f7f7ac1 commit 58dcc7741f12dd692e9fea0963fa8528f772e7f5 @mmalecki mmalecki committed Oct 14, 2011
Showing with 7 additions and 1 deletion.
  1. +7 −1 lib/listeners/beer.js
View
@@ -11,6 +11,7 @@ var beer = module.exports = function () {
var self = this;
self.karma = {};
+ self.preferences = {};
self.on('*::gotMessage', function (data) {
var re = /(\w+)(\+\+|--)/,
@@ -26,10 +27,15 @@ var beer = module.exports = function () {
}
return self.emit('sendMsg', {
dest: data.to,
- msg: res[1] + ' has ' + self.karma[res[1]] + ' beer' +
+ msg: res[1] + ' has ' + self.karma[res[1]] + ' ' +
+ (self.preferences[res[1]] || 'beer') +
((Math.abs(self.karma[res[1]]) > 1) ? 's' : '')
});
}
});
+
+ self.on('karmaPreferenceSet', function (data) {
+ self.preferences[data.nick] = data.preference;
+ });
};

0 comments on commit 58dcc77

Please sign in to comment.