refactoring, fixes and laniakea v0.8

This commit is contained in:
2026-02-19 14:02:25 +03:00
parent 0804398b6c
commit c9a5a81643
30 changed files with 219 additions and 190 deletions

View File

@@ -1,7 +1,7 @@
FROM golang:1.26.0-alpine3.23 AS builder FROM golang:1.26.0-alpine3.23 AS builder
ARG BUILD_TIME ARG BUILD_TIME
ARG GIT_COMMIT ARG GIT_COMMIT
WORKDIR /usr/src/kurumi WORKDIR /usr/src/ymgb
COPY go.mod go.sum ./ COPY go.mod go.sum ./
#COPY ./laniakea ./laniakea #COPY ./laniakea ./laniakea
RUN --mount=type=cache,target=/go/pkg/mod go mod download RUN --mount=type=cache,target=/go/pkg/mod go mod download
@@ -12,11 +12,11 @@ COPY ./main.go ./
RUN --mount=type=cache,target=/root/.cache/go-build \ RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/go/pkg/mod \
CGO_ENABLED=0 go build -trimpath \ CGO_ENABLED=0 go build -trimpath \
-ldflags="-s -w -X 'kurumibot/utils.BuildTime=$BUILD_TIME' -X 'kurumibot/utils.GitCommit=$GIT_COMMIT'" \ -ldflags="-s -w -X 'ymgb/utils.BuildTime=$BUILD_TIME' -X 'ymgb/utils.GitCommit=$GIT_COMMIT'" \
-v -o /usr/local/bin/kurumi ./ -v -o /usr/local/bin/ymgb ./
FROM alpine:3.23 AS runner FROM alpine:3.23 AS runner
WORKDIR /app WORKDIR /app
ENV GOMEMLIMIT=256MiB ENV GOMEMLIMIT=256MiB
COPY --from=builder /usr/local/bin/kurumi /app/kurumi COPY --from=builder /usr/local/bin/ymgb /app/ymgb
CMD ["/app/kurumi"] CMD ["/app/ymgb"]

View File

@@ -5,5 +5,5 @@ build:
@echo "Building commit $(GIT_COMMIT)" @echo "Building commit $(GIT_COMMIT)"
@echo "Build time $(BUILD_TIME)" @echo "Build time $(BUILD_TIME)"
go mod tidy go mod tidy
docker build --build-arg GIT_COMMIT --build-arg BUILD_TIME -t git.nix13.pw/scuroneko/kurumibotgo:dev -f ./Dockerfile . docker build --build-arg GIT_COMMIT --build-arg BUILD_TIME -t git.nix13.pw/scuroneko/yaemikobot:dev -f ./Dockerfile .
docker push git.nix13.pw/scuroneko/kurumibotgo:dev docker push git.nix13.pw/scuroneko/yaemikobot:dev

15
database/ctx.go Normal file
View File

@@ -0,0 +1,15 @@
package database
import (
"git.nix13.pw/scuroneko/laniakea"
"github.com/redis/go-redis/v9"
"github.com/vinovest/sqlx"
"go.mongodb.org/mongo-driver/v2/mongo"
)
type Context struct {
laniakea.DbContext
Postgres *sqlx.DB
Mongo *mongo.Client
Redis *redis.Client
}

View File

@@ -2,14 +2,13 @@ package mdb
import ( import (
"context" "context"
"kurumibot/database"
"time" "time"
"ymgb/database"
"git.nix13.pw/scuroneko/laniakea"
"go.mongodb.org/mongo-driver/v2/bson" "go.mongodb.org/mongo-driver/v2/bson"
) )
func GetGptChatHistory(db *laniakea.DatabaseContext, chatId string) ([]AiChatMessage, error) { func GetGptChatHistory(db *database.Context, chatId string) ([]AiChatMessage, error) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel() defer cancel()
col := database.GetMongoCollection(db, "gpt_chat_messages") col := database.GetMongoCollection(db, "gpt_chat_messages")
@@ -21,7 +20,7 @@ func GetGptChatHistory(db *laniakea.DatabaseContext, chatId string) ([]AiChatMes
err = cursor.All(ctx, &result) err = cursor.All(ctx, &result)
return result, err return result, err
} }
func UpdateGptChatHistory(db *laniakea.DatabaseContext, chatId, role, message string) error { func UpdateGptChatHistory(db *database.Context, chatId, role, message string) error {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel() defer cancel()
col := database.GetMongoCollection(db, "gpt_chat_messages") col := database.GetMongoCollection(db, "gpt_chat_messages")

View File

@@ -2,10 +2,9 @@ package mdb
import ( import (
"context" "context"
"kurumibot/database"
"time" "time"
"ymgb/database"
"git.nix13.pw/scuroneko/laniakea"
"go.mongodb.org/mongo-driver/v2/bson" "go.mongodb.org/mongo-driver/v2/bson"
) )
@@ -22,7 +21,7 @@ type CodeEntry struct {
TotalUsages uint `bson:"totalUsages"` TotalUsages uint `bson:"totalUsages"`
} }
func FindCode(db *laniakea.DatabaseContext, code string) (CodeEntry, error) { func FindCode(db *database.Context, code string) (CodeEntry, error) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel() defer cancel()
collection := database.GetMongoCollection(db, "codes") collection := database.GetMongoCollection(db, "codes")

View File

@@ -2,11 +2,10 @@ package mdb
import ( import (
"context" "context"
"kurumibot/database"
"time" "time"
"ymgb/database"
"git.nix13.pw/scuroneko/extypes" "git.nix13.pw/scuroneko/extypes"
"git.nix13.pw/scuroneko/laniakea"
"go.mongodb.org/mongo-driver/v2/bson" "go.mongodb.org/mongo-driver/v2/bson"
"go.mongodb.org/mongo-driver/v2/mongo/options" "go.mongodb.org/mongo-driver/v2/mongo/options"
) )
@@ -20,14 +19,14 @@ type ConsoleLogEntry struct {
TimeStamp int64 `bson:"timeStamp" json:"time_stamp"` TimeStamp int64 `bson:"timeStamp" json:"time_stamp"`
} }
func WriteConsoleLog(db *laniakea.DatabaseContext, e ConsoleLogEntry) error { func WriteConsoleLog(db *database.Context, e ConsoleLogEntry) error {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel() defer cancel()
col := database.GetMongoCollection(db, "logs") col := database.GetMongoCollection(db, "logs")
_, err := col.InsertOne(ctx, e) _, err := col.InsertOne(ctx, e)
return err return err
} }
func GetConsoleLogs(db *laniakea.DatabaseContext) ([]ConsoleLogEntry, error) { func GetConsoleLogs(db *database.Context) ([]ConsoleLogEntry, error) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel() defer cancel()
col := database.GetMongoCollection(db, "logs") col := database.GetMongoCollection(db, "logs")
@@ -52,14 +51,14 @@ type MessageLogEntry struct {
TimeStamp int64 `bson:"timestamp" json:"timestamp"` TimeStamp int64 `bson:"timestamp" json:"timestamp"`
} }
func WriteMessageLog(db *laniakea.DatabaseContext, e *MessageLogEntry) error { func WriteMessageLog(db *database.Context, e *MessageLogEntry) error {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel() defer cancel()
col := database.GetMongoCollection(db, "msg_logs") col := database.GetMongoCollection(db, "msg_logs")
_, err := col.InsertOne(ctx, e) _, err := col.InsertOne(ctx, e)
return err return err
} }
func GetMessageLogs(db *laniakea.DatabaseContext) (extypes.Slice[*MessageLogEntry], error) { func GetMessageLogs(db *database.Context) (extypes.Slice[*MessageLogEntry], error) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel() defer cancel()
col := database.GetMongoCollection(db, "msg_logs") col := database.GetMongoCollection(db, "msg_logs")

View File

@@ -2,10 +2,9 @@ package mdb
import ( import (
"context" "context"
"kurumibot/database"
"time" "time"
"ymgb/database"
"git.nix13.pw/scuroneko/laniakea"
"go.mongodb.org/mongo-driver/v2/bson" "go.mongodb.org/mongo-driver/v2/bson"
) )
@@ -17,7 +16,7 @@ type AiChatMessage struct {
Index int `bson:"index"` Index int `bson:"index"`
} }
func GetRPChatHistory(db *laniakea.DatabaseContext, chatId string) ([]AiChatMessage, error) { func GetRPChatHistory(db *database.Context, chatId string) ([]AiChatMessage, error) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel() defer cancel()
col := database.GetMongoCollection(db, "rp_chat_messages") col := database.GetMongoCollection(db, "rp_chat_messages")
@@ -29,7 +28,7 @@ func GetRPChatHistory(db *laniakea.DatabaseContext, chatId string) ([]AiChatMess
err = cursor.All(ctx, &result) err = cursor.All(ctx, &result)
return result, err return result, err
} }
func UpdateRPChatHistory(db *laniakea.DatabaseContext, chatId, role, message string, index int) error { func UpdateRPChatHistory(db *database.Context, chatId, role, message string, index int) error {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel() defer cancel()
col := database.GetMongoCollection(db, "rp_chat_messages") col := database.GetMongoCollection(db, "rp_chat_messages")
@@ -41,13 +40,13 @@ func UpdateRPChatHistory(db *laniakea.DatabaseContext, chatId, role, message str
}) })
return err return err
} }
func GetRPChatHistorySize(db *laniakea.DatabaseContext, chatId string) (int64, error) { func GetRPChatHistorySize(db *database.Context, chatId string) (int64, error) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel() defer cancel()
col := database.GetMongoCollection(db, "rp_chat_messages") col := database.GetMongoCollection(db, "rp_chat_messages")
return col.CountDocuments(ctx, bson.M{"chatId": chatId}) return col.CountDocuments(ctx, bson.M{"chatId": chatId})
} }
func DeleteRPChatEntry(db *laniakea.DatabaseContext, entry AiChatMessage) error { func DeleteRPChatEntry(db *database.Context, entry AiChatMessage) error {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel() defer cancel()
col := database.GetMongoCollection(db, "rp_chat_messages") col := database.GetMongoCollection(db, "rp_chat_messages")

View File

@@ -5,7 +5,6 @@ import (
"log" "log"
"os" "os"
"git.nix13.pw/scuroneko/laniakea"
"go.mongodb.org/mongo-driver/v2/mongo" "go.mongodb.org/mongo-driver/v2/mongo"
"go.mongodb.org/mongo-driver/v2/mongo/options" "go.mongodb.org/mongo-driver/v2/mongo/options"
) )
@@ -32,6 +31,6 @@ func ConnectMongo() {
} }
} }
func GetMongoCollection(db *laniakea.DatabaseContext, name string) *mongo.Collection { func GetMongoCollection(db *Context, name string) *mongo.Collection {
return db.MongoDB.Database(os.Getenv("MONGO_NAME")).Collection(name) return db.Mongo.Database(os.Getenv("MONGO_NAME")).Collection(name)
} }

View File

@@ -1,7 +1,8 @@
package psql package psql
import ( import (
"git.nix13.pw/scuroneko/laniakea" "ymgb/database"
"github.com/vinovest/sqlx" "github.com/vinovest/sqlx"
) )
@@ -19,8 +20,8 @@ type AIRepository struct {
func newAiRepository(db *sqlx.DB) AIRepository { func newAiRepository(db *sqlx.DB) AIRepository {
return AIRepository{db} return AIRepository{db}
} }
func NewAIRepository(db *laniakea.DatabaseContext) AIRepository { func NewAIRepository(db *database.Context) AIRepository {
return newAiRepository(db.PostgresSQL) return newAiRepository(db.Postgres)
} }
func (rep AIRepository) GetModel(id string) (AIModel, error) { func (rep AIRepository) GetModel(id string) (AIModel, error) {

View File

@@ -1,7 +1,8 @@
package psql package psql
import ( import (
"git.nix13.pw/scuroneko/laniakea" "ymgb/database"
"github.com/shopspring/decimal" "github.com/shopspring/decimal"
"github.com/vinovest/sqlx" "github.com/vinovest/sqlx"
) )
@@ -22,8 +23,8 @@ type FractionRepository struct {
func newFractionRepository(db *sqlx.DB) FractionRepository { func newFractionRepository(db *sqlx.DB) FractionRepository {
return FractionRepository{db} return FractionRepository{db}
} }
func NewFractionRepository(db *laniakea.DatabaseContext) FractionRepository { func NewFractionRepository(db *database.Context) FractionRepository {
return newFractionRepository(db.PostgresSQL) return newFractionRepository(db.Postgres)
} }
func (rep FractionRepository) GetAll() ([]Fraction, error) { func (rep FractionRepository) GetAll() ([]Fraction, error) {

View File

@@ -1,7 +1,8 @@
package psql package psql
import ( import (
"git.nix13.pw/scuroneko/laniakea" "ymgb/database"
"github.com/shopspring/decimal" "github.com/shopspring/decimal"
"github.com/vinovest/sqlx" "github.com/vinovest/sqlx"
) )
@@ -25,8 +26,8 @@ type GroupRepository struct {
func newGroupRepository(db *sqlx.DB) GroupRepository { func newGroupRepository(db *sqlx.DB) GroupRepository {
return GroupRepository{db} return GroupRepository{db}
} }
func NewGroupRepository(db *laniakea.DatabaseContext) GroupRepository { func NewGroupRepository(db *database.Context) GroupRepository {
return newGroupRepository(db.PostgresSQL) return newGroupRepository(db.Postgres)
} }
func (rep GroupRepository) GetAll() ([]Group, error) { func (rep GroupRepository) GetAll() ([]Group, error) {

View File

@@ -3,8 +3,8 @@ package psql
import ( import (
"database/sql" "database/sql"
"errors" "errors"
"ymgb/database"
"git.nix13.pw/scuroneko/laniakea"
"github.com/vinovest/sqlx" "github.com/vinovest/sqlx"
) )
@@ -56,8 +56,8 @@ type RPRepository struct {
func newRpRepository(db *sqlx.DB) RPRepository { func newRpRepository(db *sqlx.DB) RPRepository {
return RPRepository{db} return RPRepository{db}
} }
func NewRPRepository(db *laniakea.DatabaseContext) RPRepository { func NewRPRepository(db *database.Context) RPRepository {
return newRpRepository(db.PostgresSQL) return newRpRepository(db.Postgres)
} }
func (rep RPRepository) GetOrCreateUser(id int64) (RPUser, error) { func (rep RPRepository) GetOrCreateUser(id int64) (RPUser, error) {

View File

@@ -1,7 +1,8 @@
package psql package psql
import ( import (
"git.nix13.pw/scuroneko/laniakea" "ymgb/database"
"github.com/shopspring/decimal" "github.com/shopspring/decimal"
"github.com/vinovest/sqlx" "github.com/vinovest/sqlx"
) )
@@ -37,10 +38,10 @@ type ShopRepository struct {
db *sqlx.DB db *sqlx.DB
} }
func NewShopRepository(db *laniakea.DatabaseContext) ShopRepository {
return newShopRepository(db.PostgresSQL)
}
func newShopRepository(db *sqlx.DB) ShopRepository { return ShopRepository{db} } func newShopRepository(db *sqlx.DB) ShopRepository { return ShopRepository{db} }
func NewShopRepository(db *database.Context) ShopRepository {
return newShopRepository(db.Postgres)
}
func (rep ShopRepository) GetAllAuto() ([]ShopAuto, error) { func (rep ShopRepository) GetAllAuto() ([]ShopAuto, error) {
auto := make([]ShopAuto, 0) auto := make([]ShopAuto, 0)

View File

@@ -6,8 +6,8 @@ import (
"errors" "errors"
"math" "math"
"time" "time"
"ymgb/database"
"git.nix13.pw/scuroneko/laniakea"
"github.com/shopspring/decimal" "github.com/shopspring/decimal"
"github.com/vinovest/sqlx" "github.com/vinovest/sqlx"
) )
@@ -56,8 +56,8 @@ type UserRepository struct {
} }
func newUserRepository(db *sqlx.DB) UserRepository { return UserRepository{db} } func newUserRepository(db *sqlx.DB) UserRepository { return UserRepository{db} }
func NewUserRepository(db *laniakea.DatabaseContext) UserRepository { func NewUserRepository(db *database.Context) UserRepository {
return newUserRepository(db.PostgresSQL) return newUserRepository(db.Postgres)
} }
func (rep UserRepository) GetOrCreate(tgId int, name string) (*User, error) { func (rep UserRepository) GetOrCreate(tgId int, name string) (*User, error) {

View File

@@ -2,8 +2,8 @@ package psql
import ( import (
"database/sql" "database/sql"
"ymgb/database"
"git.nix13.pw/scuroneko/laniakea"
"github.com/shopspring/decimal" "github.com/shopspring/decimal"
"github.com/vinovest/sqlx" "github.com/vinovest/sqlx"
) )
@@ -26,8 +26,9 @@ type WaifuRepository struct {
db *sqlx.DB db *sqlx.DB
} }
func NewWaifuRepository(db *laniakea.DatabaseContext) *WaifuRepository { func newWaifuRepository(db *sqlx.DB) *WaifuRepository { return &WaifuRepository{db} }
return &WaifuRepository{db: db.PostgresSQL} func NewWaifuRepository(db *database.Context) *WaifuRepository {
return newWaifuRepository(db.Postgres)
} }
func (rep *WaifuRepository) GetAll() ([]*Waifu, error) { func (rep *WaifuRepository) GetAll() ([]*Waifu, error) {

View File

@@ -1,7 +1,8 @@
package psql package psql
import ( import (
"git.nix13.pw/scuroneko/laniakea" "ymgb/database"
"github.com/shopspring/decimal" "github.com/shopspring/decimal"
"github.com/vinovest/sqlx" "github.com/vinovest/sqlx"
) )
@@ -22,8 +23,8 @@ type WorkRepository struct {
func newWorkRepository(db *sqlx.DB) WorkRepository { func newWorkRepository(db *sqlx.DB) WorkRepository {
return WorkRepository{db} return WorkRepository{db}
} }
func NewWorkRepository(db *laniakea.DatabaseContext) WorkRepository { func NewWorkRepository(db *database.Context) WorkRepository {
return newWorkRepository(db.PostgresSQL) return newWorkRepository(db.Postgres)
} }
func (rep WorkRepository) GetById(id int) (Work, error) { func (rep WorkRepository) GetById(id int) (Work, error) {

View File

@@ -2,8 +2,8 @@ package red
import ( import (
"fmt" "fmt"
"ymgb/database"
"git.nix13.pw/scuroneko/laniakea"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/redis/go-redis/v9" "github.com/redis/go-redis/v9"
) )
@@ -12,7 +12,7 @@ type AiRepository struct {
client *redis.Client client *redis.Client
} }
func NewAiRepository(db *laniakea.DatabaseContext) AiRepository { func NewAiRepository(db *database.Context) AiRepository {
return AiRepository{client: db.Redis} return AiRepository{client: db.Redis}
} }

View File

@@ -5,11 +5,11 @@ import (
"database/sql" "database/sql"
"errors" "errors"
"fmt" "fmt"
"kurumibot/database/psql"
"kurumibot/utils"
"strings" "strings"
"ymgb/database"
"ymgb/database/psql"
"ymgb/utils"
"git.nix13.pw/scuroneko/laniakea"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/redis/go-redis/v9" "github.com/redis/go-redis/v9"
) )
@@ -18,7 +18,7 @@ var ctx = context.Background()
type RPRepository struct { type RPRepository struct {
client *redis.Client client *redis.Client
db *laniakea.DatabaseContext db *database.Context
} }
type RPChat struct { type RPChat struct {
@@ -35,7 +35,7 @@ type RPChat struct {
Scenarios []psql.RPScenario Scenarios []psql.RPScenario
} }
func NewRPRepository(db *laniakea.DatabaseContext) RPRepository { func NewRPRepository(db *database.Context) RPRepository {
return RPRepository{db.Redis, db} return RPRepository{db.Redis, db}
} }

4
go.mod
View File

@@ -1,10 +1,10 @@
module kurumibot module ymgb
go 1.26.0 go 1.26.0
require ( require (
git.nix13.pw/scuroneko/extypes v1.2.0 git.nix13.pw/scuroneko/extypes v1.2.0
git.nix13.pw/scuroneko/laniakea v0.7.1 git.nix13.pw/scuroneko/laniakea v0.8.0-beta.3
git.nix13.pw/scuroneko/slog v1.0.2 git.nix13.pw/scuroneko/slog v1.0.2
github.com/google/uuid v1.6.0 github.com/google/uuid v1.6.0
github.com/joho/godotenv v1.5.1 github.com/joho/godotenv v1.5.1

4
go.sum
View File

@@ -2,8 +2,8 @@ filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
git.nix13.pw/scuroneko/extypes v1.2.0 h1:2n2hD6KsMAted+6MGhAyeWyli2Qzc9G2y+pQNB7C1dM= git.nix13.pw/scuroneko/extypes v1.2.0 h1:2n2hD6KsMAted+6MGhAyeWyli2Qzc9G2y+pQNB7C1dM=
git.nix13.pw/scuroneko/extypes v1.2.0/go.mod h1:uZVs8Yo3RrYAG9dMad6qR6lsYY67t+459D9c65QAYAw= git.nix13.pw/scuroneko/extypes v1.2.0/go.mod h1:uZVs8Yo3RrYAG9dMad6qR6lsYY67t+459D9c65QAYAw=
git.nix13.pw/scuroneko/laniakea v0.7.1 h1:OIIsZ4qdgHevicOHsYTD+yviGIxvd30Wi6j56QptC3Q= git.nix13.pw/scuroneko/laniakea v0.8.0-beta.3 h1:ZXW6TEKmhrqSLHxtLX6JDZeUaeuO5R6qYMhNf01G0Ec=
git.nix13.pw/scuroneko/laniakea v0.7.1/go.mod h1:ABjrmhKkTbhTwlMs+bLCr2e+ANnHbYTeidaicl2F0Z4= git.nix13.pw/scuroneko/laniakea v0.8.0-beta.3/go.mod h1:oYJ4Bp+AsbNBP4clPBJ2ODnJ8oSTihBbi5XaTJa0hMc=
git.nix13.pw/scuroneko/slog v1.0.2 h1:vZyUROygxC2d5FJHUQM/30xFEHY1JT/aweDZXA4rm2g= git.nix13.pw/scuroneko/slog v1.0.2 h1:vZyUROygxC2d5FJHUQM/30xFEHY1JT/aweDZXA4rm2g=
git.nix13.pw/scuroneko/slog v1.0.2/go.mod h1:3Qm2wzkR5KjwOponMfG7TcGSDjmYaFqRAmLvSPTuWJI= git.nix13.pw/scuroneko/slog v1.0.2/go.mod h1:3Qm2wzkR5KjwOponMfG7TcGSDjmYaFqRAmLvSPTuWJI=
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs= github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=

30
main.go
View File

@@ -3,8 +3,8 @@ package main
import ( import (
"git.nix13.pw/scuroneko/laniakea" "git.nix13.pw/scuroneko/laniakea"
"kurumibot/database" "ymgb/database"
"kurumibot/plugins" "ymgb/plugins"
"github.com/joho/godotenv" "github.com/joho/godotenv"
) )
@@ -16,27 +16,29 @@ func main() {
database.ConnectMongo() database.ConnectMongo()
database.ConnectRedis() database.ConnectRedis()
bot := laniakea.NewBot(laniakea.LoadOptsFromEnv()) bot := laniakea.NewBot[database.Context](laniakea.LoadOptsFromEnv())
defer bot.Close() defer bot.Close()
bot = bot.ErrorTemplate("Во время выполнения команды произошла ошибка!\nСообщите об этом разработчику!\n\n%s") bot = bot.ErrorTemplate("Во время выполнения команды произошла ошибка!\nСообщите об этом разработчику!\n\n%s")
bot = bot.DatabaseContext(&laniakea.DatabaseContext{ bot = bot.DatabaseContext(&database.Context{
PostgresSQL: database.PostgresDatabase, Postgres: database.PostgresDatabase,
MongoDB: database.MongoClient, Mongo: database.MongoClient,
Redis: database.RedisClient, Redis: database.RedisClient,
}) })
bot.AddDatabaseLogger(plugins.DatabaseLogger) bot.AddDatabaseLogger(plugins.DatabaseLogger)
bot.AddMiddleware(plugins.InitLogMiddleware()) bot.AddMiddleware(plugins.InitLogMiddleware())
plugins.RegisterService(bot) bot.AddPlugins(
plugins.RegisterAdmin(bot) plugins.RegisterService(),
plugins.RegisterLogs(bot) plugins.RegisterAdmin(),
plugins.RegisterLogs(),
plugins.RegisterEconomy(bot),
plugins.RegisterWaifus(),
plugins.RegisterRP(),
plugins.RegisterAi(),
plugins.RegisterFun(),
)
plugins.RegisterEconomy(bot)
//plugins.RegisterRelations(bot) //plugins.RegisterRelations(bot)
plugins.RegisterWaifus(bot)
plugins.RegisterRP(bot)
plugins.RegisterAi(bot)
plugins.RegisterFun(bot)
if err := bot.AutoGenerateCommands(); err != nil { if err := bot.AutoGenerateCommands(); err != nil {
panic(err) panic(err)

View File

@@ -2,9 +2,10 @@ package plugins
import ( import (
"encoding/json" "encoding/json"
"kurumibot/database/psql"
"path/filepath" "path/filepath"
"strings" "strings"
"ymgb/database"
"ymgb/database/psql"
"git.nix13.pw/scuroneko/laniakea" "git.nix13.pw/scuroneko/laniakea"
"git.nix13.pw/scuroneko/laniakea/tgapi" "git.nix13.pw/scuroneko/laniakea/tgapi"
@@ -12,18 +13,18 @@ import (
"github.com/vinovest/sqlx" "github.com/vinovest/sqlx"
) )
func RegisterAdmin(b *laniakea.Bot) { func RegisterAdmin() *laniakea.Plugin[database.Context] {
p := laniakea.NewPlugin("Admin") p := laniakea.NewPlugin[database.Context]("Admin")
p.AddCommand(laniakea.NewCommand(uploadPhoto, "uploadPhoto").SkipCommandAutoGen()) p.AddCommand(laniakea.NewCommand(uploadPhoto, "uploadPhoto").SkipCommandAutoGen())
p.AddCommand(laniakea.NewCommand(emojiId, "emojiId").SkipCommandAutoGen()) p.AddCommand(laniakea.NewCommand(emojiId, "emojiId").SkipCommandAutoGen())
p.AddCommand(laniakea.NewCommand(getProxy, "proxy").SkipCommandAutoGen()) p.AddCommand(laniakea.NewCommand(getProxy, "proxy").SkipCommandAutoGen())
p.AddCommand(laniakea.NewCommand(execSql, "sql").SkipCommandAutoGen()) p.AddCommand(laniakea.NewCommand(execSql, "sql").SkipCommandAutoGen())
p.AddMiddleware(AdminMiddleware()) p.AddMiddleware(AdminMiddleware())
b.AddPlugins(p) return p
} }
func AdminMiddleware() laniakea.Middleware { func AdminMiddleware() laniakea.Middleware[database.Context] {
m := laniakea.NewMiddleware("AdminMiddleware", func(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) bool { m := laniakea.NewMiddleware("AdminMiddleware", func(ctx *laniakea.MsgContext, db *database.Context) bool {
rep := psql.NewUserRepository(db) rep := psql.NewUserRepository(db)
u, err := rep.GetById(ctx.FromID) u, err := rep.GetById(ctx.FromID)
if err != nil { if err != nil {
@@ -34,12 +35,12 @@ func AdminMiddleware() laniakea.Middleware {
return *m return *m
} }
func execSql(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func execSql(ctx *laniakea.MsgContext, db *database.Context) {
stmt := strings.Join(ctx.Args, " ") stmt := strings.Join(ctx.Args, " ")
stmt = db.PostgresSQL.Rebind(stmt) stmt = db.Postgres.Rebind(stmt)
var res []map[string]any var res []map[string]any
r, err := db.PostgresSQL.Query(stmt) r, err := db.Postgres.Query(stmt)
if err != nil { if err != nil {
ctx.Error(err) ctx.Error(err)
return return
@@ -61,7 +62,7 @@ func execSql(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
} }
ctx.Answerf("`%s`", data) ctx.Answerf("`%s`", data)
} }
func getProxy(ctx *laniakea.MsgContext, _ *laniakea.DatabaseContext) { func getProxy(ctx *laniakea.MsgContext, _ *database.Context) {
ruProxy := "tg://proxy?port=3128&secret=7qaZyfQN-IQ7ZMwrR_zWnHBvem9uLnJ1&server=185.231.245.25" ruProxy := "tg://proxy?port=3128&secret=7qaZyfQN-IQ7ZMwrR_zWnHBvem9uLnJ1&server=185.231.245.25"
fiProxy := "tg://proxy?port=3128&secret=7vmNtw_233xvIRFvImm2PLtvem9uLnJ1&server=46.243.6.125" fiProxy := "tg://proxy?port=3128&secret=7vmNtw_233xvIRFvImm2PLtvem9uLnJ1&server=46.243.6.125"
kb := laniakea.NewInlineKeyboard(1) kb := laniakea.NewInlineKeyboard(1)
@@ -69,7 +70,7 @@ func getProxy(ctx *laniakea.MsgContext, _ *laniakea.DatabaseContext) {
kb.AddUrlButtonStyle("🇫🇮Finland", laniakea.ButtonStylePrimary, fiProxy) kb.AddUrlButtonStyle("🇫🇮Finland", laniakea.ButtonStylePrimary, fiProxy)
ctx.Keyboard("Доступные прокси", kb) ctx.Keyboard("Доступные прокси", kb)
} }
func emojiId(ctx *laniakea.MsgContext, _ *laniakea.DatabaseContext) { func emojiId(ctx *laniakea.MsgContext, _ *database.Context) {
var id string var id string
for _, e := range ctx.Msg.Entities { for _, e := range ctx.Msg.Entities {
if e.Type != tgapi.MessageEntityCustomEmoji { if e.Type != tgapi.MessageEntityCustomEmoji {
@@ -80,7 +81,7 @@ func emojiId(ctx *laniakea.MsgContext, _ *laniakea.DatabaseContext) {
} }
ctx.Answer(id) ctx.Answer(id)
} }
func uploadPhoto(ctx *laniakea.MsgContext, _ *laniakea.DatabaseContext) { func uploadPhoto(ctx *laniakea.MsgContext, _ *database.Context) {
ctx.SendAction(tgapi.ChatActionUploadPhoto) ctx.SendAction(tgapi.ChatActionUploadPhoto)
photoId := ctx.Msg.Photo.Last().FileID photoId := ctx.Msg.Photo.Last().FileID
f, err := ctx.Api.GetFile(tgapi.GetFileP{FileId: photoId}) f, err := ctx.Api.GetFile(tgapi.GetFileP{FileId: photoId})
@@ -90,7 +91,7 @@ func uploadPhoto(ctx *laniakea.MsgContext, _ *laniakea.DatabaseContext) {
} }
u := tgapi.NewUploader(ctx.Api) u := tgapi.NewUploader(ctx.Api)
defer u.Close() defer u.Close()
content, err := ctx.Bot.GetFileByLink(f.FilePath) content, err := ctx.Api.GetFileByLink(f.FilePath)
if err != nil { if err != nil {
ctx.Error(err) ctx.Error(err)
return return

View File

@@ -1,21 +1,22 @@
package plugins package plugins
import ( import (
"kurumibot/database/mdb"
"kurumibot/database/red"
"kurumibot/utils/ai"
"strings" "strings"
"ymgb/database"
"ymgb/database/mdb"
"ymgb/database/red"
"ymgb/utils/ai"
"git.nix13.pw/scuroneko/laniakea" "git.nix13.pw/scuroneko/laniakea"
) )
func RegisterAi(bot *laniakea.Bot) { func RegisterAi() *laniakea.Plugin[database.Context] {
p := laniakea.NewPlugin("AI") p := laniakea.NewPlugin[database.Context]("AI")
p.AddCommand(p.NewCommand(gpt, "gpt").SkipCommandAutoGen()) p.AddCommand(p.NewCommand(gpt, "gpt").SkipCommandAutoGen())
bot.AddPlugins(p) return p
} }
func gpt(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func gpt(ctx *laniakea.MsgContext, db *database.Context) {
q := strings.Join(ctx.Args, " ") q := strings.Join(ctx.Args, " ")
api := ai.NewOpenAIAPI(ai.GPTBaseUrl, "", "anthropic/claude-sonnet-4") api := ai.NewOpenAIAPI(ai.GPTBaseUrl, "", "anthropic/claude-sonnet-4")
defer api.Close() defer api.Close()

View File

@@ -2,20 +2,21 @@ package plugins
import ( import (
"fmt" "fmt"
"kurumibot/database/psql"
"kurumibot/utils"
"math" "math"
"math/rand/v2" "math/rand/v2"
"strconv" "strconv"
"strings" "strings"
"time" "time"
"ymgb/database"
"ymgb/database/psql"
"ymgb/utils"
"git.nix13.pw/scuroneko/laniakea" "git.nix13.pw/scuroneko/laniakea"
"github.com/shopspring/decimal" "github.com/shopspring/decimal"
) )
func RegisterEconomy(bot *laniakea.Bot) { func RegisterEconomy(bot *laniakea.Bot[database.Context]) *laniakea.Plugin[database.Context] {
p := laniakea.NewPlugin("Economy") p := laniakea.NewPlugin[database.Context]("Economy")
p.AddCommand(p.NewCommand(profile, "profile")) p.AddCommand(p.NewCommand(profile, "profile"))
p.AddCommand(p.NewCommand(profile, "профиль").SkipCommandAutoGen()) p.AddCommand(p.NewCommand(profile, "профиль").SkipCommandAutoGen())
p.AddCommand(p.NewCommand(work, "work")) p.AddCommand(p.NewCommand(work, "work"))
@@ -33,14 +34,13 @@ func RegisterEconomy(bot *laniakea.Bot) {
p.AddCommand(p.NewCommand(aboutGroup, "group")) p.AddCommand(p.NewCommand(aboutGroup, "group"))
p.AddCommand(p.NewCommand(aboutGroup, "о группе").SkipCommandAutoGen()) p.AddCommand(p.NewCommand(aboutGroup, "о группе").SkipCommandAutoGen())
bot.AddRunner(laniakea.NewRunner( bot.AddRunner(*laniakea.NewRunner[database.Context](
"economy.PassiveIncome", passiveIncome, "economy.PassiveIncome", passiveIncome,
).Timeout(time.Minute).Build()) ).Timeout(time.Minute))
return p
bot.AddPlugins(p)
} }
func passiveIncome(b *laniakea.Bot) error { func passiveIncome(b *laniakea.Bot[database.Context]) error {
ctx := b.GetDBContext() ctx := b.GetDBContext()
waifuRep := psql.NewWaifuRepository(ctx) waifuRep := psql.NewWaifuRepository(ctx)
userRep := psql.NewUserRepository(ctx) userRep := psql.NewUserRepository(ctx)
@@ -49,7 +49,7 @@ func passiveIncome(b *laniakea.Bot) error {
if err != nil { if err != nil {
return err return err
} }
b.Logger().Debugf("Loaded %d users\n", len(users)) b.GetLogger().Debugf("Loaded %d users\n", len(users))
for _, user := range users { for _, user := range users {
if user.Business == nil && user.Maid == nil && user.Miner == nil { if user.Business == nil && user.Maid == nil && user.Miner == nil {
@@ -76,7 +76,7 @@ func passiveIncome(b *laniakea.Bot) error {
waifus, err := waifuRep.GetByUserId(user.ID) waifus, err := waifuRep.GetByUserId(user.ID)
if err != nil { if err != nil {
b.Logger().Error(err) b.GetLogger().Errorln(err)
continue continue
} }
for _, waifu := range waifus { for _, waifu := range waifus {
@@ -96,16 +96,16 @@ func passiveIncome(b *laniakea.Bot) error {
_, err = userRep.Update(&user) _, err = userRep.Update(&user)
if err != nil { if err != nil {
b.Logger().Error(err) b.GetLogger().Errorln(err)
continue continue
} }
b.Logger().Debug(fmt.Sprintf("У %d было пассивно собрано. След. сбор через час\n", user.ID)) b.GetLogger().Debugln(fmt.Sprintf("У %d было пассивно собрано. След. сбор через час\n", user.ID))
} }
return nil return nil
} }
func profile(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func profile(ctx *laniakea.MsgContext, db *database.Context) {
rep := psql.NewUserRepository(db) rep := psql.NewUserRepository(db)
user, err := rep.GetOrCreate(ctx.FromID, ctx.Msg.From.FirstName) user, err := rep.GetOrCreate(ctx.FromID, ctx.Msg.From.FirstName)
if err != nil { if err != nil {
@@ -158,7 +158,7 @@ func profile(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
ctx.Answer(strings.Join(out, "\n")) ctx.Answer(strings.Join(out, "\n"))
} }
func work(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func work(ctx *laniakea.MsgContext, db *database.Context) {
rep := psql.NewUserRepository(db) rep := psql.NewUserRepository(db)
user, err := rep.GetOrCreate(ctx.FromID, ctx.Update.Message.From.FirstName) user, err := rep.GetOrCreate(ctx.FromID, ctx.Update.Message.From.FirstName)
if err != nil { if err != nil {
@@ -207,7 +207,7 @@ func work(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
)) ))
} }
func collect(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func collect(ctx *laniakea.MsgContext, db *database.Context) {
rep := psql.NewUserRepository(db) rep := psql.NewUserRepository(db)
user, err := rep.GetOrCreate(ctx.FromID, ctx.Update.Message.From.FirstName) user, err := rep.GetOrCreate(ctx.FromID, ctx.Update.Message.From.FirstName)
if err != nil { if err != nil {
@@ -312,11 +312,11 @@ func collect(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
ctx.Answer(strings.Join(out, "\n")) ctx.Answer(strings.Join(out, "\n"))
} }
func code(ctx *laniakea.MsgContext, _ *laniakea.DatabaseContext) { func code(ctx *laniakea.MsgContext, _ *database.Context) {
// user, err := database.Get // user, err := database.Get
} }
func vacancies(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func vacancies(ctx *laniakea.MsgContext, db *database.Context) {
worksRep := psql.NewWorkRepository(db) worksRep := psql.NewWorkRepository(db)
works, err := worksRep.GetAll() works, err := worksRep.GetAll()
@@ -336,7 +336,7 @@ func vacancies(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
ctx.Answer(strings.Join(out, "\n")) ctx.Answer(strings.Join(out, "\n"))
} }
func getAJob(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func getAJob(ctx *laniakea.MsgContext, db *database.Context) {
if len(ctx.Args) == 0 { if len(ctx.Args) == 0 {
ctx.Answer("Недостаточно аргументов") ctx.Answer("Недостаточно аргументов")
return return
@@ -372,7 +372,7 @@ func getAJob(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
ctx.Answer("Ты успешно устроился на работу!") ctx.Answer("Ты успешно устроился на работу!")
} }
func aboutGroup(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func aboutGroup(ctx *laniakea.MsgContext, db *database.Context) {
userRep := psql.NewUserRepository(db) userRep := psql.NewUserRepository(db)
user, err := userRep.GetOrCreate(ctx.FromID, ctx.Msg.From.FirstName) user, err := userRep.GetOrCreate(ctx.FromID, ctx.Msg.From.FirstName)
if err != nil { if err != nil {

View File

@@ -2,15 +2,16 @@ package plugins
import ( import (
"strings" "strings"
"ymgb/database"
"git.nix13.pw/scuroneko/laniakea" "git.nix13.pw/scuroneko/laniakea"
) )
func RegisterFun(bot *laniakea.Bot) { func RegisterFun() *laniakea.Plugin[database.Context] {
p := laniakea.NewPlugin("Fun") p := laniakea.NewPlugin[database.Context]("Fun")
p.AddCommand(p.NewCommand(beautyFont, "bf")) p.AddCommand(p.NewCommand(beautyFont, "bf"))
p.AddCommand(p.NewCommand(beautyFontHeart, "bfh")) p.AddCommand(p.NewCommand(beautyFontHeart, "bfh"))
bot.AddPlugins(p) return p
} }
var ligatures = map[string]string{ var ligatures = map[string]string{
@@ -22,7 +23,7 @@ var ligatures = map[string]string{
"v": "𝑣", "w": "𝑤", "x": "𝑥", "y": "𝑦", "z": "𝑧", "v": "𝑣", "w": "𝑤", "x": "𝑥", "y": "𝑦", "z": "𝑧",
} }
func beautyFont(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func beautyFont(ctx *laniakea.MsgContext, _ *database.Context) {
m := strings.Join(ctx.Args, " ") m := strings.Join(ctx.Args, " ")
out := "" out := ""
for _, r := range m { for _, r := range m {
@@ -36,7 +37,7 @@ func beautyFont(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
ctx.Answer(out) ctx.Answer(out)
} }
func beautyFontHeart(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func beautyFontHeart(ctx *laniakea.MsgContext, _ *database.Context) {
m := strings.Join(ctx.Args, " ") m := strings.Join(ctx.Args, " ")
out := "" out := ""
for _, r := range m { for _, r := range m {

View File

@@ -4,28 +4,29 @@ import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"fmt" "fmt"
"kurumibot/database/mdb"
"kurumibot/utils"
"strings" "strings"
"time" "time"
"ymgb/database"
"ymgb/database/mdb"
"ymgb/utils"
"git.nix13.pw/scuroneko/extypes" "git.nix13.pw/scuroneko/extypes"
"git.nix13.pw/scuroneko/laniakea" "git.nix13.pw/scuroneko/laniakea"
"git.nix13.pw/scuroneko/slog" "git.nix13.pw/scuroneko/slog"
) )
func RegisterLogs(bot *laniakea.Bot) { func RegisterLogs() *laniakea.Plugin[database.Context] {
p := laniakea.NewPlugin("Logs") p := laniakea.NewPlugin[database.Context]("Logs")
p.AddCommand(p.NewCommand(getLogs, "logs").SkipCommandAutoGen()) p.AddCommand(p.NewCommand(getLogs, "logs").SkipCommandAutoGen())
p.AddCommand(p.NewCommand(getMsgLogs, "msglogs").SkipCommandAutoGen()) p.AddCommand(p.NewCommand(getMsgLogs, "msglogs").SkipCommandAutoGen())
p.AddMiddleware(AdminMiddleware()) p.AddMiddleware(AdminMiddleware())
bot.AddPlugins(p) return p
} }
func InitLogMiddleware() laniakea.Middleware { func InitLogMiddleware() laniakea.Middleware[database.Context] {
return *laniakea.NewMiddleware("LogMiddleware", logMiddleware).SetAsync(true) return *laniakea.NewMiddleware("LogMiddleware", logMiddleware).SetAsync(true)
} }
func getLogs(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func getLogs(ctx *laniakea.MsgContext, db *database.Context) {
logs, err := mdb.GetConsoleLogs(db) logs, err := mdb.GetConsoleLogs(db)
if err != nil { if err != nil {
ctx.Error(err) ctx.Error(err)
@@ -34,7 +35,7 @@ func getLogs(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
out := encodeLogs(logs) out := encodeLogs(logs)
ctx.Answer(strings.Join(out, "")) ctx.Answer(strings.Join(out, ""))
} }
func getMsgLogs(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func getMsgLogs(ctx *laniakea.MsgContext, db *database.Context) {
logs, err := mdb.GetMessageLogs(db) logs, err := mdb.GetMessageLogs(db)
if err != nil { if err != nil {
ctx.Error(err) ctx.Error(err)
@@ -61,7 +62,7 @@ func encodeLogs[T comparable](logs extypes.Slice[T]) extypes.Slice[string] {
return out return out
} }
func logMiddleware(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) bool { func logMiddleware(ctx *laniakea.MsgContext, db *database.Context) bool {
if ctx.Msg == nil { if ctx.Msg == nil {
return true return true
} }
@@ -70,18 +71,18 @@ func logMiddleware(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) bool
SenderID: ctx.FromID, SenderID: ctx.FromID,
ChatID: ctx.Msg.Chat.ID, ChatID: ctx.Msg.Chat.ID,
Text: ctx.Msg.Text, Text: ctx.Msg.Text,
TimeStamp: time.Now().Unix(), TimeStamp: int64(ctx.Msg.Date),
} }
err := mdb.WriteMessageLog(db, entry) err := mdb.WriteMessageLog(db, entry)
if err != nil { if err != nil {
ctx.Bot.Logger().Errorln(err) ctx.Error(err)
} }
return true return true
} }
type DatabaseWriter struct { type DatabaseWriter struct {
slog.LoggerWriter slog.LoggerWriter
db *laniakea.DatabaseContext db *database.Context
} }
func (w *DatabaseWriter) Print(level slog.LogLevel, prefix string, traceback []*slog.MethodTraceback, messages ...any) error { func (w *DatabaseWriter) Print(level slog.LogLevel, prefix string, traceback []*slog.MethodTraceback, messages ...any) error {
@@ -102,6 +103,6 @@ func (w *DatabaseWriter) Print(level slog.LogLevel, prefix string, traceback []*
err := mdb.WriteConsoleLog(w.db, entry) err := mdb.WriteConsoleLog(w.db, entry)
return err return err
} }
func DatabaseLogger(db *laniakea.DatabaseContext) slog.LoggerWriter { func DatabaseLogger(db *database.Context) slog.LoggerWriter {
return &DatabaseWriter{db: db} return &DatabaseWriter{db: db}
} }

View File

@@ -1,8 +1,12 @@
package plugins package plugins
import "git.nix13.pw/scuroneko/laniakea" import (
"ymgb/database"
func RegisterRelations(b *laniakea.Bot) { "git.nix13.pw/scuroneko/laniakea"
p := laniakea.NewPlugin("Relations") )
b.AddPlugins(p)
func RegisterRelations() *laniakea.Plugin[database.Context] {
p := laniakea.NewPlugin[database.Context]("Relations")
return p
} }

View File

@@ -4,14 +4,15 @@ import (
"database/sql" "database/sql"
"errors" "errors"
"fmt" "fmt"
"kurumibot/database/mdb"
"kurumibot/database/psql"
"kurumibot/database/red"
"kurumibot/utils"
"kurumibot/utils/ai"
"log" "log"
"strconv" "strconv"
"strings" "strings"
"ymgb/database"
"ymgb/database/mdb"
"ymgb/database/psql"
"ymgb/database/red"
"ymgb/utils"
"ymgb/utils/ai"
"git.nix13.pw/scuroneko/extypes" "git.nix13.pw/scuroneko/extypes"
"git.nix13.pw/scuroneko/laniakea" "git.nix13.pw/scuroneko/laniakea"
@@ -19,8 +20,8 @@ import (
"github.com/google/uuid" "github.com/google/uuid"
) )
func RegisterRP(bot *laniakea.Bot) { func RegisterRP() *laniakea.Plugin[database.Context] {
rp := laniakea.NewPlugin("RP") rp := laniakea.NewPlugin[database.Context]("RP")
rp.AddCommand(rp.NewCommand(rpUserPromptSet, "rpuserpset")) rp.AddCommand(rp.NewCommand(rpUserPromptSet, "rpuserpset"))
rp.AddCommand(rp.NewCommand(rpInfo, "rp").SetDescription("РП профиль пользователя")) rp.AddCommand(rp.NewCommand(rpInfo, "rp").SetDescription("РП профиль пользователя"))
rp.AddCommand(rp.NewCommand(rpInfo, "рп").SkipCommandAutoGen()) rp.AddCommand(rp.NewCommand(rpInfo, "рп").SkipCommandAutoGen())
@@ -50,10 +51,10 @@ func RegisterRP(bot *laniakea.Bot) {
rp.AddPayload(rp.NewCommand(compressSettingStage2, "rp.compress_setting_s2")) rp.AddPayload(rp.NewCommand(compressSettingStage2, "rp.compress_setting_s2"))
rp.AddPayload(rp.NewCommand(compressSetting, "rp.compress_setting")) rp.AddPayload(rp.NewCommand(compressSetting, "rp.compress_setting"))
bot.AddPlugins(rp) return rp
} }
func rpInfo(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func rpInfo(ctx *laniakea.MsgContext, db *database.Context) {
userRep := psql.NewUserRepository(db) userRep := psql.NewUserRepository(db)
_, err := userRep.GetOrCreate(ctx.FromID, ctx.From.FirstName) _, err := userRep.GetOrCreate(ctx.FromID, ctx.From.FirstName)
if err != nil { if err != nil {
@@ -135,7 +136,7 @@ func rpInfo(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
} }
} }
func rpWaifuList(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func rpWaifuList(ctx *laniakea.MsgContext, db *database.Context) {
waifuRep := psql.NewWaifuRepository(db) waifuRep := psql.NewWaifuRepository(db)
var waifus extypes.Slice[*psql.Waifu] var waifus extypes.Slice[*psql.Waifu]
@@ -176,7 +177,7 @@ func rpWaifuList(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
ctx.EditCallback(strings.Join(out, "\n"), kb) ctx.EditCallback(strings.Join(out, "\n"), kb)
ctx.AnswerCbQuery() ctx.AnswerCbQuery()
} }
func rpWaifuSet(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func rpWaifuSet(ctx *laniakea.MsgContext, db *database.Context) {
waifuId, err := strconv.Atoi(ctx.Args[0]) waifuId, err := strconv.Atoi(ctx.Args[0])
if err != nil { if err != nil {
ctx.Error(err) ctx.Error(err)
@@ -201,7 +202,7 @@ func rpWaifuSet(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
ctx.AnswerCbQuery() ctx.AnswerCbQuery()
} }
func rpPresetsList(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func rpPresetsList(ctx *laniakea.MsgContext, db *database.Context) {
rep := psql.NewRPRepository(db) rep := psql.NewRPRepository(db)
presets, err := rep.GetAllPresets() presets, err := rep.GetAllPresets()
if err != nil { if err != nil {
@@ -222,7 +223,7 @@ func rpPresetsList(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
ctx.EditCallback(strings.Join(out, "\n"), kb) ctx.EditCallback(strings.Join(out, "\n"), kb)
ctx.AnswerCbQuery() ctx.AnswerCbQuery()
} }
func rpPresetSet(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func rpPresetSet(ctx *laniakea.MsgContext, db *database.Context) {
if len(ctx.Args) == 0 || ctx.Args[0] == "" { if len(ctx.Args) == 0 || ctx.Args[0] == "" {
return return
} }
@@ -249,7 +250,7 @@ func rpPresetSet(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
ctx.AnswerCbQuery() ctx.AnswerCbQuery()
} }
func rpModelList(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func rpModelList(ctx *laniakea.MsgContext, db *database.Context) {
rep := psql.NewAIRepository(db) rep := psql.NewAIRepository(db)
models, err := rep.GetAllModels() models, err := rep.GetAllModels()
if err != nil { if err != nil {
@@ -268,7 +269,7 @@ func rpModelList(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
ctx.EditCallback(strings.Join(out, "\n"), kb) ctx.EditCallback(strings.Join(out, "\n"), kb)
ctx.AnswerCbQuery() ctx.AnswerCbQuery()
} }
func rpModelSet(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func rpModelSet(ctx *laniakea.MsgContext, db *database.Context) {
rep := psql.NewRPRepository(db) rep := psql.NewRPRepository(db)
user, err := rep.GetOrCreateUser(int64(ctx.FromID)) user, err := rep.GetOrCreateUser(int64(ctx.FromID))
if err != nil { if err != nil {
@@ -293,7 +294,7 @@ func rpModelSet(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
ctx.AnswerCbQuery() ctx.AnswerCbQuery()
} }
func rpScenarioList(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func rpScenarioList(ctx *laniakea.MsgContext, db *database.Context) {
rep := psql.NewRPRepository(db) rep := psql.NewRPRepository(db)
scenarios, err := rep.GetAllScenarios() scenarios, err := rep.GetAllScenarios()
if err != nil { if err != nil {
@@ -309,7 +310,7 @@ func rpScenarioList(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
ctx.EditCallback("Список сценариев\n"+strings.Join(out, "\n"), kb) ctx.EditCallback("Список сценариев\n"+strings.Join(out, "\n"), kb)
ctx.AnswerCbQuery() ctx.AnswerCbQuery()
} }
func rpSettingList(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func rpSettingList(ctx *laniakea.MsgContext, db *database.Context) {
rep := psql.NewRPRepository(db) rep := psql.NewRPRepository(db)
settings, err := rep.GetAllSettings() settings, err := rep.GetAllSettings()
if err != nil { if err != nil {
@@ -327,7 +328,7 @@ func rpSettingList(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
ctx.AnswerCbQuery() ctx.AnswerCbQuery()
} }
func chatStat(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func chatStat(ctx *laniakea.MsgContext, db *database.Context) {
redisRpRep := red.NewRPRepository(db) redisRpRep := red.NewRPRepository(db)
chat, err := redisRpRep.GetChat(ctx.FromID) chat, err := redisRpRep.GetChat(ctx.FromID)
if err != nil { if err != nil {
@@ -368,7 +369,7 @@ func chatStat(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
ctx.AnswerCbQuery() ctx.AnswerCbQuery()
} }
func newChatStage1(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func newChatStage1(ctx *laniakea.MsgContext, db *database.Context) {
// Выбор сеттинга // Выбор сеттинга
rep := psql.NewRPRepository(db) rep := psql.NewRPRepository(db)
settings, err := rep.GetAllSettings() settings, err := rep.GetAllSettings()
@@ -391,7 +392,7 @@ func newChatStage1(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
ctx.EditCallback(strings.Join(out, "\n"), kb) ctx.EditCallback(strings.Join(out, "\n"), kb)
ctx.AnswerCbQuery() ctx.AnswerCbQuery()
} }
func newChatStage2(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func newChatStage2(ctx *laniakea.MsgContext, db *database.Context) {
// Выбор сценария // Выбор сценария
if len(ctx.Args) == 0 { if len(ctx.Args) == 0 {
ctx.Error(fmt.Errorf("zero args len")) ctx.Error(fmt.Errorf("zero args len"))
@@ -455,7 +456,7 @@ func newChatStage2(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
//ctx.AnswerCbQueryText(fmt.Sprintf("Ты выбрал сеттинг %s", setting.Name)) //ctx.AnswerCbQueryText(fmt.Sprintf("Ты выбрал сеттинг %s", setting.Name))
ctx.AnswerCbQuery() ctx.AnswerCbQuery()
} }
func newChat(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func newChat(ctx *laniakea.MsgContext, db *database.Context) {
redisRpRep := red.NewRPRepository(db) redisRpRep := red.NewRPRepository(db)
psqlRpRep := psql.NewRPRepository(db) psqlRpRep := psql.NewRPRepository(db)
waifuId := redisRpRep.GetSelectedWaifu(ctx.FromID) waifuId := redisRpRep.GetSelectedWaifu(ctx.FromID)
@@ -536,7 +537,7 @@ func newChat(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
ctx.AnswerCbQuery() ctx.AnswerCbQuery()
} }
func rpUserPromptSet(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func rpUserPromptSet(ctx *laniakea.MsgContext, db *database.Context) {
if len(ctx.Args) == 0 || ctx.Args[0] == "" { if len(ctx.Args) == 0 || ctx.Args[0] == "" {
return return
} }
@@ -556,7 +557,7 @@ func rpUserPromptSet(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
ctx.Answer("Описание пользователя было обновлено") ctx.Answer("Описание пользователя было обновлено")
} }
func _getChatHistory(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) ([]ai.Message, error) { func _getChatHistory(ctx *laniakea.MsgContext, db *database.Context) ([]ai.Message, error) {
redRep := red.NewRPRepository(db) redRep := red.NewRPRepository(db)
psqlRep := psql.NewRPRepository(db) psqlRep := psql.NewRPRepository(db)
waifuRep := psql.NewWaifuRepository(db) waifuRep := psql.NewWaifuRepository(db)
@@ -620,7 +621,7 @@ func _getChatHistory(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) ([]
return messages, nil return messages, nil
} }
func generate(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func generate(ctx *laniakea.MsgContext, db *database.Context) {
redisRpRep := red.NewRPRepository(db) redisRpRep := red.NewRPRepository(db)
rpRep := psql.NewRPRepository(db) rpRep := psql.NewRPRepository(db)
waifuId := redisRpRep.GetSelectedWaifu(ctx.FromID) waifuId := redisRpRep.GetSelectedWaifu(ctx.FromID)
@@ -717,7 +718,7 @@ func generate(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
} }
} }
func regenerateResponse(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func regenerateResponse(ctx *laniakea.MsgContext, db *database.Context) {
ctx.AnswerCbQueryText("Запущена повторная генерация…") ctx.AnswerCbQueryText("Запущена повторная генерация…")
redRep := red.NewRPRepository(db) redRep := red.NewRPRepository(db)
@@ -789,7 +790,7 @@ func regenerateResponse(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext)
ctx.EditCallback(laniakea.EscapeMarkdown(res.Choices[0].Message.Content), kb) ctx.EditCallback(laniakea.EscapeMarkdown(res.Choices[0].Message.Content), kb)
} }
func compress(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func compress(ctx *laniakea.MsgContext, db *database.Context) {
ctx.AnswerCbQueryText("Запущено сжатие чата…") ctx.AnswerCbQueryText("Запущено сжатие чата…")
_compress(ctx, db) _compress(ctx, db)
kb := laniakea.NewInlineKeyboard(1) kb := laniakea.NewInlineKeyboard(1)
@@ -797,7 +798,7 @@ func compress(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
kb.AddCallbackButtonStyle("На главную", laniakea.ButtonStyleDanger, "rp.info") kb.AddCallbackButtonStyle("На главную", laniakea.ButtonStyleDanger, "rp.info")
} }
func _compress(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func _compress(ctx *laniakea.MsgContext, db *database.Context) {
redisRpRep := red.NewRPRepository(db) redisRpRep := red.NewRPRepository(db)
waifuId := redisRpRep.GetSelectedWaifu(ctx.FromID) waifuId := redisRpRep.GetSelectedWaifu(ctx.FromID)
if waifuId == 0 { if waifuId == 0 {
@@ -902,7 +903,7 @@ var tokenMethodCount = []int{
16, 32, 64, 128, 256, 16, 32, 64, 128, 256,
} }
func compressSettingStage1(ctx *laniakea.MsgContext, _ *laniakea.DatabaseContext) { func compressSettingStage1(ctx *laniakea.MsgContext, _ *database.Context) {
kb := laniakea.NewInlineKeyboard(2) kb := laniakea.NewInlineKeyboard(2)
kb.AddCallbackButton("По сообщениям", "rp.compress_setting_s2", "messages") kb.AddCallbackButton("По сообщениям", "rp.compress_setting_s2", "messages")
kb.AddCallbackButton("По токенам", "rp.compress_setting_s2", "tokens") kb.AddCallbackButton("По токенам", "rp.compress_setting_s2", "tokens")
@@ -917,7 +918,7 @@ func compressSettingStage1(ctx *laniakea.MsgContext, _ *laniakea.DatabaseContext
ctx.EditCallback(strings.Join(out, "\n"), kb) ctx.EditCallback(strings.Join(out, "\n"), kb)
} }
func compressSettingStage2(ctx *laniakea.MsgContext, _ *laniakea.DatabaseContext) { func compressSettingStage2(ctx *laniakea.MsgContext, _ *database.Context) {
if len(ctx.Args) == 0 { if len(ctx.Args) == 0 {
return return
} }
@@ -942,7 +943,7 @@ func compressSettingStage2(ctx *laniakea.MsgContext, _ *laniakea.DatabaseContext
kb.AddCallbackButtonStyle("На главную", laniakea.ButtonStyleDanger, "rp.info") kb.AddCallbackButtonStyle("На главную", laniakea.ButtonStyleDanger, "rp.info")
ctx.EditCallback(strings.Join(out, "\n"), kb) ctx.EditCallback(strings.Join(out, "\n"), kb)
} }
func compressSetting(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func compressSetting(ctx *laniakea.MsgContext, db *database.Context) {
rep := psql.NewRPRepository(db) rep := psql.NewRPRepository(db)
user, err := rep.GetUser(int64(ctx.FromID)) user, err := rep.GetUser(int64(ctx.FromID))
if err != nil { if err != nil {

View File

@@ -2,23 +2,24 @@ package plugins
import ( import (
"fmt" "fmt"
"kurumibot/utils"
"runtime" "runtime"
"strings" "strings"
"ymgb/database"
"ymgb/utils"
"git.nix13.pw/scuroneko/laniakea" "git.nix13.pw/scuroneko/laniakea"
) )
func RegisterService(bot *laniakea.Bot) { func RegisterService() *laniakea.Plugin[database.Context] {
p := laniakea.NewPlugin("service") p := laniakea.NewPlugin[database.Context]("service")
p.AddPayload(p.NewCommand(generalClose, "general.close")) p.AddPayload(p.NewCommand(generalClose, "general.close"))
p.AddCommand(p.NewCommand(about, "about")) p.AddCommand(p.NewCommand(about, "about"))
p.AddCommand(p.NewCommand(about, "о боте").SkipCommandAutoGen()) p.AddCommand(p.NewCommand(about, "о боте").SkipCommandAutoGen())
bot.AddPlugins(p) return p
} }
func about(ctx *laniakea.MsgContext, _ *laniakea.DatabaseContext) { func about(ctx *laniakea.MsgContext, _ *database.Context) {
out := []string{ out := []string{
fmt.Sprintf("Версия Go: %s", runtime.Version()[2:]), fmt.Sprintf("Версия Go: %s", runtime.Version()[2:]),
fmt.Sprintf("Версия Laniakea: %s", laniakea.VersionString), fmt.Sprintf("Версия Laniakea: %s", laniakea.VersionString),
@@ -32,7 +33,7 @@ func about(ctx *laniakea.MsgContext, _ *laniakea.DatabaseContext) {
ctx.Keyboard(strings.Join(out, "\n"), kb) ctx.Keyboard(strings.Join(out, "\n"), kb)
} }
func generalClose(ctx *laniakea.MsgContext, _ *laniakea.DatabaseContext) { func generalClose(ctx *laniakea.MsgContext, _ *database.Context) {
ctx.CallbackDelete() ctx.CallbackDelete()
ctx.AnswerCbQuery() ctx.AnswerCbQuery()
} }

View File

@@ -2,19 +2,20 @@ package plugins
import ( import (
"fmt" "fmt"
"kurumibot/database/psql"
"kurumibot/utils"
"log" "log"
"strconv" "strconv"
"strings" "strings"
"time" "time"
"ymgb/database"
"ymgb/database/psql"
"ymgb/utils"
"git.nix13.pw/scuroneko/extypes" "git.nix13.pw/scuroneko/extypes"
"git.nix13.pw/scuroneko/laniakea" "git.nix13.pw/scuroneko/laniakea"
) )
func RegisterWaifus(bot *laniakea.Bot) { func RegisterWaifus() *laniakea.Plugin[database.Context] {
p := laniakea.NewPlugin("Waifus") p := laniakea.NewPlugin[database.Context]("Waifus")
p.AddCommand(p.NewCommand(myWaifu, "mywaifu")) p.AddCommand(p.NewCommand(myWaifu, "mywaifu"))
p.AddCommand(p.NewCommand(myWaifu, "моивайфу").SkipCommandAutoGen()) p.AddCommand(p.NewCommand(myWaifu, "моивайфу").SkipCommandAutoGen())
@@ -33,10 +34,10 @@ func RegisterWaifus(bot *laniakea.Bot) {
p.AddPayload(p.NewCommand(waifuNotImplemented, "waifu.confirm_buy")) p.AddPayload(p.NewCommand(waifuNotImplemented, "waifu.confirm_buy"))
p.AddPayload(p.NewCommand(waifuNotImplemented, "waifu.confirm_sell")) p.AddPayload(p.NewCommand(waifuNotImplemented, "waifu.confirm_sell"))
bot.AddPlugins(p) return p
} }
func myWaifu(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func myWaifu(ctx *laniakea.MsgContext, db *database.Context) {
userRep := psql.NewUserRepository(db) userRep := psql.NewUserRepository(db)
user, err := userRep.GetOrCreate(ctx.FromID, ctx.From.FirstName) user, err := userRep.GetOrCreate(ctx.FromID, ctx.From.FirstName)
if err != nil { if err != nil {
@@ -73,7 +74,7 @@ func myWaifu(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
} }
} }
func waifuList(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func waifuList(ctx *laniakea.MsgContext, db *database.Context) {
rep := psql.NewWaifuRepository(db) rep := psql.NewWaifuRepository(db)
waifus, err := rep.GetAll() waifus, err := rep.GetAll()
if err != nil { if err != nil {
@@ -108,7 +109,7 @@ func waifuList(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
} }
} }
func waifuSell(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func waifuSell(ctx *laniakea.MsgContext, db *database.Context) {
const CantSellWaifu = "Не удалось продать вайфу" const CantSellWaifu = "Не удалось продать вайфу"
waifuId, err := strconv.Atoi(ctx.Args[0]) waifuId, err := strconv.Atoi(ctx.Args[0])
@@ -147,11 +148,11 @@ func waifuSell(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
ctx.Keyboard(strings.Join(out, "\n"), kb) ctx.Keyboard(strings.Join(out, "\n"), kb)
} }
func buyWaifu(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func buyWaifu(ctx *laniakea.MsgContext, db *database.Context) {
} }
func waifuInfo(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func waifuInfo(ctx *laniakea.MsgContext, db *database.Context) {
if len(ctx.Args) != 1 { if len(ctx.Args) != 1 {
ctx.Answer("Не указан ID вайфу!") ctx.Answer("Не указан ID вайфу!")
return return
@@ -198,7 +199,7 @@ func waifuInfo(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
ctx.AnswerCbQuery() ctx.AnswerCbQuery()
} }
func waifuSearch(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { func waifuSearch(ctx *laniakea.MsgContext, db *database.Context) {
userRep := psql.NewUserRepository(db) userRep := psql.NewUserRepository(db)
user, err := userRep.GetOrCreate(ctx.FromID, ctx.Msg.From.FirstName) user, err := userRep.GetOrCreate(ctx.FromID, ctx.Msg.From.FirstName)
if err != nil { if err != nil {
@@ -265,7 +266,7 @@ func waifuSearch(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
} }
} }
func waifuNotImplemented(ctx *laniakea.MsgContext, _ *laniakea.DatabaseContext) { func waifuNotImplemented(ctx *laniakea.MsgContext, _ *database.Context) {
kb := laniakea.NewInlineKeyboard(2).AddCallbackButton("Мои вайфу", "waifu.my").AddCallbackButton("Все вайфу", "waifu.list") kb := laniakea.NewInlineKeyboard(2).AddCallbackButton("Мои вайфу", "waifu.my").AddCallbackButton("Все вайфу", "waifu.list")
ctx.EditCallback("Данная функция ещё не реализована", kb) ctx.EditCallback("Данная функция ещё не реализована", kb)
} }