41 lines
1010 B
Go
41 lines
1010 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
"fmt"
|
|
|
|
"github.com/theorift/white-zone-bot/bot"
|
|
"github.com/theorift/white-zone-bot/bot/handlers"
|
|
"github.com/theorift/white-zone-bot/config"
|
|
"github.com/theorift/white-zone-bot/logger"
|
|
sqlite_repositories "github.com/theorift/white-zone-bot/repositories/sqlite"
|
|
_ "modernc.org/sqlite"
|
|
)
|
|
|
|
func main() {
|
|
ctx := context.Background()
|
|
cfg := config.GetConfig()
|
|
|
|
dbConnString := fmt.Sprintf("file:%s?cache=shared&_fk=1", cfg.DBPath)
|
|
conn, err := sql.Open("sqlite", dbConnString)
|
|
if err != nil {
|
|
errLog := fmt.Errorf("failed to open database: %w", err)
|
|
panic(errLog)
|
|
}
|
|
defer conn.Close()
|
|
|
|
logger.InitLogger(cfg.LogLevel)
|
|
|
|
bot := bot.Bot{ApiKey: cfg.TelegramBotAPIKey}
|
|
|
|
bot.Initialize()
|
|
|
|
userRepo := sqlite_repositories.NewUserRepository(ctx, conn)
|
|
|
|
handlers.HandleStart(bot, userRepo)
|
|
handlers.HandleCheckPointBtn(bot, userRepo)
|
|
handlers.HandleGenerateInviteQueryBtn(bot)
|
|
bot.GetInstance().Start()
|
|
}
|