Created
September 21, 2019 20:21
-
-
Save talentlessguy/b63227b345f04a4533d0ad5a570fb5a4 to your computer and use it in GitHub Desktop.
Bot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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