Skip to content

Conversation

@konard
Copy link
Member

@konard konard commented Sep 14, 2025

Summary

Added functionality to show user's top ranking position in the VK bot info command as requested in issue #42.

Changes Made

  • New Function: Added get_user_top_position() method to DataBuilder class that calculates a user's ranking position based on karma sorting
  • Enhanced Info Message: Updated build_info_message() in CommandsBuilder to include top position when:
    • Karma is enabled in the chat
    • User is in a group chat (peer_id > 2e9)
    • VK instance is available for ranking calculation
  • Updated Command Handler: Modified info_message() method in Commands class to pass required parameters
  • Test Scripts: Added experiment scripts to verify the ranking logic works correctly

Example Output

Before: User123, Ваша карма - [85][+2.0-1.0].
After: User123, Ваша карма - [85][+2.0-1.0] (место в топе: 3).

Technical Details

  • Uses the same ranking logic as the existing top command (sorted by real karma)
  • Filters users the same way as top command (excludes users with 0 karma AND no programming languages)
  • Position is 1-based (1st place, 2nd place, etc.)
  • Returns 0 if user is not found in ranking
  • Only displays position in group chats with karma enabled

Test Plan

  • Added logic verification tests in experiments/test_logic.py
  • Syntax checking passes for all modified Python files
  • Position calculation correctly handles edge cases (user not in ranking, filtered users)
  • Info message properly includes position only when appropriate conditions are met

Fixes #42

🤖 Generated with Claude Code

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

Issue: #42
@konard konard self-assigned this Sep 14, 2025
- Added get_user_top_position method to DataBuilder to calculate user's ranking position
- Updated build_info_message to include top position when karma is enabled in group chats
- Modified info_message method to pass required parameters for position calculation
- Added experiments folder with test scripts to verify functionality
- Position is only shown in group chats (peer_id > 2e9) when karma is enabled

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

Co-Authored-By: Claude <[email protected]>
@konard konard changed the title [WIP] Add top place number to info Add top place number to VK bot info command Sep 14, 2025
@konard konard marked this pull request as ready for review September 14, 2025 00:54
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.

Add top place number to info

2 participants