fixed gitignore
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2025-06-23 16:22:34 +03:00
parent 0d5fcabebd
commit ad61acf53c
2 changed files with 70 additions and 0 deletions

1
.gitignore vendored
View File

@@ -1,5 +1,6 @@
# Binary
bot
!cmd/bot
yamusic-bot
# Data

69
cmd/bot/main.go Normal file
View File

@@ -0,0 +1,69 @@
package main
import (
"context"
"log/slog"
"time"
"gitea.mrixs.me/Mrixs/yamusic-bot/internal/admin"
"gitea.mrixs.me/Mrixs/yamusic-bot/internal/bot"
"gitea.mrixs.me/Mrixs/yamusic-bot/internal/config"
"gitea.mrixs.me/Mrixs/yamusic-bot/internal/processor"
"gitea.mrixs.me/Mrixs/yamusic-bot/internal/storage"
"gitea.mrixs.me/Mrixs/yamusic-bot/pkg/downloader"
"gitea.mrixs.me/Mrixs/yamusic-bot/pkg/logging"
"gitea.mrixs.me/Mrixs/yamusic-bot/pkg/tagger"
"gitea.mrixs.me/Mrixs/yamusic-bot/pkg/yamusic"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
)
func main() {
startTime := time.Now()
ctx := context.Background()
// 1. Инициализация конфигурации
cfg := config.New()
// 2. Инициализация логгера
logger := logging.NewLogger(cfg.LogLevel)
slog.SetDefault(logger)
slog.Info("Starting Yandex.Music Downloader Bot...", "version", "1.0")
// 3. Инициализация зависимостей
db, err := storage.NewSQLiteStorage(ctx, cfg.DatabasePath)
if err != nil {
slog.Error("Failed to initialize storage", "error", err)
return
}
yandexClient, err := yamusic.NewApiClient(cfg.YandexMusicToken)
if err != nil {
slog.Error("Failed to initialize yandex client", "error", err)
return
}
tgAPI, err := tgbotapi.NewBotAPI(cfg.TelegramBotToken)
if err != nil {
slog.Error("Failed to initialize telegram bot api", "error", err)
return
}
tgAPI.Debug = cfg.LogLevel == "debug"
slog.Info("Authorized on account", "username", tgAPI.Self.UserName)
// 4. Инициализация компонентов
downloaderComponent := downloader.NewHTTPDownloader()
taggerComponent := tagger.NewID3Tagger()
telegramClient := bot.NewTelegramClientAdapter(tgAPI, cfg.TelegramCacheChatID)
trackProcessor := processor.NewTrackProcessor(db, yandexClient, downloaderComponent, taggerComponent, telegramClient)
adminHandler := admin.NewHandler(db, telegramClient, yandexClient, startTime)
inlineHandler := bot.NewInlineHandler(yandexClient, trackProcessor, telegramClient)
// 5. Создание и запуск приложения
app := bot.NewApp(cfg, tgAPI, db, adminHandler, inlineHandler)
app.Run(ctx)
slog.Info("Bot stopped.")
}