-
-
Notifications
You must be signed in to change notification settings - Fork 123
/
button.go
155 lines (137 loc) · 4.78 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
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,
}
}
// InputURLAuth creates button to request a user to authorize via URL using Seamless Telegram Login.
// Can only be sent or received as part of an inline keyboard, use URLAuth for reply keyboards.
func InputURLAuth(requestWriteAccess bool, text, fwdText, url string, bot tg.InputUserClass) *tg.InputKeyboardButtonURLAuth {
return &tg.InputKeyboardButtonURLAuth{
RequestWriteAccess: requestWriteAccess,
Text: text,
FwdText: fwdText,
URL: url,
Bot: bot,
}
}
// URLAuth creates button to request a user to authorize via URL using Seamless Telegram Login.
// Can only be sent or received as part of a reply keyboard, use InputURLAuth for inline keyboards.
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,
}
}
// InputUserProfile creates button that links directly to a user profile.
// Can only be sent or received as part of an inline keyboard, use UserProfile for reply keyboards.
func InputUserProfile(text string, user tg.InputUserClass) *tg.InputKeyboardButtonUserProfile {
return &tg.InputKeyboardButtonUserProfile{
Text: text,
UserID: user,
}
}
// UserProfile creates button that links directly to a user profile.
// Can only be sent or received as part of a reply keyboard, use InputUserProfile for inline keyboards.
func UserProfile(text string, userID int64) *tg.KeyboardButtonUserProfile {
return &tg.KeyboardButtonUserProfile{
Text: text,
UserID: userID,
}
}
// WebView creates button to open a bot web app using messages.requestWebView, sending over user information after
// user confirmation.
// Can only be sent or received as part of an inline keyboard, use SimpleWebView for reply keyboards.
func WebView(text, url string) *tg.KeyboardButtonWebView {
return &tg.KeyboardButtonWebView{
Text: text,
URL: url,
}
}
// SimpleWebView creates button to open a bot web app using messages.requestSimpleWebView, without sending user
// information to the web app.
// Can only be sent or received as part of a reply keyboard, use WebView for inline keyboards.
func SimpleWebView(text, url string) *tg.KeyboardButtonSimpleWebView {
return &tg.KeyboardButtonSimpleWebView{
Text: text,
URL: url,
}
}
// RequestPeer creates button that prompts the user to select and share a peer with the bot using
// messages.sendBotRequestedPeer.
func RequestPeer(text string, buttonID int, peerType tg.RequestPeerTypeClass) *tg.KeyboardButtonRequestPeer {
return &tg.KeyboardButtonRequestPeer{
Text: text,
ButtonID: buttonID,
PeerType: peerType,
}
}