Skip to content

Conversation

@konard
Copy link
Member

@konard konard commented Sep 14, 2025

🎯 Summary

This PR implements a chat-specific karma system to address issue #8 "Should the rating be splited in different chats?".

Previously, the VK bot used a global karma system where users had a single karma score across all chats. Now users have separate karma scores for each chat, making ratings truly chat-specific.

🔧 Key Changes

Data Structure Migration

  • Before: karma: 10 (global integer)
  • After: karma: {2000000001: 10, 2000000002: -2} (per-chat dictionary)

Same approach applied to supporters and opponents arrays.

Core Features

  • Chat-specific karma: Each user has separate karma per chat
  • Isolated voting: Votes in one chat don't affect karma in other chats
  • Chat-specific rankings: Top lists show karma specific to current chat
  • Backward compatibility: Existing global karma data migrates automatically
  • Seamless transition: Old and new formats work during migration

Modified Files

  • python/modules/data_service.py: Added chat-specific karma/supporters/opponents methods
  • python/modules/data_builder.py: Updated karma calculations for chat-specific data
  • python/modules/commands_builder.py: Updated message builders to use chat-specific karma
  • python/modules/commands.py: Updated karma commands to use chat-specific data

🧪 Testing

  • ✅ Implementation logic validated with test scripts
  • ✅ Python syntax verified across all modified files
  • ✅ Backward compatibility confirmed for existing data
  • ✅ Migration path tested for old integer karma format

🔄 Migration Strategy

The implementation automatically handles migration:

  1. New users: Start with empty karma dictionaries
  2. Existing users with zero karma: Migrate to empty dictionary
  3. Existing users with karma: Migrate integer to {current_chat: karma_value}
  4. Mixed scenarios: Support both formats during transition

📋 Examples

Before (Global Karma)

User A: karma=10 everywhere
Chat 1 ranking: User A [10]
Chat 2 ranking: User A [10]  

After (Chat-Specific Karma)

User A: karma={chat1: 15, chat2: -3}
Chat 1 ranking: User A [15]
Chat 2 ranking: User A [-3]

✅ Answer to Issue #8

Question: "Should the rating be splited in different chats?"
Answer: YES - This PR implements exactly that! Ratings are now split across different chats, giving users separate karma scores per chat.


🤖 Generated with Claude Code


Resolves #8

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #8
@konard konard self-assigned this Sep 14, 2025
This commit addresses issue #8 "Should the rating be splited in different chats?"
by implementing a chat-specific karma system instead of the previous global karma.

## Key Changes

### Data Structure Changes
- Modified karma storage from `karma: 0` to `karma: {chat_id: karma_value}`
- Modified supporters from `supporters: []` to `supporters: {chat_id: [user_ids]}`
- Modified opponents from `opponents: []` to `opponents: {chat_id: [user_ids]}`

### New Features
- Users now have separate karma scores for each chat
- Voting in one chat doesn't affect karma in other chats
- Rankings show chat-specific karma instead of global karma
- Backward compatibility with existing global karma data

### Modified Files
- `data_service.py`: Added chat-specific karma, supporters, opponents methods
- `data_builder.py`: Updated karma calculation and display for chat-specific data
- `commands_builder.py`: Updated message builders to use chat-specific karma
- `commands.py`: Updated all karma-related commands to use chat-specific data

### Backward Compatibility
- Automatically migrates old integer karma to new dict format
- Supports both old and new data formats during transition
- Existing data remains functional while gaining new chat-specific features

### Testing
- Added validation scripts to verify implementation logic
- Confirmed Python syntax validity across all modified files

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard changed the title [WIP] Should the rating be splited in different chats? Implement chat-specific karma system Sep 14, 2025
@konard konard marked this pull request as ready for review September 14, 2025 03:55
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.

Should the rating be splited in different chats?

2 participants