Skip to content

Commit

Permalink
automagically bring all karma to lowercase
Browse files Browse the repository at this point in the history
fixes #10
  • Loading branch information
qmx committed Apr 13, 2014
1 parent e9e96b1 commit 5ce26d3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function Bot(nick) {
this.parseKarmaRequest = function (message) {
var matchData = this.KARMA_RE.exec(message);
if (matchData) {
var user = matchData[2];
var user = matchData[2].toLowerCase();
var direction;
if (matchData[3] === '++') {
direction = 1;
Expand Down
5 changes: 5 additions & 0 deletions test/bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ describe('The Bot', function () {
var bot = new Bot('ferb');
assert.notOk(bot.isValidKarmaRequest('larry', bot.parseKarmaRequest('I am awesome, thus larry++')));
});
it('ignores case while processing karma', function () {
var bot = new Bot('doofenschmirtz');
var request = bot.parseKarmaRequest('ignoring case is a must, FOO++');
assert.equal(request.user, 'foo');
});
it('allows you to downvote yourself', function() {
var bot = new Bot('phineas');
assert.ok(bot.isValidKarmaRequest('larry', bot.parseKarmaRequest('whoops, larry--')));
Expand Down

0 comments on commit 5ce26d3

Please sign in to comment.