@@ -32,8 +32,7 @@ function patchEmitCallbackQuery(TelegramBot) {
32
32
}
33
33
}
34
34
35
- function patchSendVenue ( TelegramBot )
36
- {
35
+ function patchSendVenue ( TelegramBot ) {
37
36
/**
38
37
* Send venue.
39
38
* Use this method to send information about a venue.
@@ -58,18 +57,166 @@ function patchSendVenue(TelegramBot)
58
57
}
59
58
}
60
59
60
+ function patchKickChatMember ( TelegramBot ) {
61
+ /**
62
+ * Use this method to kick a user from a group or a supergroup.
63
+ * In the case of supergroups, the user will not be able to return
64
+ * to the group on their own using invite links, etc., unless unbanned
65
+ * first. The bot must be an administrator in the group for this to work.
66
+ * Returns True on success.
67
+ *
68
+ * @param {Number|String } chatId Unique identifier for the target group or username of the target supergroup
69
+ * @param {String } userId Unique identifier of the target user
70
+ * @return {Promise }
71
+ * @see https://core.telegram.org/bots/api#kickchatmember
72
+ */
73
+ TelegramBot . prototype . kickChatMember = function kickChatMember ( chatId , userId ) {
74
+ const form = {
75
+ chat_id : chatId ,
76
+ user_id : userId
77
+ } ;
78
+ return this . _request ( 'kickChatMember' , { form : form } ) ;
79
+ }
80
+ }
81
+
82
+ function patchUnbanChatMember ( TelegramBot ) {
83
+ /**
84
+ * Use this method to unban a previously kicked user in a supergroup.
85
+ * The user will not return to the group automatically, but will be
86
+ * able to join via link, etc. The bot must be an administrator in
87
+ * the group for this to work. Returns True on success.
88
+ *
89
+ * @param {Number|String } chatId Unique identifier for the target group or username of the target supergroup
90
+ * @param {String } userId Unique identifier of the target user
91
+ * @return {Promise }
92
+ * @see https://core.telegram.org/bots/api#unbanchatmember
93
+ */
94
+ TelegramBot . prototype . unbanChatMember = function unbanChatMember ( chatId , userId ) {
95
+ const form = {
96
+ chat_id : chatId ,
97
+ user_id : userId
98
+ } ;
99
+ return this . _request ( 'unbanChatMember' , { form : form } ) ;
100
+ }
101
+ }
102
+
103
+ function pathAnswerCallbackQuery ( TelegramBot ) {
104
+ /**
105
+ * Use this method to send answers to callback queries sent from
106
+ * inline keyboards. The answer will be displayed to the user as
107
+ * a notification at the top of the chat screen or as an alert.
108
+ * On success, True is returned.
109
+ *
110
+ * @param {Number|String } callbackQueryId Unique identifier for the query to be answered
111
+ * @param {String } text Text of the notification. If not specified, nothing will be shown to the user
112
+ * @param {Boolean } showAlert Whether to show an alert or a notification at the top of the screen
113
+ * @param {Object } [options] Additional Telegram query options
114
+ * @return {Promise }
115
+ * @see https://core.telegram.org/bots/api#answercallbackquery
116
+ */
117
+ TelegramBot . prototype . answerCallbackQuery = function answerCallbackQuery ( callbackQueryId , text , showAlert , form ) {
118
+ form = form || { } ;
119
+ form . callback_query_id = callbackQueryId ;
120
+ form . text = text ;
121
+ form . show_alert = showAlert ;
122
+ return this . _request ( 'answerCallbackQuery' , { form : form } ) ;
123
+ }
124
+ }
125
+
126
+ function patchEditMessageText ( TelegramBot ) {
127
+ /**
128
+ * Use this method to edit text messages sent by the bot or via
129
+ * the bot (for inline bots). On success, the edited Message is
130
+ * returned.
131
+ *
132
+ * Note that you must provide one of chat_id, message_id, or
133
+ * inline_message_id in your request.
134
+ *
135
+ * @param {String } text New text of the message
136
+ * @param {Object } [options] Additional Telegram query options (provide either one of chat_id, message_id, or inline_message_id here)
137
+ * @return {Promise }
138
+ * @see https://core.telegram.org/bots/api#editmessagetext
139
+ */
140
+ TelegramBot . prototype . editMessageText = function editMessageText ( text , form ) {
141
+ form = form || { } ;
142
+ form . text = text ;
143
+ return this . _request ( 'editMessageText' , { form : form } ) ;
144
+ }
145
+
146
+ }
147
+
148
+
149
+ function patchEditMessageCaption ( TelegramBot ) {
150
+ /**
151
+ * Use this method to edit captions of messages sent by the
152
+ * bot or via the bot (for inline bots). On success, the
153
+ * edited Message is returned.
154
+ *
155
+ * Note that you must provide one of chat_id, message_id, or
156
+ * inline_message_id in your request.
157
+ *
158
+ * @param {String } caption New caption of the message
159
+ * @param {Object } [options] Additional Telegram query options (provide either one of chat_id, message_id, or inline_message_id here)
160
+ * @return {Promise }
161
+ * @see https://core.telegram.org/bots/api#editmessagecaption
162
+ */
163
+ TelegramBot . prototype . editMessageCaption = function editMessageCaption ( caption , form ) {
164
+ form = form || { } ;
165
+ form . caption = caption ;
166
+ return this . _request ( 'editMessageCaption' , { form : form } ) ;
167
+ }
168
+ }
169
+ function patchEditMessageReplyMarkup ( TelegramBot ) {
170
+ /**
171
+ * Use this method to edit only the reply markup of messages
172
+ * sent by the bot or via the bot (for inline bots).
173
+ * On success, the edited Message is returned.
174
+ *
175
+ * Note that you must provide one of chat_id, message_id, or
176
+ * inline_message_id in your request.
177
+ *
178
+ * @param {Object } replyMarkup A JSON-serialized object for an inline keyboard.
179
+ * @param {Object } [options] Additional Telegram query options (provide either one of chat_id, message_id, or inline_message_id here)
180
+ * @return {Promise }
181
+ * @see https://core.telegram.org/bots/api#editmessagereplymarkup
182
+ */
183
+ TelegramBot . prototype . editMessageReplyMarkup = function editMessageReplyMarkup ( replyMarkup , form ) {
184
+ form = form || { } ;
185
+ form . reply_markup = replyMarkup ;
186
+ return this . _request ( 'editMessageReplyMarkup' , { form : form } ) ;
187
+ }
188
+ }
189
+
61
190
module . exports = function ( TelegramBot , options ) {
62
191
options = options || { } ;
63
- if ( options . stopPolling ) {
192
+ if ( options . all || options . stopPolling ) {
64
193
patchStopPolling ( TelegramBot ) ;
65
194
}
66
- if ( options . emitUpdate ) {
195
+ if ( options . all || options . emitUpdate ) {
67
196
patchEmitUpdate ( TelegramBot ) ;
68
197
}
69
- if ( options . emitCallbackQuery ) {
198
+ if ( options . all || options . emitCallbackQuery ) {
70
199
patchEmitCallbackQuery ( TelegramBot ) ;
71
200
}
72
- if ( options . sendVenue ) {
201
+ if ( options . all || options . sendVenue ) {
73
202
patchSendVenue ( TelegramBot ) ;
74
203
}
204
+ if ( options . all || options . kickChatMember ) {
205
+ patchKickChatMember ( TelegramBot ) ;
206
+ }
207
+ if ( options . all || options . unbanChatMember ) {
208
+ patchUnbanChatMember ( TelegramBot ) ;
209
+ }
210
+ if ( options . all || options . answerCallbackQuery ) {
211
+ pathAnswerCallbackQuery ( TelegramBot ) ;
212
+ }
213
+ if ( options . all || options . editMessageText ) {
214
+ patchEditMessageText ( TelegramBot ) ;
215
+ }
216
+ if ( options . all || options . editMessageCaption ) {
217
+ patchEditMessageCaption ( TelegramBot ) ;
218
+ }
219
+ if ( options . all || options . editMessageReplyMarkup ) {
220
+ patchEditMessageReplyMarkup ( TelegramBot ) ;
221
+ }
75
222
} ;
0 commit comments