This repository has been archived on 2023-12-11. You can view files and clone it, but cannot push or open issues or pull requests.
archive/golang/asciisay-bot/main.go
2023-07-29 16:42:28 +05:00

36 lines
577 B
Go

package main
import (
"log"
"os"
"github.com/joho/godotenv"
"github.com/yanzay/tbot/v2"
)
type application struct {
client *tbot.Client
}
var (
app application
bot *tbot.Server
token string
)
func init() {
e := godotenv.Load()
if e != nil {
log.Println(e)
}
token = os.Getenv("TELEGRAM_TOKEN")
}
func main() {
bot = tbot.New(token, tbot.WithWebhook("https://asciisay-bot.herokuapp.com", ":"+os.Getenv("PORT")))
app.client = bot.Client()
bot.HandleMessage("/start", app.startHandler)
bot.HandleMessage(".+", app.msgHandler)
log.Fatal(bot.Start())
}