some fixes and new features
This commit is contained in:
@@ -40,14 +40,32 @@ func RegisterRP(bot *laniakea.Bot) {
|
||||
}
|
||||
|
||||
func rpInfo(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
userRep := psql.NewUserRepository(db)
|
||||
_, err := userRep.GetOrCreate(ctx.FromID, ctx.From.FirstName)
|
||||
if err != nil {
|
||||
ctx.Error(err)
|
||||
return
|
||||
}
|
||||
waifuRep := psql.NewWaifuRepository(db)
|
||||
count, err := waifuRep.GetCountByUserId(ctx.FromID)
|
||||
if err != nil {
|
||||
ctx.Error(err)
|
||||
return
|
||||
}
|
||||
if count == 0 {
|
||||
kb := laniakea.NewInlineKeyboard(1).AddCallbackButton("Закрыть", "general.close")
|
||||
ctx.Keyboard("Для доступа к этой команде нужно иметь хотя бы одну вайфу", kb)
|
||||
return
|
||||
}
|
||||
|
||||
rpRepRed := red.NewRPRepository(db)
|
||||
rpRepPsql := psql.NewRPRepository(db)
|
||||
rpUser, err := rpRepPsql.GetOrCreateUser(int64(ctx.FromID))
|
||||
if err != nil {
|
||||
ctx.Error(err)
|
||||
return
|
||||
}
|
||||
waifuId := rpRepRed.GetSelectedWaifu(ctx.FromID)
|
||||
waifuRep := psql.NewWaifuRepository(db)
|
||||
waifu, err := waifuRep.GetById(waifuId)
|
||||
if err != nil {
|
||||
ctx.Error(err)
|
||||
@@ -414,6 +432,7 @@ func generate(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
res, err := api.CreateCompletion(ai.CreateCompletionReq{
|
||||
Messages: messages,
|
||||
Temperature: 1.0,
|
||||
TopP: 1.0,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.Error(err)
|
||||
|
||||
Reference in New Issue
Block a user