// Command cepis-telegram is the official Telegram bot for https://cep.is. // // It answers a bare CEP in a private chat, "/cep " in groups and channels, // and inline queries anywhere. Updates arrive by long polling, so the process // needs no inbound port, no public hostname and no webhook secret. // // Configuration is environment-only; see the config package. package main import ( "context" "errors" "log/slog" "os" "os/signal" "syscall" "cep.is/telegrambot/internal/app" "cep.is/telegrambot/internal/config" ) func main() { if err := run(); err != nil { slog.New(slog.NewJSONHandler(os.Stdout, nil)).Error("fatal", slog.String("error", err.Error())) os.Exit(1) } } func run() error { cfg, err := config.Load() if err != nil { if errors.Is(err, config.ErrMissingToken) { return errors.New(config.EnvToken + " is required: create a bot with @BotFather and pass its token in the environment") } return err } logger := slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{Level: cfg.LogLevel})) slog.SetDefault(logger) logger.Info("configuration loaded", slog.Any("config", cfg)) ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) defer stop() application, err := app.New(ctx, cfg, logger) if err != nil { return err } return application.Run(ctx) }