feat(im): add Telegram platform integration

Add Telegram Bot API adapter supporting both webhook and long-polling
modes with streaming replies via editMessageText, file download via
getFile API, and timing-safe secret token verification.
This commit is contained in:
nullkey
2026-03-24 16:48:13 +08:00
committed by lyingbug
parent f0c6d0752a
commit aea0a97be3
12 changed files with 625 additions and 12 deletions
+5 -2
View File
@@ -11,6 +11,9 @@ import (
"github.com/gin-gonic/gin"
)
// validIMPlatforms is the set of supported IM platforms.
var validIMPlatforms = map[string]bool{"wecom": true, "feishu": true, "slack": true, "telegram": true}
// IMHandler handles IM platform callback requests and channel CRUD.
type IMHandler struct {
imService *im.Service
@@ -53,8 +56,8 @@ func (h *IMHandler) CreateIMChannel(c *gin.Context) {
return
}
if req.Platform != "wecom" && req.Platform != "feishu" && req.Platform != "slack" {
c.JSON(http.StatusBadRequest, gin.H{"error": "platform must be 'wecom', 'feishu' or 'slack'"})
if !validIMPlatforms[req.Platform] {
c.JSON(http.StatusBadRequest, gin.H{"error": "platform must be 'wecom', 'feishu', 'slack' or 'telegram'"})
return
}