Skip to content

Commit 4dc7af7

Browse files
committed
Add bot2.0 new methods.
1 parent 209764a commit 4dc7af7

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

‎telebot/__init__.py‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,19 @@ def send_location(self, chat_id, latitude, longitude, reply_to_message_id=None,
415415

416416
def send_venue(self, chat_id, latitude, longitude, title, address, foursquare_id=None, disable_notification=None,
417417
reply_to_message_id=None, reply_markup=None):
418+
"""
419+
Use this method to send information about a venue.
420+
:param chat_id: Integer or String : Unique identifier for the target chat or username of the target channel
421+
:param latitude: Float : Latitude of the venue
422+
:param longitude: Float : Longitude of the venue
423+
:param title: String : Name of the venue
424+
:param address: String : Address of the venue
425+
:param foursquare_id: String : Foursquare identifier of the venue
426+
:param disable_notification:
427+
:param reply_to_message_id:
428+
:param reply_markup:
429+
:return:
430+
"""
418431
return types.Message.de_json(
419432
apihelper.send_venue(self.token, chat_id, latitude, longitude, title, address, foursquare_id,
420433
disable_notification, reply_to_message_id, reply_markup)
@@ -432,6 +445,21 @@ def send_chat_action(self, chat_id, action):
432445
"""
433446
return apihelper.send_chat_action(self.token, chat_id, action)
434447

448+
def kick_chat_member(self, chat_id, user_id):
449+
"""
450+
Use this method to kick a user from a group or a supergroup.
451+
:param chat_id: Int or string : Unique identifier for the target group or username of the target supergroup
452+
:param user_id: Int : Unique identifier of the target user
453+
:return: types.Message
454+
"""
455+
return apihelper.kick_chat_member(self.token, chat_id, user_id)
456+
457+
def unban_chat_member(self, chat_id, user_id):
458+
return apihelper.unban_chat_member(self.token, chat_id, user_id)
459+
460+
def answer_callback_query(self, callback_query_id, text=None, show_alert=None):
461+
return apihelper.answer_callback_query(self.token, callback_query_id, text, show_alert)
462+
435463
def reply_to(self, message, text, **kwargs):
436464
"""
437465
Convenience function for `send_message(message.chat.id, text, reply_to_message_id=message.message_id, **kwargs)`

‎telebot/apihelper.py‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,28 @@ def get_method_by_type(data_type):
299299
return r'sendSticker'
300300

301301

302+
def kick_chat_member(token, chat_id, user_id):
303+
method_url = 'kickChatMember'
304+
payload = {'chat_id': chat_id, 'user_id': user_id}
305+
return _make_request(token, method_url, params=payload, method='post')
306+
307+
308+
def unban_chat_member(token, chat_id, user_id):
309+
method_url = 'unbanChatMember'
310+
payload = {'chat_id': chat_id, 'user_id': user_id}
311+
return _make_request(token, method_url, params=payload, method='post')
312+
313+
314+
def answer_callback_query(token, callback_query_id, text=None, show_alert=None):
315+
method_url = 'answerCallbackQuery'
316+
payload = {'callback_query_id': callback_query_id}
317+
if text:
318+
payload['text'] = text
319+
if show_alert:
320+
payload['show_alert'] = show_alert
321+
return _make_request(token, method_url, params=payload, method='post')
322+
323+
302324
def answer_inline_query(token, inline_query_id, results, cache_time=None, is_personal=None, next_offset=None):
303325
method_url = 'answerInlineQuery'
304326
payload = {'inline_query_id': inline_query_id, 'results': _convert_inline_results(results)}

0 commit comments

Comments
 (0)