laniakea v0.7
This commit is contained in:
@@ -3,4 +3,6 @@ TG_TOKEN=
|
|||||||
PREFIXES=/;!
|
PREFIXES=/;!
|
||||||
DEBUG=true
|
DEBUG=true
|
||||||
USE_REQ_LOG=true
|
USE_REQ_LOG=true
|
||||||
WRITE_TO_FILE=false
|
WRITE_TO_FILE=false
|
||||||
|
USE_TEST_SERVER=true
|
||||||
|
API_URL=http://127.0.0.1:8081
|
||||||
@@ -69,18 +69,18 @@ func (rep UserRepository) GetOrCreate(tgId int, name string) (*User, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (rep UserRepository) Create(id int, name string) (*User, error) {
|
func (rep UserRepository) Create(id int, name string) (*User, error) {
|
||||||
user := User{}
|
user := new(User)
|
||||||
err := rep.db.Get(user, "INSERT INTO users (id, name) VALUES ($1, $2) RETURNING *;", id, name)
|
err := rep.db.Get(user, "INSERT INTO users (id, name) VALUES ($1, $2) RETURNING *;", id, name)
|
||||||
return &user, err
|
return user, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rep UserRepository) GetById(telegramId int) (*User, error) {
|
func (rep UserRepository) GetById(telegramId int) (*User, error) {
|
||||||
user := User{}
|
user := new(User)
|
||||||
err := rep.db.Get(&user, "SELECT * FROM users WHERE id=$1;", telegramId)
|
err := rep.db.Get(user, "SELECT * FROM users WHERE id=$1;", telegramId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &user, err
|
return user, err
|
||||||
}
|
}
|
||||||
return rep.GetJoins(&user)
|
return rep.GetJoins(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rep UserRepository) GetJoins(user *User) (*User, error) {
|
func (rep UserRepository) GetJoins(user *User) (*User, error) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
services:
|
services:
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:18.1-alpine
|
image: postgres:18.2-alpine3.23
|
||||||
networks:
|
networks:
|
||||||
- bot
|
- bot
|
||||||
ports:
|
ports:
|
||||||
@@ -19,7 +19,7 @@ services:
|
|||||||
- ./scripts/postgres:/docker-entrypoint-initdb.d
|
- ./scripts/postgres:/docker-entrypoint-initdb.d
|
||||||
- postgres_data:/var/lib/postgresql/data
|
- postgres_data:/var/lib/postgresql/data
|
||||||
mongo:
|
mongo:
|
||||||
image: mongo:noble
|
image: mongo:8.2.5-noble
|
||||||
networks:
|
networks:
|
||||||
- bot
|
- bot
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
name: "kurumibot"
|
name: "ymbot"
|
||||||
include:
|
include:
|
||||||
- db.docker-compose.yml
|
- db.docker-compose.yml
|
||||||
services:
|
services:
|
||||||
@@ -20,7 +20,6 @@ services:
|
|||||||
postgres:
|
postgres:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
restart: true
|
restart: true
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
bot:
|
bot:
|
||||||
driver: bridge
|
driver: bridge
|
||||||
4
go.mod
4
go.mod
@@ -4,7 +4,7 @@ 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.6.2
|
git.nix13.pw/scuroneko/laniakea v0.7.1
|
||||||
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
|
||||||
@@ -15,7 +15,7 @@ require (
|
|||||||
go.mongodb.org/mongo-driver/v2 v2.5.0
|
go.mongodb.org/mongo-driver/v2 v2.5.0
|
||||||
)
|
)
|
||||||
|
|
||||||
//replace git.nix13.pw/scuroneko/laniakea v0.6.2 => ./laniakea
|
//replace git.nix13.pw/scuroneko/laniakea v0.7.0 => ./laniakea
|
||||||
//replace git.nix13.pw/scuroneko/extypes v1.2.0 => ../go-extypes
|
//replace git.nix13.pw/scuroneko/extypes v1.2.0 => ../go-extypes
|
||||||
//replace git.nix13.pw/scuroneko/slog v1.0.2 => ../slog
|
//replace git.nix13.pw/scuroneko/slog v1.0.2 => ../slog
|
||||||
|
|
||||||
|
|||||||
4
go.sum
4
go.sum
@@ -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.6.2 h1:YsXvTPB10lmunWiLGlYorrZ5qbYJp00xy8HSA/4EdyI=
|
git.nix13.pw/scuroneko/laniakea v0.7.1 h1:OIIsZ4qdgHevicOHsYTD+yviGIxvd30Wi6j56QptC3Q=
|
||||||
git.nix13.pw/scuroneko/laniakea v0.6.2/go.mod h1:ABjrmhKkTbhTwlMs+bLCr2e+ANnHbYTeidaicl2F0Z4=
|
git.nix13.pw/scuroneko/laniakea v0.7.1/go.mod h1:ABjrmhKkTbhTwlMs+bLCr2e+ANnHbYTeidaicl2F0Z4=
|
||||||
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=
|
||||||
|
|||||||
2
main.go
2
main.go
@@ -16,7 +16,7 @@ func main() {
|
|||||||
database.ConnectMongo()
|
database.ConnectMongo()
|
||||||
database.ConnectRedis()
|
database.ConnectRedis()
|
||||||
|
|
||||||
bot := laniakea.NewBot(laniakea.LoadSettingsFromEnv())
|
bot := laniakea.NewBot(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(&laniakea.DatabaseContext{
|
||||||
|
|||||||
Reference in New Issue
Block a user