update: tg bot

This commit is contained in:
Kerwin
2025-09-19 18:37:50 +08:00
parent 982e4f942e
commit a24d32776c
7 changed files with 450 additions and 61 deletions

View File

@@ -200,7 +200,7 @@ func (h *TelegramHandler) UpdateChannel(c *gin.Context) {
return
}
var req dto.TelegramChannelRequest
var req dto.TelegramChannelUpdateRequest
if err := c.ShouldBindJSON(&req); err != nil {
ErrorResponse(c, "请求参数错误", http.StatusBadRequest)
return
@@ -213,6 +213,12 @@ func (h *TelegramHandler) UpdateChannel(c *gin.Context) {
return
}
// 如果前端传递了ChatID验证它是否与现有频道匹配
if req.ChatID != 0 && req.ChatID != channel.ChatID {
ErrorResponse(c, "ChatID不匹配无法更新此频道", http.StatusBadRequest)
return
}
// 更新频道信息
channel.ChatName = req.ChatName
channel.ChatType = req.ChatType
@@ -276,7 +282,7 @@ func (h *TelegramHandler) RegisterChannelByCommand(chatID int64, chatName, chatT
ChatName: chatName,
ChatType: chatType,
PushEnabled: true,
PushFrequency: 24, // 默认24小时
PushFrequency: 5, // 默认5分钟
IsActive: true,
RegisteredBy: "bot_command",
}