I use this library tucnak/telebot to build a telegram bot.
Method b.Handle() have two parameters such as Handle(endpoint interface{}, handler interface{})`.
Here is the code i use for a starter
func main() {
b, err := tb.NewBot(tb.Settings{
Token: "TOKEN_HERE",
Poller: &tb.LongPoller{Timeout: 10 * time.Second},
})
if err != nil {
log.Fatal(err)
return
}
// i want to split this(interface)
b.Handle("/hello", func(m *tb.Message) {
b.Send(m.Sender, "Hello World!")
})
b.Start()
}
Here is what I have tried to compile :
func main() {
b, err := tb.NewBot(tb.Settings{
Token: "TOKEN_HERE",
Poller: &tb.LongPoller{Timeout: 10 * time.Second},
})
if err != nil {
log.Fatal(err)
return
}
b.Handle("/hello", handleHello(b))
b.Start()
}
func handleHello(b *tb.Bot) {
b.Send(m.Sender, "Hello World!")
}
I have an error with this code : undefined m, in m.Sender() and I can't use m as a parameter for that function call, because of the same error. I don't understand where that m comes from.