Skip to content

Conversation

@konard
Copy link
Member

@konard konard commented Sep 14, 2025

Summary

This PR implements enhanced auto-update capabilities for user profiles to solve issue #48. The implementation provides comprehensive automatic profile updating with multiple new features and commands.

✨ New Features

🔄 Enhanced Individual Profile Updates

  • Command: обновить / update
  • Comprehensive VK API integration with extended fields
  • Auto-detection of GitHub profiles from VK site field
  • Auto-detection of programming languages from activities/about sections
  • Detailed feedback showing exactly what fields were updated

👥 Bulk Profile Updates (Admin Feature)

  • Command: обновить всех / update all
  • Mass update all users in a chat (requires admin privileges or karma 50+)
  • Respects individual user auto-update preferences
  • Provides summary statistics of processed/updated users
  • Available only in group chats for security

⚙️ Auto-Update User Preferences

  • Commands: автообновление вкл/выкл / auto-update on/off
  • Users can control their automatic profile updates
  • Check current auto-update status
  • Persistent settings storage in user database

🕒 Periodic Background Auto-Updates

  • Automatic background updates every 6 hours
  • Only updates profiles not updated in 24+ hours
  • Rate-limited to 10 users per cycle to respect API limits
  • Comprehensive error handling and logging

🔧 Technical Implementation

New Command Patterns

UPDATE_ALL = recompile(r'\A\s*(обновить всех|update all)\s*\Z', IGNORECASE)
AUTO_UPDATE = recompile(r'\A\s*(авто[- ]?обновление|auto[- ]?update)\s+(вкл|on|выкл|off)\s*\Z', IGNORECASE)

Enhanced VK API Integration

  • Extended fields for comprehensive profile data collection
  • Smart GitHub profile detection and validation
  • Programming language detection supporting 100+ languages
  • Name synchronization with VK API changes

New Database Fields

  • auto_update_enabled (boolean): User preference for automatic updates
  • last_auto_update (timestamp): Tracks when profile was last auto-updated

Security & Performance Features

  • Admin privilege verification for bulk operations
  • API rate limiting and comprehensive error handling
  • User privacy controls and opt-out capabilities
  • Graceful handling of VK API failures

📝 Files Modified

  • python/patterns.py: New command patterns for auto-update features
  • python/__main__.py: Periodic update mechanism integration
  • python/modules/commands.py: Enhanced update logic and new command handlers
  • python/modules/data_service.py: New user profile fields
  • python/modules/commands_builder.py: Updated help messages with new commands

🧪 Testing & Validation

Comprehensive Tests Provided

  • Pattern matching validation for all new commands
  • GitHub profile URL detection logic testing
  • Programming language detection verification
  • Integration tests for the complete workflow

Example Usage Documentation

  • Complete usage examples in examples/auto_update_usage.md
  • Test scripts in experiments/ directory
  • Detailed technical documentation

🚀 User Experience Improvements

Enhanced Help Messages

The bot now displays helpful auto-update commands:

🔄 Команды обновления профиля:
• обновить/update — обновить свой профиль
• обновить всех/update all — массовое обновление (для админов)
• автообновление вкл/выкл — управление автообновлением

Smart Auto-Detection Examples

  • GitHub: VK site "https://github.com/username" → GitHub profile: "username"
  • Languages: VK activities "Coding in Python and JavaScript" → Adds Python, JavaScript
  • Name sync: Automatic synchronization when users change their VK names

🔒 Migration & Backward Compatibility

  • Existing users automatically get auto_update_enabled = True (opt-in by default)
  • All existing functionality remains unchanged
  • New features are additive and don't break existing workflows
  • Graceful degradation if VK API is unavailable

Test plan

  • Test new command patterns with regex validation
  • Test GitHub profile detection with various URL formats
  • Test programming language detection logic
  • Verify database schema updates work correctly
  • Test error handling for API failures
  • Validate admin privilege checking for bulk operations
  • Test help message updates display correctly

🤖 Generated with Claude Code


Resolves #48

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

Issue: #48
@konard konard self-assigned this Sep 14, 2025
This commit implements enhanced auto-update capabilities for user profiles as requested in issue #48.

## New Features:

### 1. Enhanced Individual Profile Updates
- Comprehensive VK API integration with extended fields
- Auto-detection of GitHub profiles from VK site field
- Auto-detection of programming languages from activities/about sections
- Detailed feedback on updated fields

### 2. Bulk Profile Updates (Admin Feature)
- Mass update all users in a chat (admin/high-karma only)
- Respects individual user auto-update preferences
- Provides summary statistics

### 3. Auto-Update Preferences
- Users can enable/disable automatic profile updates
- New commands: автообновление вкл/выкл, auto-update on/off
- Persistent setting storage

### 4. Periodic Auto-Updates
- Automatic background updates every 6 hours
- Only updates profiles not updated in 24+ hours
- Rate-limited to 10 users per cycle
- Comprehensive error handling

## Technical Implementation:

### New Patterns:
- UPDATE_ALL: Mass update command
- AUTO_UPDATE: Toggle auto-update preferences

### Enhanced Data Storage:
- auto_update_enabled: Boolean preference
- last_auto_update: Timestamp tracking

### Improved VK API Usage:
- Extended fields for comprehensive profile data
- GitHub profile validation before updating
- Smart language detection with 100+ supported languages

### Security & Performance:
- Admin privilege checks for bulk operations
- API rate limiting and error handling
- User privacy controls

## Files Modified:
- python/patterns.py: New command patterns
- python/__main__.py: Periodic update mechanism
- python/modules/commands.py: Enhanced update logic
- python/modules/data_service.py: New user fields
- python/modules/commands_builder.py: Updated help messages

## Testing:
- Comprehensive pattern matching tests
- GitHub profile detection validation
- Language detection logic verification
- Examples and documentation provided

Fixes #48

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

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard changed the title [WIP] Auto-update changes in user profiles Implement comprehensive auto-update functionality for user profiles Sep 14, 2025
@konard konard marked this pull request as ready for review September 14, 2025 00:41
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.

Auto-update changes in user profiles

2 participants