laniakea v1.0.0 rc1
This commit is contained in:
@@ -48,7 +48,7 @@ func GetConsoleLogs(db *database.Context) ([]ConsoleLogEntry, error) {
|
||||
|
||||
type MessageLogEntry struct {
|
||||
MessageID int `bson:"messageId" json:"message_id"`
|
||||
SenderID int `bson:"senderId" json:"sender_id"`
|
||||
SenderID int64 `bson:"senderId" json:"sender_id"`
|
||||
ChatID int64 `bson:"chatId" json:"chat_id"`
|
||||
Text string `bson:"text" json:"text"`
|
||||
TimeStamp int64 `bson:"timestamp" json:"timestamp"`
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
type User struct {
|
||||
ID int
|
||||
ID int64
|
||||
Balance decimal.Decimal
|
||||
Name string
|
||||
GroupID int `db:"group_id"`
|
||||
@@ -60,7 +60,7 @@ func NewUserRepository(db *database.Context) UserRepository {
|
||||
return newUserRepository(db.Postgres)
|
||||
}
|
||||
|
||||
func (rep UserRepository) GetOrCreate(tgId int, name string) (*User, error) {
|
||||
func (rep UserRepository) GetOrCreate(tgId int64, name string) (*User, error) {
|
||||
user, err := rep.GetById(tgId)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
user, err = rep.Create(tgId, name)
|
||||
@@ -68,13 +68,13 @@ func (rep UserRepository) GetOrCreate(tgId int, name string) (*User, error) {
|
||||
return user, err
|
||||
}
|
||||
|
||||
func (rep UserRepository) Create(id int, name string) (*User, error) {
|
||||
func (rep UserRepository) Create(id int64, name string) (*User, error) {
|
||||
user := new(User)
|
||||
err := rep.db.Get(user, "INSERT INTO users (id, name) VALUES ($1, $2) RETURNING *;", id, name)
|
||||
return user, err
|
||||
}
|
||||
|
||||
func (rep UserRepository) GetById(telegramId int) (*User, error) {
|
||||
func (rep UserRepository) GetById(telegramId int64) (*User, error) {
|
||||
user := new(User)
|
||||
err := rep.db.Get(user, "SELECT * FROM users WHERE id=$1;", telegramId)
|
||||
if err != nil {
|
||||
@@ -125,7 +125,7 @@ func (rep UserRepository) GetJoins(user *User) (*User, error) {
|
||||
user.Miner = &miner
|
||||
}
|
||||
if user.PairID.Valid {
|
||||
pair, err := rep.GetById(int(user.PairID.Int64))
|
||||
pair, err := rep.GetById(user.PairID.Int64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
type Waifu struct {
|
||||
ID int
|
||||
ID int64
|
||||
OwnerID sql.NullInt64 `db:"owner_id"`
|
||||
Name string
|
||||
Rarity int
|
||||
@@ -51,7 +51,7 @@ func (rep *WaifuRepository) GetAll() ([]*Waifu, error) {
|
||||
return waifus, err
|
||||
}
|
||||
|
||||
func (rep *WaifuRepository) GetByUserId(userId int) ([]*Waifu, error) {
|
||||
func (rep *WaifuRepository) GetByUserId(userId int64) ([]*Waifu, error) {
|
||||
waifus, err := sqlx.List[*Waifu](rep.db, "SELECT waifus.* FROM waifus WHERE owner_id=$1;", userId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -69,7 +69,7 @@ func (rep *WaifuRepository) GetByUserId(userId int) ([]*Waifu, error) {
|
||||
return waifus, nil
|
||||
}
|
||||
|
||||
func (rep *WaifuRepository) GetCountByUserId(userId int) (int64, error) {
|
||||
func (rep *WaifuRepository) GetCountByUserId(userId int64) (int64, error) {
|
||||
var count int64 = 0
|
||||
err := rep.db.QueryRow("SELECT COUNT(*) FROM waifus WHERE owner_id=$1;", userId).Scan(&count)
|
||||
return count, err
|
||||
@@ -91,7 +91,7 @@ func (rep *WaifuRepository) GetFreeByRarity(rarity int) ([]Waifu, error) {
|
||||
return waifus, err
|
||||
}
|
||||
|
||||
func (rep *WaifuRepository) GetById(id int) (*Waifu, error) {
|
||||
func (rep *WaifuRepository) GetById(id int64) (*Waifu, error) {
|
||||
waifu := new(Waifu)
|
||||
err := rep.db.Get(waifu, "SELECT * FROM waifus WHERE id=$1;", id)
|
||||
if err != nil {
|
||||
|
||||
@@ -23,8 +23,8 @@ type RPRepository struct {
|
||||
|
||||
type RPChat struct {
|
||||
ID uuid.UUID
|
||||
UserID int
|
||||
WaifuID int
|
||||
UserID int64
|
||||
WaifuID int64
|
||||
Prompt string
|
||||
Counter int
|
||||
ChatTokens int64
|
||||
@@ -39,25 +39,25 @@ func NewRPRepository(db *database.Context) RPRepository {
|
||||
return RPRepository{db.Redis, db}
|
||||
}
|
||||
|
||||
func (rep RPRepository) SetSelectedWaifu(userId, waifuId int) error {
|
||||
func (rep RPRepository) SetSelectedWaifu(userId, waifuId int64) error {
|
||||
key := fmt.Sprintf("ai.chats.rp.%d", userId)
|
||||
return rep.client.Set(ctx, key, waifuId, 0).Err()
|
||||
}
|
||||
func (rep RPRepository) GetSelectedWaifu(userId int) int {
|
||||
func (rep RPRepository) GetSelectedWaifu(userId int64) int64 {
|
||||
key := fmt.Sprintf("ai.chats.rp.%d", userId)
|
||||
res := rep.client.Get(ctx, key)
|
||||
if res.Err() != nil {
|
||||
return 0
|
||||
}
|
||||
i, _ := res.Int()
|
||||
return i
|
||||
return int64(i)
|
||||
}
|
||||
|
||||
func (rep RPRepository) SetChatId(userId, waifuId int, chatId string) error {
|
||||
func (rep RPRepository) SetChatId(userId, waifuId int64, chatId string) error {
|
||||
key := fmt.Sprintf("ai.chats.rp.%d.%d.chat", userId, waifuId)
|
||||
return rep.client.Set(context.Background(), key, chatId, 0).Err()
|
||||
}
|
||||
func (rep RPRepository) GetChatId(userId, waifuId int) string {
|
||||
func (rep RPRepository) GetChatId(userId, waifuId int64) string {
|
||||
key := fmt.Sprintf("ai.chats.rp.%d.%d.chat", userId, waifuId)
|
||||
res := rep.client.Get(ctx, key)
|
||||
if res.Err() != nil {
|
||||
@@ -65,7 +65,7 @@ func (rep RPRepository) GetChatId(userId, waifuId int) string {
|
||||
}
|
||||
return res.Val()
|
||||
}
|
||||
func (rep RPRepository) GetOrCreateChatId(userId, waifuId int) (string, error) {
|
||||
func (rep RPRepository) GetOrCreateChatId(userId, waifuId int64) (string, error) {
|
||||
chatId := rep.GetChatId(userId, waifuId)
|
||||
if chatId == "" {
|
||||
chatId = uuid.New().String()
|
||||
@@ -73,7 +73,7 @@ func (rep RPRepository) GetOrCreateChatId(userId, waifuId int) (string, error) {
|
||||
err := rep.SetChatId(userId, waifuId, chatId)
|
||||
return chatId, err
|
||||
}
|
||||
func (rep RPRepository) GetChat(userId int) (RPChat, error) {
|
||||
func (rep RPRepository) GetChat(userId int64) (RPChat, error) {
|
||||
var chat RPChat
|
||||
waifuId := rep.GetSelectedWaifu(userId)
|
||||
if waifuId == 0 {
|
||||
@@ -133,7 +133,7 @@ func (rep RPRepository) SaveChat(chat RPChat) error {
|
||||
if err = rep.SetCounter(userId, waifuId, chat.Counter); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = rep.SetChatTokens(userId, waifuId, int(chat.ChatTokens)); err != nil {
|
||||
if err = rep.SetChatTokens(userId, waifuId, chat.ChatTokens); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -161,11 +161,11 @@ func (rep RPRepository) SaveChat(chat RPChat) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rep RPRepository) SetChatPrompt(userId, waifuId int, prompt string) error {
|
||||
func (rep RPRepository) SetChatPrompt(userId, waifuId int64, prompt string) error {
|
||||
key := fmt.Sprintf("ai.chats.rp.%d.%d.prompt", userId, waifuId)
|
||||
return rep.client.Set(context.Background(), key, prompt, 0).Err()
|
||||
}
|
||||
func (rep RPRepository) GetChatPrompt(userId, waifuId int) string {
|
||||
func (rep RPRepository) GetChatPrompt(userId, waifuId int64) string {
|
||||
key := fmt.Sprintf("ai.chats.rp.%d.%d.prompt", userId, waifuId)
|
||||
res := rep.client.Get(ctx, key)
|
||||
if res.Err() != nil {
|
||||
@@ -174,11 +174,11 @@ func (rep RPRepository) GetChatPrompt(userId, waifuId int) string {
|
||||
return res.Val()
|
||||
}
|
||||
|
||||
func (rep RPRepository) SetCounter(userId, waifuId, counter int) error {
|
||||
func (rep RPRepository) SetCounter(userId, waifuId int64, counter int) error {
|
||||
key := fmt.Sprintf("ai.chats.rp.%d.%d.counter", userId, waifuId)
|
||||
return rep.client.Set(ctx, key, counter, 0).Err()
|
||||
}
|
||||
func (rep RPRepository) GetCounter(userId, waifuId int) int {
|
||||
func (rep RPRepository) GetCounter(userId, waifuId int64) int {
|
||||
key := fmt.Sprintf("ai.chats.rp.%d.%d.counter", userId, waifuId)
|
||||
res := rep.client.Get(ctx, key)
|
||||
if res.Err() != nil {
|
||||
@@ -188,25 +188,25 @@ func (rep RPRepository) GetCounter(userId, waifuId int) int {
|
||||
return i
|
||||
}
|
||||
|
||||
func (rep RPRepository) SetChatTokens(userId, waifuId, tokens int) error {
|
||||
func (rep RPRepository) SetChatTokens(userId, waifuId, tokens int64) error {
|
||||
key := fmt.Sprintf("ai.chats.rp.%d.%d.tokens", userId, waifuId)
|
||||
return rep.client.Set(ctx, key, tokens, 0).Err()
|
||||
}
|
||||
func (rep RPRepository) GetChatTokens(userId, waifuId int) int {
|
||||
func (rep RPRepository) GetChatTokens(userId, waifuId int64) int64 {
|
||||
key := fmt.Sprintf("ai.chats.rp.%d.%d.tokens", userId, waifuId)
|
||||
res := rep.client.Get(ctx, key)
|
||||
if res.Err() != nil {
|
||||
return 0
|
||||
}
|
||||
i, _ := res.Int()
|
||||
return i
|
||||
return int64(i)
|
||||
}
|
||||
|
||||
func (rep RPRepository) SetChatSettingID(userId, waifuId, settingId int) error {
|
||||
func (rep RPRepository) SetChatSettingID(userId, waifuId int64, settingId int) error {
|
||||
key := fmt.Sprintf("ai.chats.rp.%d.%d.setting_id", userId, waifuId)
|
||||
return rep.client.Set(ctx, key, settingId, 0).Err()
|
||||
}
|
||||
func (rep RPRepository) GetChatSettingID(userId, waifuId int) int {
|
||||
func (rep RPRepository) GetChatSettingID(userId, waifuId int64) int {
|
||||
key := fmt.Sprintf("ai.chats.rp.%d.%d.setting_id", userId, waifuId)
|
||||
res := rep.client.Get(ctx, key)
|
||||
if res.Err() != nil {
|
||||
@@ -216,12 +216,12 @@ func (rep RPRepository) GetChatSettingID(userId, waifuId int) int {
|
||||
return i
|
||||
}
|
||||
|
||||
func (rep RPRepository) SetChatScenariosIDs(userId, waifuId int, scenarioIds []int) error {
|
||||
func (rep RPRepository) SetChatScenariosIDs(userId, waifuId int64, scenarioIds []int) error {
|
||||
key := fmt.Sprintf("ai.chats.rp.%d.%d.scenario_id", userId, waifuId)
|
||||
ids := strings.Join(utils.Map(scenarioIds, utils.AnyToString), ",")
|
||||
return rep.client.Set(ctx, key, ids, 0).Err()
|
||||
}
|
||||
func (rep RPRepository) GetChatScenariosIDs(userId, waifuId int) []int {
|
||||
func (rep RPRepository) GetChatScenariosIDs(userId, waifuId int64) []int {
|
||||
key := fmt.Sprintf("ai.chats.rp.%d.%d.scenario_id", userId, waifuId)
|
||||
res := rep.client.Get(ctx, key)
|
||||
if res.Err() != nil {
|
||||
|
||||
Reference in New Issue
Block a user