36 lines
577 B
Go
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())
|
|
}
|