50 lines
1.4 KiB
Go
50 lines
1.4 KiB
Go
package red
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"kurumibot/laniakea"
|
|
)
|
|
|
|
var ctx = context.Background()
|
|
|
|
func RPSetSelectedWaifu(db *laniakea.DatabaseContext, userId, waifuId int) error {
|
|
key := fmt.Sprintf("ai.chats.rp.%d", userId)
|
|
return db.Redis.Set(ctx, key, waifuId, 0).Err()
|
|
}
|
|
func RPGetSelectedWaifu(db *laniakea.DatabaseContext, userId int) int {
|
|
key := fmt.Sprintf("ai.chats.rp.%d", userId)
|
|
res := db.Redis.Get(ctx, key)
|
|
if res.Err() != nil {
|
|
return 0
|
|
}
|
|
i, _ := res.Int()
|
|
return i
|
|
}
|
|
|
|
func RPSetChatId(db *laniakea.DatabaseContext, userId, waifuId int, chatId string) error {
|
|
key := fmt.Sprintf("ai.chats.rp.%d.%d.chat", userId, waifuId)
|
|
return db.Redis.Set(context.Background(), key, chatId, 0).Err()
|
|
}
|
|
func RPGetChatId(db *laniakea.DatabaseContext, userId, waifuId int) string {
|
|
key := fmt.Sprintf("ai.chats.rp.%d.%d.chat", userId, waifuId)
|
|
res := db.Redis.Get(ctx, key)
|
|
if res.Err() != nil {
|
|
return ""
|
|
}
|
|
return res.Val()
|
|
}
|
|
|
|
func RPSetChatPrompt(db *laniakea.DatabaseContext, userId, waifuId int, prompt string) error {
|
|
key := fmt.Sprintf("ai.chats.rp.%d.%d.prompt", userId, waifuId)
|
|
return db.Redis.Set(context.Background(), key, prompt, 0).Err()
|
|
}
|
|
func RPGetChatPrompt(db *laniakea.DatabaseContext, userId, waifuId int) string {
|
|
key := fmt.Sprintf("ai.chats.rp.%d.%d.prompt", userId, waifuId)
|
|
res := db.Redis.Get(ctx, key)
|
|
if res.Err() != nil {
|
|
return ""
|
|
}
|
|
return res.Val()
|
|
}
|