From 90191b8d5b178208e26bac4ae0f5aa1b63bff936 Mon Sep 17 00:00:00 2001 From: "1808837298@qq.com" <1808837298@qq.com> Date: Wed, 19 Feb 2025 15:54:33 +0800 Subject: [PATCH] chore: update env name and README --- README.en.md | 2 ++ README.md | 3 +++ constant/env.go | 2 +- service/notify-limit.go | 4 ++-- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.en.md b/README.en.md index feb4b0bb..446c88f6 100644 --- a/README.en.md +++ b/README.en.md @@ -89,6 +89,8 @@ You can add custom models gpt-4-gizmo-* in channels. These are third-party model - `MAX_FILE_DOWNLOAD_MB`: Maximum file download size in MB, default `20` - `CRYPTO_SECRET`: Encryption key for encrypting database content - `AZURE_DEFAULT_API_VERSION`: Azure channel default API version, if not specified in channel settings, use this version, default `2024-12-01-preview` +- `NOTIFICATION_LIMIT_DURATION_MINUTE`: Duration of notification limit in minutes, default `10` +- `NOTIFY_LIMIT_COUNT`: Maximum number of user notifications in the specified duration, default `2` ## Deployment diff --git a/README.md b/README.md index cecefca6..e678832d 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,9 @@ - `MAX_FILE_DOWNLOAD_MB`: 最大文件下载大小,单位 MB,默认为 `20`。 - `CRYPTO_SECRET`:加密密钥,用于加密数据库内容。 - `AZURE_DEFAULT_API_VERSION`:Azure渠道默认API版本,如果渠道设置中未指定API版本,则使用此版本,默认为 `2024-12-01-preview` +- `NOTIFICATION_LIMIT_DURATION_MINUTE`:通知限制的持续时间(分钟),默认为 `10`。 +- `NOTIFY_LIMIT_COUNT`:用户通知在指定持续时间内的最大数量,默认为 `2`。 + ## 部署 > [!TIP] diff --git a/constant/env.go b/constant/env.go index 2102bb7c..bffbfeea 100644 --- a/constant/env.go +++ b/constant/env.go @@ -29,7 +29,7 @@ var GeminiModelMap = map[string]string{ var GeminiVisionMaxImageNum = common.GetEnvOrDefault("GEMINI_VISION_MAX_IMAGE_NUM", 16) -var DefaultNotifyHourlyLimit = common.GetEnvOrDefault("NOTIFY_HOURLY_LIMIT", 2) +var NotifyLimitCount = common.GetEnvOrDefault("NOTIFY_LIMIT_COUNT", 2) var NotificationLimitDurationMinute = common.GetEnvOrDefault("NOTIFICATION_LIMIT_DURATION_MINUTE", 10) func InitEnv() { diff --git a/service/notify-limit.go b/service/notify-limit.go index d99f49cc..7bb62f62 100644 --- a/service/notify-limit.go +++ b/service/notify-limit.go @@ -68,7 +68,7 @@ func checkRedisLimit(userId int, notifyType string) (bool, error) { } currentCount, _ := strconv.Atoi(count) - limit := constant.DefaultNotifyHourlyLimit + limit := constant.NotifyLimitCount // Check if limit is already reached if currentCount >= limit { @@ -107,7 +107,7 @@ func checkMemoryLimit(userId int, notifyType string) (bool, error) { currentLimit.Count++ // Check against limits - limit := constant.DefaultNotifyHourlyLimit + limit := constant.NotifyLimitCount // Store updated count notifyLimitStore.Store(key, currentLimit)