Answer the question
In order to leave comments, you need to log in
How to separate a function for Handle'ra in telebot?
Hello, I recently started writing in go. I am writing a telegram bot on tucnak/telebot
There is this code:
bot, _ := tb.NewBot(tb.Settings{
Token: "bot",
Poller: &tb.LongPoller{Timeout: 10 * time.Second},
})
bot.Handle("/help", func(m *tb.Message) {
bot.Send(m.Sender, "It is help")
})
func(m *tb.Message)
m *tb.Message
bot.Handle
interface{}
Answer the question
In order to leave comments, you need to log in
Are you talking about it?
func handler(m *tb.Message) error {
bot.Send(m.Sender, "It is help")
}
bot, _ := tb.NewBot(tb.Settings{
Token: "bot",
Poller: &tb.LongPoller{Timeout: 10 * time.Second},
})
bot.Handle("/help", handler)
func handler() func(*tb.Message) error {
return func(m *tb.Message) error {
bot.Send(m.Sender, "It is help")
}
}
bot, _ := tb.NewBot(tb.Settings{
Token: "bot",
Poller: &tb.LongPoller{Timeout: 10 * time.Second},
})
bot.Handle("/help", handler())
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question