Skip to content

Instantly share code, notes, and snippets.

@talentlessguy
Created September 21, 2019 20:21
Show Gist options
  • Save talentlessguy/b63227b345f04a4533d0ad5a570fb5a4 to your computer and use it in GitHub Desktop.
Save talentlessguy/b63227b345f04a4533d0ad5a570fb5a4 to your computer and use it in GitHub Desktop.
Bot
package main
import (
"os"
"time"
"log"
// excel "github.com/360EntSecGroup-Skylar/excelize"
env "github.com/joho/godotenv"
tb "gopkg.in/tucnak/telebot.v2"
)
func main() {
err := env.Load()
if err != nil {
log.Fatal("Error loading .env file")
}
token := os.Getenv("TOKEN")
pref := tb.Settings{
Token: token,
Poller: &tb.LongPoller{Timeout: 10 * time.Second},
}
b, err := tb.NewBot(pref)
if err != nil {
log.Fatal(err)
}
b.Handle("/hello", func(m *tb.Message) {
b.Send(m.Sender, "You entered " + m.Text)
})
inlineBtn := tb.InlineButton{
Unique: "name",
Text: "ФИО",
}
inlineKeys := [][]tb.InlineButton{
[]tb.InlineButton{inlineBtn},
}
b.Handle(&inlineBtn, func(m *tb.Message) {
b.Send(m.Sender, "You pressed the button!")
})
b.Handle(&inlineBtn, func(c *tb.Callback) {
b.Respond(c, &tb.CallbackResponse{
// WTF I should put here
})
})
b.Handle("/start", func(m *tb.Message) {
b.Send(
m.Sender, "Hello World", &tb.ReplyMarkup{ InlineKeyboard: inlineKeys })
})
b.Start()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment