Skip to content

Karma: track per-user votes to prevent double voting - #1680

Open
costelEN wants to merge 4 commits into
progval:masterfrom
costelEN:fix/issue-207-karma-vote-tracking
Open

Karma: track per-user votes to prevent double voting#1680
costelEN wants to merge 4 commits into
progval:masterfrom
costelEN:fix/issue-207-karma-vote-tracking

Conversation

@costelEN

@costelEN costelEN commented Sep 5, 2026

Copy link
Copy Markdown

Closes #207

Automated fix. Tests ran in CI on the fork.

Generated by autonomous agent Goose, supervised by costelEN.

…gval#207) - Add karma_votes table to track user votes per thing per channel - increment/decrement check existing user vote: same direction ignore, opposite direction flip vote, no prior vote record new vote - Include user nick in increment/decrement calls - Update clear() to also clear user votes - Generated by autonomous agent Goose, supervised by costelEN.
Comment thread plugins/Karma/plugin.py Outdated
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions, and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# documentation and/or materials provided with the distribution.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the license text is a no-no. This needs to be reverted.

Comment thread plugins/Karma/plugin.py Outdated
If ``config plugins.karma.allowUnaddressedKarma` is set to `False``, you
must address the bot with nick or prefix to add or subtract karma.

Each user can only vote once per thing. A second vote in the same

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new behaviour ought to be configurable; I've seen plenty channels where Karma is allowed to accumulate over time. Also new test cases need to be added for this.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, it's a major feature.

I don't even see the point of the Karma plugin without it. @costelEN you probably want the Poll plugin instead of Karma for this use-case.

Comment thread plugins/Karma/plugin.py Outdated
return True

def decrement(self, channel, name):
def decrement(self, channel, name, user):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

increment() and decrement() can probably be in one function to avoid duplicating code - just pass in the desired vote as a parameter.

Comment thread plugins/Karma/plugin.py Outdated
self.db.increment(channel, self._normalizeThing(thing))
karma = self.db.get(channel, self._normalizeThing(thing))
result = self.db.increment(channel, self._normalizeThing(thing), msg.nick)
if result is not False:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if result is not False:
if not result:

Comment thread plugins/Karma/plugin.py Outdated
self.db.decrement(channel, self._normalizeThing(thing))
karma = self.db.get(channel, self._normalizeThing(thing))
result = self.db.decrement(channel, self._normalizeThing(thing), msg.nick)
if result is not False:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if result is not False:
if not result:

Comment thread plugins/Karma/plugin.py Outdated
(channel, user.lower(), thing.lower(), vote))
db.commit()

def _deleteUserVote(self, channel, user, thing):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function isn't used?

@jlu5 jlu5 changed the title fix: #207 (automated) Karma: track per-user votes to prevent double voting Sep 5, 2026
Goose Agent added 3 commits September 6, 2026 00:10
…gval#207) - Add karma_votes table to track user votes per thing per channel - Add trackUserVotes config option (default False for backward compatibility) - Refactor increment/decrement into single _vote() method - Fix duplicate vote handling: same direction ignored, opposite flips vote - Update clear() to also clear user votes - Add comprehensive tests for trackUserVotes behavior - Fix license header (revert to original) - Fix 'if result is not False:' to 'if not result:' - Generated by autonomous agent Goose, supervised by costelEN.
…tUp - Tests use assertNoResponse which expects no reply. With response=True, bot replies 'X's karma is now Y' causing false failures. - response stays at default False (matching original test behavior).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Karma: A single user can increment a thing multiple times

3 participants