handler chat error in the chat entry func

This commit is contained in:
RockYang
2024-05-15 15:30:34 +08:00
parent 3ab29da8f0
commit 36c27d6092
7 changed files with 14 additions and 23 deletions

View File

@@ -13,6 +13,7 @@ import (
"crypto/sha256"
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"geekai/core/types"
"geekai/store/model"
@@ -87,8 +88,7 @@ func (h *ChatHandler) sendXunFeiMessage(
res = h.DB.Where("platform", session.Model.Platform).Where("type", "chat").Where("enabled", true).Order("last_used_at ASC").First(&apiKey)
}
if res.Error != nil {
utils.ReplyMessage(ws, "抱歉😔😔😔,系统已经没有可用的 API KEY请联系管理员")
return nil
return errors.New("抱歉😔😔😔,系统已经没有可用的 API KEY请联系管理员")
}
// 更新 API KEY 的最后使用时间
h.DB.Model(&apiKey).UpdateColumn("last_used_at", time.Now().Unix())