-
-
Notifications
You must be signed in to change notification settings - Fork 135
/
button.go
94 lines (82 loc) · 2.44 KB
/
button.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package markup
import "github.com/gotd/td/tg"
// Row creates keyboard row.
func Row(buttons ...tg.KeyboardButtonClass) tg.KeyboardButtonRow {
return tg.KeyboardButtonRow{
Buttons: buttons,
}
}
// Button creates new plain text button.
func Button(text string) *tg.KeyboardButton {
return &tg.KeyboardButton{
Text: text,
}
}
// URL creates new URL button.
func URL(text, url string) *tg.KeyboardButtonURL {
return &tg.KeyboardButtonURL{
Text: text,
URL: url,
}
}
// Callback creates new callback button.
func Callback(text string, data []byte) *tg.KeyboardButtonCallback {
return &tg.KeyboardButtonCallback{
Text: text,
Data: data,
}
}
// RequestPhone creates button to request a user's phone number.
func RequestPhone(text string) *tg.KeyboardButtonRequestPhone {
return &tg.KeyboardButtonRequestPhone{
Text: text,
}
}
// RequestGeoLocation creates button to request a user's geo location.
func RequestGeoLocation(text string) *tg.KeyboardButtonRequestGeoLocation {
return &tg.KeyboardButtonRequestGeoLocation{
Text: text,
}
}
// SwitchInline creates button to force a user to switch to inline mode.
// Pressing the button will prompt the user to select one of their chats, open that chat and insert the bot‘s username
// and the specified inline query in the input field.
//
// If samePeer set, pressing the button will insert the bot‘s
// username and the specified inline query in the current chat's input field.
func SwitchInline(text, query string, samePeer bool) *tg.KeyboardButtonSwitchInline {
return &tg.KeyboardButtonSwitchInline{
SamePeer: samePeer,
Text: text,
Query: query,
}
}
// Game creates button to start a game.
func Game(text string) *tg.KeyboardButtonGame {
return &tg.KeyboardButtonGame{
Text: text,
}
}
// Buy creates button to buy a product.
func Buy(text string) *tg.KeyboardButtonBuy {
return &tg.KeyboardButtonBuy{
Text: text,
}
}
// URLAuth creates button to request a user to authorize via URL using Seamless Telegram Login.
func URLAuth(text, url string, buttonID int, fwdText string) *tg.KeyboardButtonURLAuth {
return &tg.KeyboardButtonURLAuth{
Text: text,
URL: url,
ButtonID: buttonID,
FwdText: fwdText,
}
}
// RequestPoll creates button that allows the user to create and send a poll when pressed.
// Available only in private.
func RequestPoll(text string, quiz bool) *tg.KeyboardButtonRequestPoll {
return &tg.KeyboardButtonRequestPoll{
Text: text,
Quiz: quiz,
}
}