mirror of
https://github.com/ctwj/urldb.git
synced 2025-11-25 03:15:04 +08:00
update: tg bot
This commit is contained in:
@@ -2,7 +2,7 @@ package dto
|
||||
|
||||
import "time"
|
||||
|
||||
// TelegramChannelRequest 创建/更新 Telegram 频道/群组请求
|
||||
// TelegramChannelRequest 创建 Telegram 频道/群组请求
|
||||
type TelegramChannelRequest struct {
|
||||
ChatID int64 `json:"chat_id" binding:"required"`
|
||||
ChatName string `json:"chat_name" binding:"required"`
|
||||
@@ -16,6 +16,20 @@ type TelegramChannelRequest struct {
|
||||
IsActive bool `json:"is_active"`
|
||||
}
|
||||
|
||||
// TelegramChannelUpdateRequest 更新 Telegram 频道/群组请求(ChatID可选)
|
||||
type TelegramChannelUpdateRequest struct {
|
||||
ChatID int64 `json:"chat_id"` // 可选,用于验证
|
||||
ChatName string `json:"chat_name" binding:"required"`
|
||||
ChatType string `json:"chat_type" binding:"required"` // channel 或 group
|
||||
PushEnabled bool `json:"push_enabled"`
|
||||
PushFrequency int `json:"push_frequency"`
|
||||
PushStartTime string `json:"push_start_time"`
|
||||
PushEndTime string `json:"push_end_time"`
|
||||
ContentCategories string `json:"content_categories"`
|
||||
ContentTags string `json:"content_tags"`
|
||||
IsActive bool `json:"is_active"`
|
||||
}
|
||||
|
||||
// TelegramChannelResponse Telegram 频道/群组响应
|
||||
type TelegramChannelResponse struct {
|
||||
ID uint `json:"id"`
|
||||
|
||||
@@ -17,7 +17,7 @@ type TelegramChannel struct {
|
||||
|
||||
// 推送配置
|
||||
PushEnabled bool `json:"push_enabled" gorm:"default:true;comment:是否启用推送"`
|
||||
PushFrequency int `json:"push_frequency" gorm:"default:24;comment:推送频率(小时)"`
|
||||
PushFrequency int `json:"push_frequency" gorm:"default:5;comment:推送频率(分钟)"`
|
||||
PushStartTime string `json:"push_start_time" gorm:"size:10;comment:推送开始时间,格式HH:mm"`
|
||||
PushEndTime string `json:"push_end_time" gorm:"size:10;comment:推送结束时间,格式HH:mm"`
|
||||
ContentCategories string `json:"content_categories" gorm:"type:text;comment:推送的内容分类,用逗号分隔"`
|
||||
|
||||
@@ -104,8 +104,8 @@ func (r *TelegramChannelRepositoryImpl) FindDueForPush() ([]entity.TelegramChann
|
||||
if channel.LastPushAt == nil {
|
||||
dueChannels = append(dueChannels, channel)
|
||||
} else {
|
||||
// 计算下次推送时间:上次推送时间 + 推送频率小时
|
||||
nextPushTime := channel.LastPushAt.Add(time.Duration(channel.PushFrequency) * time.Hour)
|
||||
// 计算下次推送时间:上次推送时间 + 推送频率分钟
|
||||
nextPushTime := channel.LastPushAt.Add(time.Duration(channel.PushFrequency) * time.Minute)
|
||||
if now.After(nextPushTime) {
|
||||
dueChannels = append(dueChannels, channel)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user