commit 50ad50d61ff76328625156edec7b75a602283b5e Author: nightnoryu Date: Thu Jul 25 02:14:58 2024 +0300 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f11b75 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..d49fd14 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# anon3anon + +Telegram bot for anonymous questions. diff --git a/cmd/anon3anon/main.go b/cmd/anon3anon/main.go new file mode 100644 index 0000000..73d8288 --- /dev/null +++ b/cmd/anon3anon/main.go @@ -0,0 +1,38 @@ +package main + +import ( + "log" + "os" + + tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5" +) + +const telegramBotTokenEnvKey = "TELEGRAM_BOT_TOKEN" + +func main() { + token := os.Getenv(telegramBotTokenEnvKey) + bot, err := tgbotapi.NewBotAPI(token) + if err != nil { + log.Panic(err) + } + + bot.Debug = true + + log.Printf("Authorized on account %s", bot.Self.UserName) + + u := tgbotapi.NewUpdate(0) + u.Timeout = 60 + + updates := bot.GetUpdatesChan(u) + + for update := range updates { + if update.Message != nil { // If we got a message + log.Printf("[%s] %s", update.Message.From.UserName, update.Message.Text) + + msg := tgbotapi.NewMessage(update.Message.Chat.ID, update.Message.Text) + msg.ReplyToMessageID = update.Message.MessageID + + bot.Send(msg) + } + } +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..7573eed --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module github.com/nightnoryu/anon3anon + +go 1.22.5 + +require github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1 // indirect diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..db8e45c --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +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=