@@ -30,80 +30,200 @@ type Bot struct {
30
30
31
31
// GetInfo returns information about bot:
32
32
// id, name, about, avatar
33
+ //
34
+ // GetInfo uses context.Background internally; to specify the context, use
35
+ // GetInfoWithContext.
33
36
func (b * Bot ) GetInfo () (* BotInfo , error ) {
34
- return b .client .GetInfo ()
37
+ return b .GetInfoWithContext (context .Background ())
38
+ }
39
+
40
+ // GetInfoWithContext returns information about bot:
41
+ // id, name, about, avatar
42
+ func (b * Bot ) GetInfoWithContext (ctx context.Context ) (* BotInfo , error ) {
43
+ return b .client .GetInfoWithContext (ctx )
35
44
}
36
45
37
46
// GetChatInfo returns information about chat:
38
47
// id, type, title, public, group, inviteLink, admins
48
+ //
49
+ // GetChatInfo uses context.Background internally; to specify the context, use
50
+ // GetChatInfoWithContext.
39
51
func (b * Bot ) GetChatInfo (chatID string ) (* Chat , error ) {
40
- return b .client .GetChatInfo (chatID )
52
+ return b .GetChatInfoWithContext (context .Background (), chatID )
53
+ }
54
+
55
+ // GetChatInfoWithContext returns information about chat:
56
+ // id, type, title, public, group, inviteLink, admins
57
+ func (b * Bot ) GetChatInfoWithContext (ctx context.Context , chatID string ) (* Chat , error ) {
58
+ return b .client .GetChatInfoWithContext (ctx , chatID )
41
59
}
42
60
43
61
// SendChatActions sends an actions like "typing, looking"
62
+ //
63
+ // SendChatActions uses context.Background internally; to specify the context, use
64
+ // SendChatActionsWithContext.
44
65
func (b * Bot ) SendChatActions (chatID string , actions ... ChatAction ) error {
45
- return b .client .SendChatActions (chatID , actions ... )
66
+ return b .SendChatActionsWithContext (context .Background (), chatID , actions ... )
67
+ }
68
+
69
+ // SendChatActionsWithContext sends an actions like "typing, looking"
70
+ func (b * Bot ) SendChatActionsWithContext (ctx context.Context , chatID string , actions ... ChatAction ) error {
71
+ return b .client .SendChatActionsWithContext (ctx , chatID , actions ... )
46
72
}
47
73
48
74
// GetChatAdmins returns chat admins list with fields:
49
75
// userID, creator flag
76
+ //
77
+ // GetChatAdmins uses context.Background internally; to specify the context, use
78
+ // GetChatAdminsWithContext.
50
79
func (b * Bot ) GetChatAdmins (chatID string ) ([]ChatMember , error ) {
51
- return b .client .GetChatAdmins (chatID )
80
+ return b .GetChatAdminsWithContext (context .Background (), chatID )
81
+ }
82
+
83
+ // GetChatAdminsWithContext returns chat admins list with fields:
84
+ // userID, creator flag
85
+ func (b * Bot ) GetChatAdminsWithContext (ctx context.Context , chatID string ) ([]ChatMember , error ) {
86
+ return b .client .GetChatAdminsWithContext (ctx , chatID )
52
87
}
53
88
54
89
// GetChatMem returns chat members list with fields:
55
90
// userID, creator flag, admin flag
91
+ //
92
+ // GetChatMembers uses context.Background internally; to specify the context, use
93
+ // GetChatMembersWithContext.
56
94
func (b * Bot ) GetChatMembers (chatID string ) ([]ChatMember , error ) {
57
- return b .client .GetChatMembers (chatID )
95
+ return b .GetChatMembersWithContext (context .Background (), chatID )
96
+ }
97
+
98
+ // GetChatMembersWithContext returns chat members list with fields:
99
+ // userID, creator flag, admin flag
100
+ func (b * Bot ) GetChatMembersWithContext (ctx context.Context , chatID string ) ([]ChatMember , error ) {
101
+ return b .client .GetChatMembersWithContext (ctx , chatID )
58
102
}
59
103
60
104
// GetChatBlockedUsers returns chat blocked users list:
61
105
// userID
106
+ //
107
+ // GetChatBlockedUsers uses context.Background internally; to specify the context, use
108
+ // GetChatBlockedUsersWithContext.
62
109
func (b * Bot ) GetChatBlockedUsers (chatID string ) ([]User , error ) {
63
- return b .client .GetChatBlockedUsers (chatID )
110
+ return b .GetChatBlockedUsersWithContext (context .Background (), chatID )
111
+ }
112
+
113
+ // GetChatBlockedUsersWithContext returns chat blocked users list:
114
+ // userID
115
+ func (b * Bot ) GetChatBlockedUsersWithContext (ctx context.Context , chatID string ) ([]User , error ) {
116
+ return b .client .GetChatBlockedUsersWithContext (ctx , chatID )
64
117
}
65
118
66
119
// GetChatPendingUsers returns chat join pending users list:
67
120
// userID
121
+ //
122
+ // GetChatPendingUsers uses context.Background internally; to specify the context, use
123
+ // GetChatPendingUsersWithContext.
68
124
func (b * Bot ) GetChatPendingUsers (chatID string ) ([]User , error ) {
69
- return b .client .GetChatPendingUsers (chatID )
125
+ return b .GetChatPendingUsersWithContext (context .Background (), chatID )
126
+ }
127
+
128
+ // GetChatPendingUsersWithContext returns chat join pending users list:
129
+ // userID
130
+ func (b * Bot ) GetChatPendingUsersWithContext (ctx context.Context , chatID string ) ([]User , error ) {
131
+ return b .client .GetChatPendingUsersWithContext (ctx , chatID )
70
132
}
71
133
72
134
// BlockChatUser blocks user and removes him from chat.
73
135
// If deleteLastMessages is true, the messages written recently will be deleted
136
+ //
137
+ // BlockChatUser uses context.Background internally; to specify the context, use
138
+ // BlockChatUserWithContext.
74
139
func (b * Bot ) BlockChatUser (chatID , userID string , deleteLastMessages bool ) error {
75
- return b .client .BlockChatUser (chatID , userID , deleteLastMessages )
140
+ return b .BlockChatUserWithContext (context .Background (), chatID , userID , deleteLastMessages )
141
+ }
142
+
143
+ // BlockChatUserWithContext blocks user and removes him from chat.
144
+ // If deleteLastMessages is true, the messages written recently will be deleted
145
+ func (b * Bot ) BlockChatUserWithContext (ctx context.Context , chatID , userID string , deleteLastMessages bool ) error {
146
+ return b .client .BlockChatUserWithContext (ctx , chatID , userID , deleteLastMessages )
76
147
}
77
148
78
149
// UnblockChatUser unblocks user in chat
150
+ //
151
+ // UnblockChatUser uses context.Background internally; to specify the context, use
152
+ // UnblockChatUserWithContext.
79
153
func (b * Bot ) UnblockChatUser (chatID , userID string ) error {
80
- return b .client .UnblockChatUser (chatID , userID )
154
+ return b .UnblockChatUserWithContext (context .Background (), chatID , userID )
155
+ }
156
+
157
+ // UnblockChatUserWithContext unblocks user in chat
158
+ func (b * Bot ) UnblockChatUserWithContext (ctx context.Context , chatID , userID string ) error {
159
+ return b .client .UnblockChatUserWithContext (ctx , chatID , userID )
81
160
}
82
161
83
162
// ResolveChatJoinRequests sends a decision to accept/decline user join to chat
163
+ //
164
+ // ResolveChatJoinRequests uses context.Background internally; to specify the context, use
165
+ // ResolveChatJoinRequestsWithContext.
84
166
func (b * Bot ) ResolveChatJoinRequests (chatID , userID string , accept , everyone bool ) error {
85
- return b .client .ResolveChatPending (chatID , userID , accept , everyone )
167
+ return b .ResolveChatJoinRequestsWithContext (context .Background (), chatID , userID , accept , everyone )
168
+ }
169
+
170
+ // ResolveChatJoinRequestsWithContext sends a decision to accept/decline user join to chat
171
+ func (b * Bot ) ResolveChatJoinRequestsWithContext (ctx context.Context , chatID , userID string , accept , everyone bool ) error {
172
+ return b .client .ResolveChatPendingWithContext (ctx , chatID , userID , accept , everyone )
86
173
}
87
174
88
175
// SetChatTitle changes chat title
176
+ //
177
+ // SetChatTitle uses context.Background internally; to specify the context, use
178
+ // SetChatTitleWithContext.
89
179
func (b * Bot ) SetChatTitle (chatID , title string ) error {
90
- return b .client .SetChatTitle (chatID , title )
180
+ return b .SetChatTitleWithContext (context .Background (), chatID , title )
181
+ }
182
+
183
+ // SetChatTitleWithContext changes chat title
184
+ func (b * Bot ) SetChatTitleWithContext (ctx context.Context , chatID , title string ) error {
185
+ return b .client .SetChatTitleWithContext (ctx , chatID , title )
91
186
}
92
187
93
188
// SetChatAbout changes chat about
189
+ //
190
+ // SetChatAbout uses context.Background internally; to specify the context, use
191
+ // SetChatAboutWithContext.
94
192
func (b * Bot ) SetChatAbout (chatID , about string ) error {
95
- return b .client .SetChatAbout (chatID , about )
193
+ return b .SetChatAboutWithContext (context .Background (), chatID , about )
194
+ }
195
+
196
+ // SetChatAboutWithContext changes chat about
197
+ func (b * Bot ) SetChatAboutWithContext (ctx context.Context , chatID , about string ) error {
198
+ return b .client .SetChatAboutWithContext (ctx , chatID , about )
96
199
}
97
200
98
201
// SetChatRules changes chat rules
202
+ //
203
+ // SetChatRules uses context.Background internally; to specify the context, use
204
+ // SetChatRulesWithContext.
99
205
func (b * Bot ) SetChatRules (chatID , rules string ) error {
100
- return b .client .SetChatRules (chatID , rules )
206
+ return b .SetChatRulesWithContext (context .Background (), chatID , rules )
207
+ }
208
+
209
+ // SetChatRulesWithContext changes chat rules
210
+ func (b * Bot ) SetChatRulesWithContext (ctx context.Context , chatID , rules string ) error {
211
+ return b .client .SetChatRulesWithContext (ctx , chatID , rules )
101
212
}
102
213
103
214
// GetFileInfo returns information about file:
104
215
// id, type, size, filename, url
216
+ //
217
+ // GetFileInfo uses context.Background internally; to specify the context, use
218
+ // GetFileInfoWithContext.
105
219
func (b * Bot ) GetFileInfo (fileID string ) (* File , error ) {
106
- return b .client .GetFileInfo (fileID )
220
+ return b .GetFileInfoWithContext (context .Background (), fileID )
221
+ }
222
+
223
+ // GetFileInfoWithContext returns information about file:
224
+ // id, type, size, filename, url
225
+ func (b * Bot ) GetFileInfoWithContext (ctx context.Context , fileID string ) (* File , error ) {
226
+ return b .client .GetFileInfoWithContext (ctx , fileID )
107
227
}
108
228
109
229
// NewMessage returns new message
@@ -206,14 +326,31 @@ func (b *Bot) NewChat(id string) *Chat {
206
326
207
327
// SendMessage sends a message, passed as an argument.
208
328
// This method fills the argument with ID of sent message and returns an error if any.
329
+ //
330
+ // SendMessage uses context.Background internally; to specify the context, use
331
+ // SendMessageWithContext.
209
332
func (b * Bot ) SendMessage (message * Message ) error {
333
+ return b .SendMessageWithContext (context .Background (), message )
334
+ }
335
+
336
+ // SendMessageWithContext sends a message, passed as an argument.
337
+ // This method fills the argument with ID of sent message and returns an error if any.
338
+ func (b * Bot ) SendMessageWithContext (ctx context.Context , message * Message ) error {
210
339
message .client = b .client
211
- return message .Send ( )
340
+ return message .SendWithContext ( ctx )
212
341
}
213
342
214
343
// EditMessage edit a message passed as an argument.
344
+ //
345
+ // EditMessage uses context.Background internally; to specify the context, use
346
+ // EditMessageWithContext.
215
347
func (b * Bot ) EditMessage (message * Message ) error {
216
- return b .client .EditMessage (message )
348
+ return b .EditMessageWithContext (context .Background (), message )
349
+ }
350
+
351
+ // EditMessageWithContext edit a message passed as an argument.
352
+ func (b * Bot ) EditMessageWithContext (ctx context.Context , message * Message ) error {
353
+ return b .client .EditMessageWithContext (ctx , message )
217
354
}
218
355
219
356
// GetUpdatesChannel returns a channel, which will be filled with events.
0 commit comments