Skip to content

Conversation

@konard
Copy link
Member

@konard konard commented Sep 14, 2025

🤖 AI-Powered Solution

This pull request implements the daily message limiting feature requested in issue #17.

📋 Issue Reference

Fixes #17

🎯 Implementation Summary

This implementation adds karma-based message limiting to the VK bot with the following features:

✅ Message Limits by Karma Level

  • No limit: karma > -10
  • 64 messages/day: karma ≤ -10 and > -20
  • 32 messages/day: karma ≤ -20 and > -40
  • 16 messages/day: karma ≤ -40 and > -80
  • 8 messages/day: karma ≤ -80 and > -160
  • 4 messages/day: karma ≤ -160 and > -320
  • 2 messages/day: karma ≤ -320 and > -640
  • 1 message/day: karma ≤ -640 and > -1280
  • Read-only mode: karma ≤ -1280 (0 messages/day)

🔧 Technical Details

Data Model Changes (python/modules/data_service.py):

  • Added daily_message_count field to track messages per day
  • Added last_message_date field to reset daily counts

Message Limiting Logic (python/__main__.py):

  • Checks karma level for each message in group chats
  • Resets daily counter when date changes
  • Blocks messages and notifies users when limits are exceeded
  • Deletes violating messages automatically

Utility Functions (python/modules/utils.py):

  • Added get_daily_message_limit() function with karma-based logic
  • Comprehensive test coverage with boundary condition validation

🧪 Testing

The implementation includes comprehensive tests:

  • experiments/test_message_limits_simple.py: Standalone test suite
  • Tests all karma boundary conditions
  • Validates message limits for each karma range
  • All 26 test cases pass ✅

🚦 Behavior

  1. Group Chat Only: Limits apply only to group chats (peer_id >= 2e9)
  2. Daily Reset: Message counters reset at midnight
  3. Immediate Feedback: Users receive notifications when limits are exceeded
  4. Message Deletion: Violating messages are automatically deleted
  5. Read-Only Mode: Users with karma ≤ -1280 cannot send any messages

This PR was implemented automatically by the AI issue solver

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

Issue: #17
@konard konard self-assigned this Sep 14, 2025
* Add daily message count tracking to user data model
* Create message limit function based on karma thresholds:
  - No limit for karma > -10
  - 64 messages for karma ≤ -10 and > -20
  - 32 messages for karma ≤ -20 and > -40
  - 16 messages for karma ≤ -40 and > -80
  - 8 messages for karma ≤ -80 and > -160
  - 4 messages for karma ≤ -160 and > -320
  - 2 messages for karma ≤ -320 and > -640
  - 1 message for karma ≤ -640 and > -1280
  - Read-only mode (0 messages) for karma ≤ -1280
* Add message limiting logic to main bot handler
* Include comprehensive test suite

Fixes #17

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

Co-Authored-By: Claude <[email protected]>
@konard konard changed the title [WIP] Limit amount of messages from user per day if reputation (karma) is less than -10 Implement daily message limiting based on karma levels Sep 14, 2025
@konard konard marked this pull request as ready for review September 14, 2025 03:25
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.

Limit amount of messages from user per day if reputation (karma) is less than -10

2 participants