mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-16 13:13:41 +08:00
✨ feat: add chat cache (#152)
This commit is contained in:
@@ -37,6 +37,10 @@ var WeChatAuthEnabled = false
|
||||
var TurnstileCheckEnabled = false
|
||||
var RegisterEnabled = true
|
||||
|
||||
// chat cache
|
||||
var ChatCacheEnabled = false
|
||||
var ChatCacheExpireMinute = 5 // 5 Minute
|
||||
|
||||
// mj
|
||||
var MjNotifyEnabled = false
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"log"
|
||||
@@ -248,3 +249,16 @@ func EscapeMarkdownText(text string) string {
|
||||
}
|
||||
return text
|
||||
}
|
||||
|
||||
func UnmarshalString[T interface{}](data string) (form T, err error) {
|
||||
err = json.Unmarshal([]byte(data), &form)
|
||||
return form, err
|
||||
}
|
||||
|
||||
func Marshal[T interface{}](data T) string {
|
||||
res, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return string(res)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user