diff --git a/go/go.sum b/go/go.sum index d61b19e..0467a41 100644 --- a/go/go.sum +++ b/go/go.sum @@ -1,2 +1,4 @@ +github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1 h1:wG8n/XJQ07TmjbITcGiUaOtXxdrINDz1b0J1w0SzqDc= +github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1/go.mod h1:A2S0CWkNylc2phvKXWBBdD3K0iGnDBGbzRpISP2zBl8= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= diff --git a/go/tg/.gitignore b/go/tg/.gitignore new file mode 100644 index 0000000..4c49bd7 --- /dev/null +++ b/go/tg/.gitignore @@ -0,0 +1 @@ +.env diff --git a/go/tg/go.sum b/go/tg/go.sum new file mode 100644 index 0000000..0467a41 --- /dev/null +++ b/go/tg/go.sum @@ -0,0 +1,4 @@ +github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1 h1:wG8n/XJQ07TmjbITcGiUaOtXxdrINDz1b0J1w0SzqDc= +github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1/go.mod h1:A2S0CWkNylc2phvKXWBBdD3K0iGnDBGbzRpISP2zBl8= +github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= +github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= diff --git a/go/tg/l1.go b/go/tg/l1.go new file mode 100644 index 0000000..8ec10c1 --- /dev/null +++ b/go/tg/l1.go @@ -0,0 +1,35 @@ +package main + +import ( + "fmt" + "log" + tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5" + "github.com/joho/godotenv" + "os" +) + +func main() { + err := godotenv.Load() + if err != nil { + log.Fatalf("%v\n", err) + } + tg := os.Getenv("TG_TOKEN") + bot, err := tgbotapi.NewBotAPI(tg) + if err != nil { + log.Fatalf("%v\n", err) + } + bot.Debug = true + fmt.Printf("Работает как %s", bot.Self.UserName) + u := tgbotapi.NewUpdate(0) + u.Timeout = 60 + upd := bot.GetUpdatesChan(u) + for update := range upd { + if update.Message == nil { + continue + } + if update.Message.IsCommand() && update.Message.Command() == "start" { + msg := tgbotapi.NewMessage(update.Message.Chat.ID, "Сергей") + bot.Send(msg) + } + } +} diff --git a/go/tg/output/l1 b/go/tg/output/l1 new file mode 100755 index 0000000..9ddaee8 Binary files /dev/null and b/go/tg/output/l1 differ