35 lines
587 B
Go
35 lines
587 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/spf13/viper"
|
|
tb "gopkg.in/tucnak/telebot.v2"
|
|
"time"
|
|
)
|
|
|
|
var (
|
|
BotToken string
|
|
)
|
|
|
|
func main() {
|
|
viper.SetConfigName("config")
|
|
viper.AddConfigPath(".")
|
|
err := viper.ReadInConfig()
|
|
if err != nil {
|
|
panic(fmt.Errorf("Fatal error config file: %s \n", err))
|
|
}
|
|
BotToken = viper.GetString("bot_token")
|
|
b, err := tb.NewBot(tb.Settings{
|
|
Token: BotToken,
|
|
Poller: &tb.LongPoller{Timeout: 10 * time.Second},
|
|
})
|
|
if err != nil {
|
|
return
|
|
}
|
|
//b.Handle(tb.OnText, func(m *tb.Message) {
|
|
// b.Send(m.Sender, "hello world")
|
|
//})
|
|
|
|
b.Start()
|
|
}
|