From cc27469a38e5eb9b4609eb0f8ffa5d138b99e3af Mon Sep 17 00:00:00 2001 From: pibragimov Date: Tue, 23 Apr 2024 23:10:52 +0300 Subject: [PATCH] auto: autocommit --- .gitignore | 2 +- VERSION | 2 +- core/presentation/telegram/telegram.go | 2 +- core/shared/settings.go | 22 ++++++---------------- docker-compose-local.yaml | 2 +- docker-compose.yaml | 4 ++-- go.mod | 1 - go.sum | 1 - 8 files changed, 12 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index 62a58c0..95c3077 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -ds/weights.pth +.mtproto* bootstrap* ### Builds ### fun-telegram-v* diff --git a/VERSION b/VERSION index 56d1242..928e34d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v1.11.49 +v1.11.50 diff --git a/core/presentation/telegram/telegram.go b/core/presentation/telegram/telegram.go index dfb637b..11e723d 100644 --- a/core/presentation/telegram/telegram.go +++ b/core/presentation/telegram/telegram.go @@ -98,7 +98,7 @@ func NewProtoClient(ctx context.Context) (*gotgproto.Client, error) { InMemory: false, DisableCopyright: true, Session: sessionMaker.SqlSession( - sqlite.Open(shared.AppSettings.Telegram.SessionFullPath), + sqlite.Open(".mtproto"), ), Middlewares: middlewares, RunMiddleware: runMiddleware, diff --git a/core/shared/settings.go b/core/shared/settings.go index baf548a..5a2b15a 100644 --- a/core/shared/settings.go +++ b/core/shared/settings.go @@ -2,14 +2,12 @@ package shared import ( "context" - "path/filepath" "time" "github.com/pkg/errors" "github.com/caarlos0/env/v7" "github.com/joho/godotenv" - "github.com/mitchellh/go-homedir" ) const ( @@ -18,11 +16,9 @@ const ( ) type telegram struct { - AppID int `env:"app_id,required"` - AppHash string `env:"app_hash,required"` - PhoneNumber string `env:"phone_number,required"` - SessionPath string `env:"session_storage_path" envDefault:"telegram-session.json"` - SessionFullPath string + AppID int `env:"app_id,required"` + AppHash string `env:"app_hash,required"` + PhoneNumber string `env:"phone_number,required"` FloodWaiterEnabled bool `env:"flood_waiter_enabled" envDefault:"true"` RateLimiterEnabled bool `env:"rate_limiter_enabled" envDefault:"true"` @@ -38,10 +34,9 @@ type storage struct { } type Settings struct { - Telegram telegram `envPrefix:"telegram__"` - Storage storage `envPrefix:"storage__"` - FileStoragePath string ` env:"file_storage_path" envDefault:"~/.config/fun-telegram/"` - LogLevel string ` env:"log_level" envDefault:"debug"` + Telegram telegram `envPrefix:"telegram__"` + Storage storage `envPrefix:"storage__"` + LogLevel string ` env:"log_level" envDefault:"debug"` MessagesMaxSizeMB int `env:"messages_max_size_mb" envDefault:"100"` @@ -61,11 +56,6 @@ func mustNewSettings() Settings { err := env.Parse(&settings, env.Options{Prefix: defaultEnvPrefix}) Check(ctx, errors.Wrap(err, "failed to env parse")) - realPath, err := homedir.Expand(settings.FileStoragePath) - Check(ctx, errors.Wrap(err, "failed to homedir expand")) - - settings.Telegram.SessionFullPath = filepath.Join(realPath, settings.Telegram.SessionPath) - return settings } diff --git a/docker-compose-local.yaml b/docker-compose-local.yaml index 0b7e9a4..4a8be37 100644 --- a/docker-compose-local.yaml +++ b/docker-compose-local.yaml @@ -13,7 +13,7 @@ services: context: . dockerfile: DockerfileCore volumes: - - "~/.config/fun-telegram:/config" + - ".mtproto:/.mtproto" - ".env:/.env" depends_on: redis: diff --git a/docker-compose.yaml b/docker-compose.yaml index 49e6be8..434c8ce 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -9,9 +9,9 @@ services: fun_storage__mongo_db_url: "mongodb://mongodb:27017" fun_storage__clickhouse_url: "clickhouse:9000" fun_ds_supplier_url: "http://ds:8000" - image: ghcr.io/teadove/fun-telegram:v1.11.49 + image: ghcr.io/teadove/fun-telegram:v1.11.50 volumes: - - "~/.config/fun-telegram:/config" + - ".mtproto:/.mtproto" - ".env:/.env" depends_on: redis: diff --git a/go.mod b/go.mod index 2a9f0ed..03f8dc4 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,6 @@ require ( github.com/guregu/null/v5 v5.0.0 github.com/joho/godotenv v1.5.1 github.com/kamva/mgm/v3 v3.5.0 - github.com/mitchellh/go-homedir v1.1.0 github.com/pkg/errors v0.9.1 github.com/redis/go-redis/v9 v9.4.0 github.com/rs/zerolog v1.31.0 diff --git a/go.sum b/go.sum index 0de9551..a1983f8 100644 --- a/go.sum +++ b/go.sum @@ -515,7 +515,6 @@ github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM= github.com/minio/minio-go/v7 v7.0.34/go.mod h1:nCrRzjoSUQh8hgKKtu3Y708OLvRLtuASMg2/nvmbarw= github.com/minio/sha256-simd v1.0.0/go.mod h1:OuYzVNI5vcoYIAmbIvHPl3N3jUzVedXbKy5RFepssQM= -github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=