Skip to content

Externalize Notification Templates #12

@LXSCA7

Description

@LXSCA7

Following the standardization of internal logs and error messages to English in PR #11, user-facing notifications (Telegram, Gotify) were also affected. To ensure GOrimpo remains user-friendly for people in different regions and to allow customization without recompiling the binary, we need to move these message templates to the configuration file.

Proposal:
Implement a new templates section in config.yaml that allows users to define their own notification formats using Go's native template syntax.

Expected Configuration Example:

# config.yaml
notifier:
  templates:
    new_offer: "💎 <b>New offer found!</b>\n\n📌 {{.Title}}\n💰 {{.Price}}\n\n🔗 {{.Link}}"
    circuit_breaker: "🚧 <b>CIRCUIT BREAKER!</b>\nSystem is cooling down for {{.Cooldown}}."
    error: "❌ <b>Scraper Error:</b> {{.Error}}"

Technical Requirements:

  1. Automatic Fallback: If the templates section is missing from the YAML, the system must use the current hardcoded English strings as a default.
  2. Supported Fields: Provide initial support for:
    • {{.Title}}: Offer title.
    • {{.Price}}: Formatted price.
    • {{.Link}}: Offer URL.
    • {{.Date}}: Posting date.
    • {{.Cooldown}}: Circuit Breaker wait time.
    • {{.Error}}: Scraper error message.
  3. Implementation: Use Go's text/template or html/template package within the Core or Notification Adapters to parse and execute the templates before sending.

Why is this important?
This significantly improves GOrimpo's UX, allowing every user to give the bot a personality, using emojis, slang, or other languages, in a purely declarative way

Implementation Hints (Good First Issue)

  • Check internal/adapters/config/ to see how we parse the YAML.
  • Take a look at internal/adapters/notifier/telegram.go (or Gotify). That's where the magic happens.
  • You'll likely need to use the text/template package from the Go standard library.
  • Remember to define a constant for the default templates to ensure the fallback works!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions