Skip to content

Conversation

@konard
Copy link
Member

@konard konard commented Sep 12, 2025

Summary

Implements automatic karma-based chat membership management as requested in issue #131.

Features

  • 🔄 Automatic membership management: Users are automatically added to/removed from chats based on karma levels
  • ⚙️ Configurable thresholds: Support for multiple chats with different karma requirements
  • 🎯 Real-time updates: Membership changes trigger immediately when karma changes
  • 🛠️ Management commands: Manual controls for admins and status checking
  • 📊 Comprehensive logging: All membership changes are logged for monitoring

How it works

  1. Configuration: Define chat IDs and karma thresholds in config.py
  2. Automatic triggers: When a user's karma changes (via +/- commands), the system:
    • Checks their new karma level
    • For each configured chat, determines if they should be a member
    • Adds them if they meet the threshold but aren't in the chat
    • Removes them if they don't meet the threshold but are in the chat
  3. Manual commands: Users and admins can trigger membership checks manually

Configuration Example

KARMA_BASED_CHATS = [
    {
        "chat_id": 2000000001,  # Chat where users should be managed
        "karma_threshold": 2,   # Minimum karma required
        "name": "Main Chat"     # Optional name for logging
    },
    {
        "chat_id": 2000000002,
        "karma_threshold": 10,
        "name": "Advanced Chat"
    }
]

Available Commands

  • check chat membership - Check your membership in all karma chats
  • check all membership - Admin command to check all users (resource intensive)
  • chat status - Show status of current chat
  • chat status [chat_id] - Show status of specific chat

Technical Implementation

  • New module: modules/chat_membership.py containing KarmaChatManager
  • Integration: Hooks into existing karma system in Commands.apply_karma()
  • Error handling: Robust error handling for VK API failures
  • Performance: Efficient membership checks with logging
  • Testing: Comprehensive test suite and usage examples included

Files Changed

  • python/config.py - Added karma chat configuration
  • python/modules/chat_membership.py - New membership manager
  • python/modules/commands.py - Added hooks and management commands
  • python/__main__.py - Integration with main bot
  • python/patterns.py - New command patterns
  • examples/karma_chat_usage_example.py - Usage examples
  • python/test_karma_chat.py - Test suite

Test plan

  • ✅ Code compiles without syntax errors
  • ✅ All new modules import correctly
  • ✅ Command patterns match expected inputs
  • ✅ Configuration structure is valid
  • ✅ Example scenarios demonstrate expected behavior
  • 🔄 Manual testing with real VK API (requires live bot instance)
  • 🔄 Load testing with multiple users (requires production environment)

Note: Full integration testing requires a live VK bot instance with proper API tokens and chat permissions.

🤖 Generated with Claude Code


Resolves #131

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

Issue: #131
@konard konard self-assigned this Sep 12, 2025
- Add configuration for karma-based chats with customizable thresholds
- Create KarmaChatManager class to handle automatic member management
- Hook into karma changes to automatically add/remove users from chats
- Add management commands for manual membership checks and status
- Include comprehensive tests and usage examples
- Support multiple chats with different karma requirements

Addresses issue #131: Users are automatically added to chats when karma ≥ 2
and removed when karma < 2. System is configurable for any karma threshold
and supports multiple chats with different levels.

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

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard changed the title [WIP] Automatically add and remove people to and from chat with 2+ karma Implement automatic karma-based chat membership management Sep 12, 2025
@konard konard marked this pull request as ready for review September 12, 2025 22:04
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.

Automatically add and remove people to and from chat with 2+ karma

2 participants