Skip to content

Implement message logging from main chat to logging chat - #330

Open
konard wants to merge 4 commits into
mainfrom
issue-57-af4f56b0
Open

Implement message logging from main chat to logging chat#330
konard wants to merge 4 commits into
mainfrom
issue-57-af4f56b0

Conversation

@konard

@konard konard commented Sep 13, 2025

Copy link
Copy Markdown
Member

Summary

  • Implements message forwarding functionality for the VK bot to log all messages from specified main chats to a dedicated logging chat
  • Adds comprehensive configuration options and safety measures

Changes Made

  • Configuration: Added MAIN_CHATS and LOGGING_CHAT_ID settings in config.py
  • Core Functionality: Implemented _forward_message_to_logging_chat() method in the Bot class
  • Chat Metadata: Added _get_chat_title() helper to resolve chat names for better log formatting
  • Message Formatting: Creates structured log entries with timestamp, chat title, user name, and content
  • Attachment Handling: Logs attachment types without exposing actual content
  • Special Messages: Handles forwarded messages and replies with appropriate indicators
  • Safety Features: Prevents bot message loops and handles API errors gracefully
  • Documentation: Added comprehensive setup and usage guide in MESSAGE_LOGGING.md

Key Features

✅ Forwards messages only from configured main chats
✅ Rich log format with timestamps and metadata
✅ Attachment type logging (preserves privacy)
✅ Forwarded message and reply indicators
✅ Error handling and infinite loop prevention
✅ Easy configuration via config variables

Configuration Required

Users need to set:

MAIN_CHATS = [2000000001, 2000000011]  # Chat IDs to monitor
LOGGING_CHAT_ID = 2000000020           # Where to send logs

Testing

  • Code compiles without syntax errors
  • Includes comprehensive test suite (requires dependencies)
  • Safety checks prevent common issues like infinite loops

Fixes #57

🤖 Generated with Claude Code

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

Issue: #57
@konard konard self-assigned this Sep 13, 2025
- Add configuration options for main chats and logging chat in config.py
- Implement message forwarding functionality in Bot._forward_message_to_logging_chat()
- Add chat title resolution for better log formatting
- Include comprehensive message metadata (timestamp, user, attachments, etc.)
- Add safety checks to prevent infinite loops and handle errors gracefully
- Add documentation for configuration and usage

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

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard changed the title [WIP] Log all messages from main chat to logging chat Implement message logging from main chat to logging chat Sep 13, 2025
@konard
konard marked this pull request as ready for review September 13, 2025 23:38
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>'
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.

Log all messages from main chat to logging chat

1 participant