-
Notifications
You must be signed in to change notification settings - Fork 6
/
options.go
228 lines (200 loc) · 8.55 KB
/
options.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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
package micha
import (
"context"
"strings"
)
type Options struct {
limit int
timeout int
logger Logger
apiServer string
httpClient HttpClient
ctx context.Context
}
type Option func(*Options)
// WithLimit - set getUpdates limit
// Values between 1—100 are accepted. Defaults to 100.
func WithLimit(limit int) Option {
return func(o *Options) {
o.limit = limit
}
}
// WithTimeout - set timeout in seconds for getUpdates long polling
// Defaults to 25
func WithTimeout(timeout int) Option {
return func(o *Options) {
o.timeout = timeout
}
}
// WithLogger - set logger
func WithLogger(logger Logger) Option {
return func(o *Options) {
o.logger = logger
}
}
// WithHttpClient - set custom http client
func WithHttpClient(httpClient HttpClient) Option {
return func(o *Options) {
o.httpClient = httpClient
}
}
// WithAPIServer - set custom api server (https://github.com/tdlib/telegram-bot-api)
func WithAPIServer(url string) Option {
return func(o *Options) {
o.apiServer = strings.TrimSuffix(url, "/")
}
}
// WithAPIServer - set custom context
func WithCtx(ctx context.Context) Option {
return func(o *Options) {
o.ctx = ctx
}
}
// SendMessageOptions optional params SendMessage method
type SendMessageOptions struct {
ParseMode ParseMode `json:"parse_mode,omitempty"`
DisableWebPagePreview bool `json:"disable_web_page_preview,omitempty"`
DisableNotification bool `json:"disable_notification,omitempty"`
ReplyToMessageID int64 `json:"reply_to_message_id,omitempty"`
ReplyMarkup ReplyMarkup `json:"reply_markup,omitempty"`
}
// SendPhotoOptions optional params SendPhoto method
type SendPhotoOptions struct {
Caption string `json:"caption,omitempty"`
ParseMode ParseMode `json:"parse_mode,omitempty"`
DisableNotification bool `json:"disable_notification,omitempty"`
ReplyToMessageID int64 `json:"reply_to_message_id,omitempty"`
ReplyMarkup ReplyMarkup `json:"reply_markup,omitempty"`
}
// SendAudioOptions optional params SendAudio method
type SendAudioOptions struct {
Caption string `json:"caption,omitempty"`
ParseMode ParseMode `json:"parse_mode,omitempty"`
Duration int `json:"duration,omitempty"`
Performer string `json:"performer,omitempty"`
Title string `json:"title,omitempty"`
Thumb string `json:"thumb,omitempty"` // TODO add thumb as file
DisableNotification bool `json:"disable_notification,omitempty"`
ReplyToMessageID int64 `json:"reply_to_message_id,omitempty"`
ReplyMarkup ReplyMarkup `json:"reply_markup,omitempty"`
}
// SendDocumentOptions optional params SendDocument method
type SendDocumentOptions struct {
Thumb string `json:"thumb,omitempty"` // TODO add thumb as file
Caption string `json:"caption,omitempty"`
ParseMode ParseMode `json:"parse_mode,omitempty"`
DisableNotification bool `json:"disable_notification,omitempty"`
ReplyToMessageID int64 `json:"reply_to_message_id,omitempty"`
ReplyMarkup ReplyMarkup `json:"reply_markup,omitempty"`
}
// Send sticker optional params
type SendStickerOptions struct {
DisableNotification bool `json:"disable_notification,omitempty"`
ReplyToMessageID int64 `json:"reply_to_message_id,omitempty"`
ReplyMarkup ReplyMarkup `json:"reply_markup,omitempty"`
}
// SendVideoOptions video optional params SendVideo method
type SendVideoOptions struct {
Duration int `json:"duration,omitempty"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
Thumb string `json:"thumb,omitempty"` // TODO add thumb as file
Caption string `json:"caption,omitempty"`
ParseMode ParseMode `json:"parse_mode,omitempty"`
SupportsStreaming bool `json:"supports_streaming,omitempty"`
DisableNotification bool `json:"disable_notification,omitempty"`
ReplyToMessageID int64 `json:"reply_to_message_id,omitempty"`
ReplyMarkup ReplyMarkup `json:"reply_markup,omitempty"`
}
// SendVoiceOptions optional params for SendVoice method
type SendVoiceOptions struct {
Caption string `json:"caption,omitempty"`
ParseMode ParseMode `json:"parse_mode,omitempty"`
Duration int `json:"duration,omitempty"`
DisableNotification bool `json:"disable_notification,omitempty"`
ReplyToMessageID int64 `json:"reply_to_message_id,omitempty"`
ReplyMarkup ReplyMarkup `json:"reply_markup,omitempty"`
}
// SendVideoNoteOptions optional params for SendVideoNote method
type SendVideoNoteOptions struct {
Duration int `json:"duration,omitempty"`
Length int `json:"length,omitempty"`
Thumb string `json:"thumb,omitempty"` // TODO add thumb as file
DisableNotification bool `json:"disable_notification,omitempty"`
ReplyToMessageID int64 `json:"reply_to_message_id,omitempty"`
ReplyMarkup ReplyMarkup `json:"reply_markup,omitempty"`
}
// SendLocationOptions optional params for SendLocation method
type SendLocationOptions struct {
LivePeriod int `json:"live_period,omitempty"`
DisableNotification bool `json:"disable_notification,omitempty"`
ReplyToMessageID int64 `json:"reply_to_message_id,omitempty"`
ReplyMarkup ReplyMarkup `json:"reply_markup,omitempty"`
}
// SendVenueOptions optional params for SendVenue method
type SendVenueOptions struct {
FoursquareID string `json:"foursquare_id,omitempty"`
FoursquareType string `json:"foursquare_type,omitempty"`
DisableNotification bool `json:"disable_notification,omitempty"`
ReplyToMessageID int64 `json:"reply_to_message_id,omitempty"`
ReplyMarkup ReplyMarkup `json:"reply_markup,omitempty"`
}
// SendContactOptions optional params for SendContact method
type SendContactOptions struct {
VCard string `json:"vcard,omitempty"`
DisableNotification bool `json:"disable_notification,omitempty"`
ReplyToMessageID int64 `json:"reply_to_message_id,omitempty"`
ReplyMarkup ReplyMarkup `json:"reply_markup,omitempty"`
}
// SendGameOptions optional params for SendGame method
type SendGameOptions struct {
DisableNotification bool `json:"disable_notification,omitempty"`
ReplyToMessageID int64 `json:"reply_to_message_id,omitempty"`
ReplyMarkup ReplyMarkup `json:"reply_markup,omitempty"`
}
// Set game score optional params
type SetGameScoreOptions struct {
ChatID ChatID `json:"chat_id,omitempty"`
MessageID int64 `json:"message_id,omitempty"`
InlineMessageID string `json:"inline_message_id,omitempty"`
DisableEditMessage bool `json:"disable_edit_message,omitempty"`
Force bool `json:"force,omitempty"`
}
// Get game high scopres optional params
type GetGameHighScoresOptions struct {
ChatID ChatID `json:"chat_id,omitempty"`
MessageID int64 `json:"message_id,omitempty"`
InlineMessageID string `json:"inline_message_id,omitempty"`
}
// Edit message text optional params
type EditMessageTextOptions struct {
ParseMode ParseMode `json:"parse_mode,omitempty"`
DisableWebPagePreview bool `json:"disable_web_page_preview,omitempty"`
ReplyMarkup ReplyMarkup `json:"reply_markup,omitempty"`
}
// Edit message caption optional params
type EditMessageCationOptions struct {
Caption string `json:"caption,omitempty"`
ReplyMarkup ReplyMarkup `json:"reply_markup,omitempty"`
}
// Answer callback query optional params
type AnswerCallbackQueryOptions struct {
Text string `json:"text,omitempty"`
ShowAlert bool `json:"show_alert,omitempty"`
URL string `json:"url,omitempty"`
CacheTime int `json:"cache_time,omitempty"`
}
// Answer inline query optional params
type AnswerInlineQueryOptions struct {
CacheTime int `json:"cache_time,omitempty"`
IsPersonal bool `json:"is_personal,omitempty"`
NextOffset string `json:"next_offset,omitempty"`
SwitchPmText string `json:"switch_pm_text,omitempty"`
SwitchPmParameter string `json:"switch_pm_parameter,omitempty"`
}
// Set webhook query optional params
type SetWebhookOptions struct {
Certificate []byte `json:"certificate,omitempty"`
MaxConnections int `json:"max_connections,omitempty"`
AllowedUpdates []string `json:"allowed_updates,omitempty"`
}