Skip to content


Subversion checkout URL

You can clone with
Download ZIP


First cut of karma functionality. #11

wants to merge 5 commits into from

4 participants


To use just do nick++ or nick--


Indentation issues fixed.


The karma.json file should probably be blank to begin with or something.

Also, wrt ecmabot, I'm not certain we want to re-enable this feature as it has generally done more harm than good.


@gkatsev I have noted down your points :

  • Only allow a user ++/-- an hour. [Need to send a new PR on this]
  • Don't print the karma change in the channel. [Well many down voted for this]
  • Have a way for channel ops or something to let the bot ignore various users from being able to change karma. [Working on the black listing]

Will empty the karma.json soon, there are multiple comits need to cheery-pick as well.


Cool, the blacklisting is definitely needed. And printing karma changes in the channel was one of the reasons why it was removed. Perhaps this can be disabled if we have blacklisting but probably not.
Also, may be cool to add a weight to the karma by the weight of a user's karma, so, it'll work somewhat like the pagerank algorithm.


I changed my mind about where the karma code should go. I think it should go in ecmabot.js, replacing the do_beers function. The karma database object should be a member of the ecmabot, not global for all of shared.js. I'd recommend something like the following in ecmabot.js. ecmabot-karma.json would be a good name because it keeps things organized.

this.karma_db = new JSONSaver(path.join(__dirname, "ecmabot-karma.json"));
this.register_listener (/^(\w+)(\+\+|--)$/i, this.karma);

Also, the karma function should do nothing if the nick is not currently in the channel, since many users may do things like es6++ or something just to show their appreciation for something.

if (![nick])

@eboyjr Hmm at first I had the idea of doing this.register_listener (/^(\w+)(\+\+|--)$/i, this.karma); but we disccused and decided to be in shared.js :cactus: Anyway changing this is not a tough task. Any specific reason why it must not be in shared?


Here is the plan :

  • Make a gods.json these are the ones who can blacklist nicks.

  • Avoid printing karma and show karma for !karma nick.

  • Weight of karma needs some more planning?


you can query chanserv to ask for the channel ops access list.
/msg chanserv access ##javascript list

also, you should only let people in the channel change karma, though, the channel is +n, so, people outside the channel can't send to it.


I think the weight idea is overly complex. My philosophy is Keep It Simple, Sally.

What's your opinion of allowing current channel operators to blacklist users?
Also, why the vacuity about only allowing people in the channel change karma if the channel is +n?

The API for finding operators is the boolean value of channel.userlist[nick].operator, given we know the user is in the channel.


@gkatsev @eboyjr

Most importantly the user should not ++/-- his/her own karma!


you can let them -- their own karma. Just don't let them ++ it.


How would they un-- (i.e. ++) themselves?


They wouldn't.

@dsamarin dsamarin closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 10, 2013
  1. @hemanth
  2. @hemanth
  3. @hemanth

    Removed unwanted logs and msgs.

    hemanth authored
    Sorry for multiple commits.
  4. @hemanth
  5. @hemanth

    Cleared old karma

    hemanth authored
This page is out of date. Refresh to see the latest.
Showing with 24 additions and 1 deletion.
  1. +2 −0  ecmabot.js
  2. +1 −0  karma.json
  3. +21 −1 shared.js
2  ecmabot.js
@@ -30,6 +30,8 @@ JSBot.prototype.init = function() {
this.register_listener(/^((?:sm?|v8?|js?|>>?)>)([^>].*)+/, Shared.execute_js);
//this.register_listener(/^(\S+)(\+\+|--);?$/, this.do_beers);
+ this.register_listener (/^(\w+)(\+\+|--)$/i, Shared.karma);
this.register_listener(/\bi(?:\u0027| wi)?ll try\b/i,
1  karma.json
@@ -0,0 +1 @@
+{"karma": {}}
22 shared.js
@@ -1,6 +1,10 @@
// This is for common functions defined in many bots at once
var Sandbox = require("./lib/sandbox");
var FeelingLucky = require("./lib/feelinglucky");
+var JSONSaver = require("./lib/jsonsaver");
+var path = require('path');
+var karma_db = new JSONSaver(path.join(__dirname,"karma.json"));
function parse_regex_literal (text) {
var regexparsed = text.match(/s\/((?:[^\\\/]|\\.)*)\/((?:[^\\\/]|\\.)*)\/([gi]*)$/);
@@ -237,7 +241,23 @@ var Shared = module.exports = {
.send("TOPIC "" "+topic);
- }
+ },
+ karma: function (context, text, nick, action) {
+ karma_db.instantwrite = true;
+ karma_db.wait = 0;
+ nick = nick.toLowerCase();
+ kurma = karma_db.object.karma;
+ if (typeof kurma[nick] !== "undefined") {
+ kurma[nick].karma = (action === "++" ? kurma[nick].karma + 1 : kurma[nick].karma - 1);
+ } else {
+ kurma[nick] = {
+ name: nick,
+ karma: 0
+ };
+ }
+ karma_db.activity();
+, "Karma for " + nick + " : " + kurma[nick].karma);
Something went wrong with that request. Please try again.