containrrr / shoutrrr

Notification library for gophers and their furry friends.
https://containrrr.dev/shoutrrr/
MIT License
904 stars 61 forks source link

Support custom Telegram API base? #257

Open gouku opened 2 years ago

gouku commented 2 years ago

In some scenario there's no way to access Telegram API https://api.telegram.org/bot directly. It would be great to have an option to customize the API base of it. ie. A custom proxy url that can bypass the firewall limitation https://my-private-tg-proxy.tld/bot.

piksel commented 2 years ago

This would also allow for testing with a custom API server: https://github.com/tdlib/telegram-bot-api

leic4u commented 1 week ago

I build a reverse proxy for api.telegram.org, and I try to send notification by Generic service.

So that I could send to my telegram bot with https://mydomain.com/bot1234567890:AQQJ_QHs6RD7in3IbdMLfZizJ_6RrKqJOS2/sendmessage?chat_id=987654321

I followed the guide of shoutrrr generic to , but it doesn't work.

It's my WATCHTOWER_NOTIFICATION_URL configuration, do you know what's wrong with it?

WATCHTOWER_NOTIFICATION_URL:
    generic://mydomain.com/bot1234567890:AQQJ_QHs6RD7in3IbdMLfZizJ_6RrKqJOS2/sendmessage?_chat_id=987654321&MessageKey=text
leic4u commented 1 week ago

I have sent notifications to telegram bot through reverse proxy of api.telegram.org with config like this:

    environment:
      WATCHTOWER_MONITOR_ONLY: 'false'
      WATCHTOWER_NOTIFICATIONS_HOSTNAME: 'MyVPS'
      WATCHTOWER_POLL_INTERVAL: 36000
      WATCHTOWER_NOTIFICATION_URL: 
        generic://api.mydomain.com/bot123456789%3ABBEJ_QHd5JI6in3IbpNisSQyX_2TpJdNSD3/sendmessage
      WATCHTOWER_NOTIFICATION_TEMPLATE:
        '{{if .}}{"text":"{{range .}}{{.Message}}\n{{end}}","chat_id":"123456789"}{{end}}'

PS: It seems that should make %3A to be instead of : in the bot token.

Thanks to @Austinsuyoyo in https://github.com/containrrr/shoutrrr/discussions/316#discussioncomment-4832057