From b625900edcf1c0da3306f67027ce621a6661f998 Mon Sep 17 00:00:00 2001 From: Aleksandr <67836333+fedorov0av@users.noreply.github.com> Date: Fri, 14 Nov 2025 14:12:57 +0300 Subject: [PATCH] feat: add multi-user support for Telegram notifications --- plugin.go | 158 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 87 insertions(+), 71 deletions(-) diff --git a/plugin.go b/plugin.go index 8f94539..1f68f47 100644 --- a/plugin.go +++ b/plugin.go @@ -8,6 +8,7 @@ import ( "net/http" "net/http/httputil" "os" + "strings" "time" "github.com/gotify/plugin-api" @@ -17,31 +18,31 @@ import ( // GetGotifyPluginInfo returns gotify plugin info func GetGotifyPluginInfo() plugin.Info { return plugin.Info{ - Version: "1.0", - Author: "Anh Bui", - Name: "Gotify 2 Telegram", - Description: "Telegram message fowarder for gotify", - ModulePath: "https://github.com/anhbh310/gotify2telegram", + Version: "1.0", + Author: "Anh Bui", + Name: "Gotify 2 Telegram", + Description: "Telegram message forwarder for gotify", + ModulePath: "https://github.com/anhbh310/gotify2telegram", } } // Plugin is the plugin instance type Plugin struct { - ws *websocket.Conn; - msgHandler plugin.MessageHandler; - debugLogger *log.Logger; - chatid string; - telegram_bot_token string; - gotify_host string; + ws *websocket.Conn + msgHandler plugin.MessageHandler + debugLogger *log.Logger + chatids []string + telegram_bot_token string + gotify_host string } type GotifyMessage struct { - Id uint32; - Appid uint32; - Message string; - Title string; - Priority uint32; - Date string; + Id uint32 + Appid uint32 + Message string + Title string + Priority uint32 + Date string } type Payload struct { @@ -51,63 +52,74 @@ type Payload struct { func (p *Plugin) send_msg_to_telegram(msg string) { step_size := 4090 - sending_message := "" - - for i:=0; i