feat: support other OpenAI APIs (#165)

*  feat: support other OpenAI APIs

* 🔖 chore: Update English translation
This commit is contained in:
Buer
2024-04-23 19:57:14 +08:00
committed by GitHub
parent f91b9856d4
commit 628df97f96
9 changed files with 152 additions and 56 deletions

View File

@@ -114,6 +114,10 @@ func tokenAuth(c *gin.Context, key string) {
return
}
c.Set("specific_channel_id", channelId)
if len(parts) == 3 && parts[2] == "ignore" {
c.Set("specific_channel_id_ignore", true)
}
} else {
abortWithMessage(c, http.StatusForbidden, "普通用户不支持指定渠道")
return
@@ -135,3 +139,16 @@ func MjAuth() func(c *gin.Context) {
tokenAuth(c, key)
}
}
func SpecifiedChannel() func(c *gin.Context) {
return func(c *gin.Context) {
channelId := c.GetInt("specific_channel_id")
c.Set("specific_channel_id_ignore", false)
if channelId <= 0 {
abortWithMessage(c, http.StatusForbidden, "必须指定渠道")
return
}
c.Next()
}
}