package main import ( "log" "os" tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5" "github.com/joho/godotenv" ) func main() { _ = godotenv.Load() token := os.Getenv("BOT_TOKEN") if token == "" { log.Fatal("BOT_TOKEN не задан. Скопируйте .env.example в .env и укажите токен от @BotFather") } bot, err := tgbotapi.NewBotAPI(token) if err != nil { log.Fatalf("не удалось подключиться к Telegram: %v", err) } bot.Debug = os.Getenv("BOT_DEBUG") == "true" log.Printf("бот @%s запущен", bot.Self.UserName) u := tgbotapi.NewUpdate(0) u.Timeout = 60 updates := bot.GetUpdatesChan(u) for update := range updates { if update.Message == nil { continue } chatID := update.Message.Chat.ID text := update.Message.Text var reply string switch text { case "/start": name := update.Message.From.FirstName if name == "" { name = "друг" } reply = "Привет, " + name + "!\n\nЯ VPN-бот. Пока умею только здороваться — дальше добавим функции." default: reply = "Напишите /start, чтобы начать." } msg := tgbotapi.NewMessage(chatID, reply) if _, err := bot.Send(msg); err != nil { log.Printf("ошибка отправки в чат %d: %v", chatID, err) } } }