初始化导入 new-api 源码

This commit is contained in:
OpenClaw Task Bot
2026-04-09 22:31:14 +08:00
commit 75bda2e845
994 changed files with 250292 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
package model
import (
"strings"
"github.com/QuantumNous/new-api/setting"
)
const PrefillGroupTypeSubscriptionGroup = "subscription_group"
func ListSubscriptionDedicatedGroups() ([]string, error) {
groups := setting.GetSubscriptionGroupsCopy()
result := make([]string, 0, len(groups))
for name := range groups {
name = strings.TrimSpace(name)
if name != "" {
result = append(result, name)
}
}
return result, nil
}
func GetSubscriptionDedicatedGroupSet() (map[string]struct{}, error) {
groups := setting.GetSubscriptionGroupsCopy()
result := make(map[string]struct{}, len(groups))
for name := range groups {
name = strings.TrimSpace(name)
if name != "" {
result[name] = struct{}{}
}
}
return result, nil
}
func IsSubscriptionDedicatedGroup(group string) (bool, error) {
group = strings.TrimSpace(group)
if group == "" {
return false, nil
}
return setting.IsSubscriptionGroup(group), nil
}
// 历史实现会把 allowed_consume_groups 自动种成 subscription_group导致"套餐允许消费分组"与
// "订阅专属分组"语义混淆。现保留该入口仅做兼容空操作,避免启动迁移时报错,并停止自动污染分组语义。
func EnsureSubscriptionDedicatedGroupsSeededFromPlans() error {
return nil
}