Skip to content

Conversation

@Picsou06
Copy link

@Picsou06 Picsou06 commented Sep 8, 2025

Add list functionality to logger

Description

This pull request adds the ability to use multiple instances of notification services simultaneously in the logger. Instead of being limited to a single service per type, users can now configure multiple destinations for each notification service.

Changes Made

📋 Features Added

  • Multi-instance support: All notification services (Telegram, Discord, Webhook, Matrix, Pushover, and Gotify) now support multiple instances
  • Configuration flexibility: Ability to use either a single object or a list of objects for each service
  • Targeted sending: Different events can be sent to different destinations by configuring distinct event lists for each instance

🔧 Technical Modifications

logger.py

  • Added Union, List import for typing
  • Modified LoggerSettings constructor parameters to accept Union[ServiceType, List[ServiceType], None]
  • Implemented _normalize_to_list() method to normalize inputs to lists
  • Updated all notification methods to iterate over instance lists

README.md

  • Updated documentation to reflect new multi-instance support
  • Added "Multiple Notification Support" section explaining new capabilities
  • Updated descriptions for all notification services

example.py

  • Added concrete examples showing how to use the new features
  • Demonstration of configurations with multiple Discord instances and webhooks
  • Examples of targeting specific events to different destinations

Usage Examples

Single service configuration

telegram=Telegram(chat_id=123456789, token="...")

Multiple services configuration

telegram=[
    Telegram(chat_id=123456789, token="...", events=[Events.STREAMER_ONLINE]),
    Telegram(chat_id=987654321, token="...", events=[Events.BET_LOSE])
]

Mixed configuration

telegram=Telegram(...),  # Single Telegram
discord=[Discord(...), Discord(...)],  # Multiple Discord

Benefits

  • Notification separation: Send different event types to different channels/users
  • Redundancy: Use multiple services to ensure delivery of important notifications
  • Organization: Separate notifications by importance or team
  • Backward compatibility: Existing configurations continue to work without modification

Testing

  • ✅ Verified backward compatibility with existing configurations
  • ✅ Tested proper functionality with single objects
  • ✅ Tested proper functionality with object lists
  • ✅ Validated sending to all configured instances

Notes

This feature addresses a community-expressed need to segment and organize notifications according to different criteria. It maintains ease of use while offering increased flexibility for advanced configurations.

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.

1 participant