-
-
Notifications
You must be signed in to change notification settings - Fork 42
/
main.go
52 lines (43 loc) · 1.23 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"fmt"
"os"
"github.com/mymmrac/telego"
tu "github.com/mymmrac/telego/telegoutil"
)
func main() {
botToken := os.Getenv("TOKEN")
// Note: Please keep in mind that default logger may expose sensitive information, use in development only
bot, err := telego.NewBot(botToken, telego.WithDefaultDebugLogger())
if err != nil {
fmt.Println(err)
os.Exit(1)
}
// Inline keyboard parameters
inlineKeyboard := tu.InlineKeyboard(
tu.InlineKeyboardRow( // Row 1
tu.InlineKeyboardButton("Callback data button 1"). // Column 1
WithCallbackData("callback_1"),
tu.InlineKeyboardButton("Callback data button 2"). // Column 2
WithCallbackData("callback_2"),
),
tu.InlineKeyboardRow( // Row 2
tu.InlineKeyboardButton("URL button").WithURL("https://example.com"), // Column 1
),
)
// Message parameters
message := tu.Message(
tu.ID(1234567),
"My message",
).WithReplyMarkup(inlineKeyboard)
// Sending message
_, _ = bot.SendMessage(message)
updates, _ := bot.UpdatesViaLongPolling(nil)
defer bot.StopLongPolling()
// Receiving callback data
for update := range updates {
if update.CallbackQuery != nil {
fmt.Println("Received callback with data:", update.CallbackQuery.Data)
}
}
}