1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

Add bot2.0 new methods.

This commit is contained in:
eternnoir 2016-04-14 14:48:26 +08:00
parent 209764a5d7
commit 4dc7af71a0
2 changed files with 50 additions and 0 deletions

View File

@ -415,6 +415,19 @@ class TeleBot:
def send_venue(self, chat_id, latitude, longitude, title, address, foursquare_id=None, disable_notification=None,
reply_to_message_id=None, reply_markup=None):
"""
Use this method to send information about a venue.
:param chat_id: Integer or String : Unique identifier for the target chat or username of the target channel
:param latitude: Float : Latitude of the venue
:param longitude: Float : Longitude of the venue
:param title: String : Name of the venue
:param address: String : Address of the venue
:param foursquare_id: String : Foursquare identifier of the venue
:param disable_notification:
:param reply_to_message_id:
:param reply_markup:
:return:
"""
return types.Message.de_json(
apihelper.send_venue(self.token, chat_id, latitude, longitude, title, address, foursquare_id,
disable_notification, reply_to_message_id, reply_markup)
@ -432,6 +445,21 @@ class TeleBot:
"""
return apihelper.send_chat_action(self.token, chat_id, action)
def kick_chat_member(self, chat_id, user_id):
"""
Use this method to kick a user from a group or a supergroup.
:param chat_id: Int or string : Unique identifier for the target group or username of the target supergroup
:param user_id: Int : Unique identifier of the target user
:return: types.Message
"""
return apihelper.kick_chat_member(self.token, chat_id, user_id)
def unban_chat_member(self, chat_id, user_id):
return apihelper.unban_chat_member(self.token, chat_id, user_id)
def answer_callback_query(self, callback_query_id, text=None, show_alert=None):
return apihelper.answer_callback_query(self.token, callback_query_id, text, show_alert)
def reply_to(self, message, text, **kwargs):
"""
Convenience function for `send_message(message.chat.id, text, reply_to_message_id=message.message_id, **kwargs)`

View File

@ -299,6 +299,28 @@ def get_method_by_type(data_type):
return r'sendSticker'
def kick_chat_member(token, chat_id, user_id):
method_url = 'kickChatMember'
payload = {'chat_id': chat_id, 'user_id': user_id}
return _make_request(token, method_url, params=payload, method='post')
def unban_chat_member(token, chat_id, user_id):
method_url = 'unbanChatMember'
payload = {'chat_id': chat_id, 'user_id': user_id}
return _make_request(token, method_url, params=payload, method='post')
def answer_callback_query(token, callback_query_id, text=None, show_alert=None):
method_url = 'answerCallbackQuery'
payload = {'callback_query_id': callback_query_id}
if text:
payload['text'] = text
if show_alert:
payload['show_alert'] = show_alert
return _make_request(token, method_url, params=payload, method='post')
def answer_inline_query(token, inline_query_id, results, cache_time=None, is_personal=None, next_offset=None):
method_url = 'answerInlineQuery'
payload = {'inline_query_id': inline_query_id, 'results': _convert_inline_results(results)}