prefer snake_case for telegram.Bot methods

This commit is contained in:
Rahiel Kasim 2017-05-07 16:09:58 +02:00
parent cdf36a20b7
commit 9f3afa5fa2

View file

@ -160,7 +160,7 @@ class Bot(TelegramObject):
return decorator return decorator
@log @log
def getMe(self, timeout=None, **kwargs): def get_me(self, timeout=None, **kwargs):
"""A simple method for testing your bot's auth token. """A simple method for testing your bot's auth token.
Args: Args:
@ -186,16 +186,16 @@ class Bot(TelegramObject):
@log @log
@message @message
def sendMessage(self, def send_message(self,
chat_id, chat_id,
text, text,
parse_mode=None, parse_mode=None,
disable_web_page_preview=None, disable_web_page_preview=None,
disable_notification=False, disable_notification=False,
reply_to_message_id=None, reply_to_message_id=None,
reply_markup=None, reply_markup=None,
timeout=None, timeout=None,
**kwargs): **kwargs):
"""Use this method to send text messages. """Use this method to send text messages.
Args: Args:
@ -243,13 +243,13 @@ class Bot(TelegramObject):
@log @log
@message @message
def forwardMessage(self, def forward_message(self,
chat_id, chat_id,
from_chat_id, from_chat_id,
message_id, message_id,
disable_notification=False, disable_notification=False,
timeout=None, timeout=None,
**kwargs): **kwargs):
"""Use this method to forward messages of any kind. """Use this method to forward messages of any kind.
Args: Args:
@ -285,15 +285,15 @@ class Bot(TelegramObject):
return url, data return url, data
@log @log
def sendPhoto(self, def send_photo(self,
chat_id, chat_id,
photo, photo,
caption=None, caption=None,
disable_notification=False, disable_notification=False,
reply_to_message_id=None, reply_to_message_id=None,
reply_markup=None, reply_markup=None,
timeout=20., timeout=20.,
**kwargs): **kwargs):
"""Use this method to send photos. """Use this method to send photos.
Args: Args:
@ -339,18 +339,18 @@ class Bot(TelegramObject):
**kwargs) **kwargs)
@log @log
def sendAudio(self, def send_audio(self,
chat_id, chat_id,
audio, audio,
duration=None, duration=None,
performer=None, performer=None,
title=None, title=None,
caption=None, caption=None,
disable_notification=False, disable_notification=False,
reply_to_message_id=None, reply_to_message_id=None,
reply_markup=None, reply_markup=None,
timeout=20., timeout=20.,
**kwargs): **kwargs):
"""Use this method to send audio files, if you want Telegram clients to """Use this method to send audio files, if you want Telegram clients to
display them in the music player. Your audio must be in an .mp3 format. display them in the music player. Your audio must be in an .mp3 format.
On success, the sent Message is returned. Bots can currently send audio On success, the sent Message is returned. Bots can currently send audio
@ -417,16 +417,16 @@ class Bot(TelegramObject):
**kwargs) **kwargs)
@log @log
def sendDocument(self, def send_document(self,
chat_id, chat_id,
document, document,
filename=None, filename=None,
caption=None, caption=None,
disable_notification=False, disable_notification=False,
reply_to_message_id=None, reply_to_message_id=None,
reply_markup=None, reply_markup=None,
timeout=20., timeout=20.,
**kwargs): **kwargs):
"""Use this method to send general files. """Use this method to send general files.
Args: Args:
@ -478,14 +478,14 @@ class Bot(TelegramObject):
@log @log
@message @message
def sendSticker(self, def send_sticker(self,
chat_id, chat_id,
sticker, sticker,
disable_notification=False, disable_notification=False,
reply_to_message_id=None, reply_to_message_id=None,
reply_markup=None, reply_markup=None,
timeout=None, timeout=None,
**kwargs): **kwargs):
"""Use this method to send .webp stickers. """Use this method to send .webp stickers.
Args: Args:
@ -519,16 +519,16 @@ class Bot(TelegramObject):
return url, data return url, data
@log @log
def sendVideo(self, def send_video(self,
chat_id, chat_id,
video, video,
duration=None, duration=None,
caption=None, caption=None,
disable_notification=False, disable_notification=False,
reply_to_message_id=None, reply_to_message_id=None,
reply_markup=None, reply_markup=None,
timeout=20., timeout=20.,
**kwargs): **kwargs):
"""Use this method to send video files, Telegram clients support mp4 """Use this method to send video files, Telegram clients support mp4
videos (other formats may be sent as telegram.Document). videos (other formats may be sent as telegram.Document).
@ -579,16 +579,16 @@ class Bot(TelegramObject):
**kwargs) **kwargs)
@log @log
def sendVoice(self, def send_voice(self,
chat_id, chat_id,
voice, voice,
duration=None, duration=None,
caption=None, caption=None,
disable_notification=False, disable_notification=False,
reply_to_message_id=None, reply_to_message_id=None,
reply_markup=None, reply_markup=None,
timeout=20., timeout=20.,
**kwargs): **kwargs):
"""Use this method to send audio files, if you want Telegram clients to display the file as """Use this method to send audio files, if you want Telegram clients to display the file as
a playable voice message. For this to work, your audio must be in an .ogg file encoded with a playable voice message. For this to work, your audio must be in an .ogg file encoded with
OPUS (other formats may be sent as Audio or Document). On success, the sent Message is OPUS (other formats may be sent as Audio or Document). On success, the sent Message is
@ -643,15 +643,15 @@ class Bot(TelegramObject):
@log @log
@message @message
def sendLocation(self, def send_location(self,
chat_id, chat_id,
latitude, latitude,
longitude, longitude,
disable_notification=False, disable_notification=False,
reply_to_message_id=None, reply_to_message_id=None,
reply_markup=None, reply_markup=None,
timeout=None, timeout=None,
**kwargs): **kwargs):
"""Use this method to send point on the map. """Use this method to send point on the map.
Args: Args:
@ -685,18 +685,18 @@ class Bot(TelegramObject):
@log @log
@message @message
def sendVenue(self, def send_venue(self,
chat_id, chat_id,
latitude, latitude,
longitude, longitude,
title, title,
address, address,
foursquare_id=None, foursquare_id=None,
disable_notification=False, disable_notification=False,
reply_to_message_id=None, reply_to_message_id=None,
reply_markup=None, reply_markup=None,
timeout=None, timeout=None,
**kwargs): **kwargs):
""" """
Use this method to send information about a venue. Use this method to send information about a venue.
@ -744,16 +744,16 @@ class Bot(TelegramObject):
@log @log
@message @message
def sendContact(self, def send_contact(self,
chat_id, chat_id,
phone_number, phone_number,
first_name, first_name,
last_name=None, last_name=None,
disable_notification=False, disable_notification=False,
reply_to_message_id=None, reply_to_message_id=None,
reply_markup=None, reply_markup=None,
timeout=None, timeout=None,
**kwargs): **kwargs):
""" """
Use this method to send phone contacts. Use this method to send phone contacts.
@ -793,14 +793,14 @@ class Bot(TelegramObject):
@log @log
@message @message
def sendGame(self, def send_game(self,
chat_id, chat_id,
game_short_name, game_short_name,
disable_notification=False, disable_notification=False,
reply_to_message_id=None, reply_to_message_id=None,
reply_markup=None, reply_markup=None,
timeout=None, timeout=None,
**kwargs): **kwargs):
"""Use this method to send a game. """Use this method to send a game.
Args: Args:
@ -836,7 +836,7 @@ class Bot(TelegramObject):
@log @log
@message @message
def sendChatAction(self, chat_id, action, timeout=None, **kwargs): def send_chat_action(self, chat_id, action, timeout=None, **kwargs):
"""Use this method when you need to tell the user that something is happening on the bot's """Use this method when you need to tell the user that something is happening on the bot's
side. The status is set for 5 seconds or less (when a message arrives from your bot, side. The status is set for 5 seconds or less (when a message arrives from your bot,
Telegram clients clear its typing status). Telegram clients clear its typing status).
@ -865,16 +865,16 @@ class Bot(TelegramObject):
return url, data return url, data
@log @log
def answerInlineQuery(self, def answer_inline_query(self,
inline_query_id, inline_query_id,
results, results,
cache_time=300, cache_time=300,
is_personal=None, is_personal=None,
next_offset=None, next_offset=None,
switch_pm_text=None, switch_pm_text=None,
switch_pm_parameter=None, switch_pm_parameter=None,
timeout=None, timeout=None,
**kwargs): **kwargs):
"""Use this method to send answers to an inline query. No more than 50 results per query """Use this method to send answers to an inline query. No more than 50 results per query
are allowed. are allowed.
@ -930,7 +930,7 @@ class Bot(TelegramObject):
return result return result
@log @log
def getUserProfilePhotos(self, user_id, offset=None, limit=100, timeout=None, **kwargs): def get_user_profile_photos(self, user_id, offset=None, limit=100, timeout=None, **kwargs):
"""Use this method to get a list of profile pictures for a user. """Use this method to get a list of profile pictures for a user.
Args: Args:
@ -966,7 +966,7 @@ class Bot(TelegramObject):
return UserProfilePhotos.de_json(result, self) return UserProfilePhotos.de_json(result, self)
@log @log
def getFile(self, file_id, timeout=None, **kwargs): def get_file(self, file_id, timeout=None, **kwargs):
"""Use this method to get basic info about a file and prepare it for downloading. For the """Use this method to get basic info about a file and prepare it for downloading. For the
moment, bots can download files of up to 20MB in size. moment, bots can download files of up to 20MB in size.
@ -996,7 +996,7 @@ class Bot(TelegramObject):
return File.de_json(result, self) return File.de_json(result, self)
@log @log
def kickChatMember(self, chat_id, user_id, timeout=None, **kwargs): def kick_chat_member(self, chat_id, user_id, timeout=None, **kwargs):
"""Use this method to kick a user from a group or a supergroup. """Use this method to kick a user from a group or a supergroup.
In the case of supergroups, the user will not be able to return to the group on their own In the case of supergroups, the user will not be able to return to the group on their own
@ -1028,7 +1028,7 @@ class Bot(TelegramObject):
return result return result
@log @log
def unbanChatMember(self, chat_id, user_id, timeout=None, **kwargs): def unban_chat_member(self, chat_id, user_id, timeout=None, **kwargs):
"""Use this method to unban a previously kicked user in a supergroup. """Use this method to unban a previously kicked user in a supergroup.
The user will not return to the group automatically, but will be able to join via link, The user will not return to the group automatically, but will be able to join via link,
etc. The bot must be an administrator in the group for this to work. etc. The bot must be an administrator in the group for this to work.
@ -1058,14 +1058,14 @@ class Bot(TelegramObject):
return result return result
@log @log
def answerCallbackQuery(self, def answer_callback_query(self,
callback_query_id, callback_query_id,
text=None, text=None,
show_alert=False, show_alert=False,
url=None, url=None,
cache_time=None, cache_time=None,
timeout=None, timeout=None,
**kwargs): **kwargs):
"""Use this method to send answers to callback queries sent from inline keyboards. The """Use this method to send answers to callback queries sent from inline keyboards. The
answer will be displayed to the user as a notification at the top of the chat screen or as answer will be displayed to the user as a notification at the top of the chat screen or as
an alert. an alert.
@ -1111,16 +1111,16 @@ class Bot(TelegramObject):
@log @log
@message @message
def editMessageText(self, def edit_message_text(self,
text, text,
chat_id=None, chat_id=None,
message_id=None, message_id=None,
inline_message_id=None, inline_message_id=None,
parse_mode=None, parse_mode=None,
disable_web_page_preview=None, disable_web_page_preview=None,
reply_markup=None, reply_markup=None,
timeout=None, timeout=None,
**kwargs): **kwargs):
"""Use this method to edit text messages sent by the bot or via the bot (for inline bots). """Use this method to edit text messages sent by the bot or via the bot (for inline bots).
Args: Args:
@ -1170,14 +1170,14 @@ class Bot(TelegramObject):
@log @log
@message @message
def editMessageCaption(self, def edit_message_caption(self,
chat_id=None, chat_id=None,
message_id=None, message_id=None,
inline_message_id=None, inline_message_id=None,
caption=None, caption=None,
reply_markup=None, reply_markup=None,
timeout=None, timeout=None,
**kwargs): **kwargs):
"""Use this method to edit captions of messages sent by the bot or via the bot (for inline """Use this method to edit captions of messages sent by the bot or via the bot (for inline
bots). bots).
@ -1227,13 +1227,13 @@ class Bot(TelegramObject):
@log @log
@message @message
def editMessageReplyMarkup(self, def edit_message_reply_markup(self,
chat_id=None, chat_id=None,
message_id=None, message_id=None,
inline_message_id=None, inline_message_id=None,
reply_markup=None, reply_markup=None,
timeout=None, timeout=None,
**kwargs): **kwargs):
"""Use this method to edit only the reply markup of messages sent by the bot or via the bot """Use this method to edit only the reply markup of messages sent by the bot or via the bot
(for inline bots). (for inline bots).
@ -1280,14 +1280,14 @@ class Bot(TelegramObject):
return url, data return url, data
@log @log
def getUpdates(self, def get_updates(self,
offset=None, offset=None,
limit=100, limit=100,
timeout=0, timeout=0,
network_delay=None, network_delay=None,
read_latency=2., read_latency=2.,
allowed_updates=None, allowed_updates=None,
**kwargs): **kwargs):
"""Use this method to receive incoming updates using long polling. """Use this method to receive incoming updates using long polling.
Args: Args:
@ -1363,13 +1363,13 @@ class Bot(TelegramObject):
return [Update.de_json(u, self) for u in result] return [Update.de_json(u, self) for u in result]
@log @log
def setWebhook(self, def set_webhook(self,
url=None, url=None,
certificate=None, certificate=None,
timeout=None, timeout=None,
max_connections=40, max_connections=40,
allowed_updates=None, allowed_updates=None,
**kwargs): **kwargs):
"""Use this method to specify a url and receive incoming updates via an outgoing webhook. """Use this method to specify a url and receive incoming updates via an outgoing webhook.
Whenever there is an update for the bot, we will send an HTTPS POST request to the Whenever there is an update for the bot, we will send an HTTPS POST request to the
specified url, containing a JSON-serialized Update. In case of an unsuccessful request, we specified url, containing a JSON-serialized Update. In case of an unsuccessful request, we
@ -1432,7 +1432,7 @@ class Bot(TelegramObject):
return result return result
@log @log
def deleteWebhook(self, timeout=None, **kwargs): def delete_webhook(self, timeout=None, **kwargs):
"""Use this method to remove webhook integration if you decide to switch back to """Use this method to remove webhook integration if you decide to switch back to
getUpdates. Returns True on success. Requires no parameters. getUpdates. Returns True on success. Requires no parameters.
@ -1457,7 +1457,7 @@ class Bot(TelegramObject):
return result return result
@log @log
def leaveChat(self, chat_id, timeout=None, **kwargs): def leave_chat(self, chat_id, timeout=None, **kwargs):
"""Use this method for your bot to leave a group, supergroup or channel. """Use this method for your bot to leave a group, supergroup or channel.
Args: Args:
@ -1484,7 +1484,7 @@ class Bot(TelegramObject):
return result return result
@log @log
def getChat(self, chat_id, timeout=None, **kwargs): def get_chat(self, chat_id, timeout=None, **kwargs):
"""Use this method to get up to date information about the chat (current name of the user """Use this method to get up to date information about the chat (current name of the user
for one-on-one conversations, current username of a user, group or channel, etc.). for one-on-one conversations, current username of a user, group or channel, etc.).
@ -1513,7 +1513,7 @@ class Bot(TelegramObject):
return Chat.de_json(result, self) return Chat.de_json(result, self)
@log @log
def getChatAdministrators(self, chat_id, timeout=None, **kwargs): def get_chat_administrators(self, chat_id, timeout=None, **kwargs):
"""Use this method to get a list of administrators in a chat. On success, returns an Array """Use this method to get a list of administrators in a chat. On success, returns an Array
of ChatMember objects that contains information about all chat administrators except other of ChatMember objects that contains information about all chat administrators except other
bots. If the chat is a group or a supergroup and no administrators were appointed, only the bots. If the chat is a group or a supergroup and no administrators were appointed, only the
@ -1543,7 +1543,7 @@ class Bot(TelegramObject):
return [ChatMember.de_json(x, self) for x in result] return [ChatMember.de_json(x, self) for x in result]
@log @log
def getChatMembersCount(self, chat_id, timeout=None, **kwargs): def get_chat_members_count(self, chat_id, timeout=None, **kwargs):
"""Use this method to get the number of members in a chat. """Use this method to get the number of members in a chat.
Args: Args:
@ -1570,7 +1570,7 @@ class Bot(TelegramObject):
return result return result
@log @log
def getChatMember(self, chat_id, user_id, timeout=None, **kwargs): def get_chat_member(self, chat_id, user_id, timeout=None, **kwargs):
"""Use this method to get information about a member of a chat. """Use this method to get information about a member of a chat.
Args: Args:
@ -1597,7 +1597,7 @@ class Bot(TelegramObject):
return ChatMember.de_json(result, self) return ChatMember.de_json(result, self)
def getWebhookInfo(self, timeout=None, **kwargs): def get_webhook_info(self, timeout=None, **kwargs):
"""Use this method to get current webhook status. """Use this method to get current webhook status.
If the bot is using getUpdates, will return an object with the url field empty. If the bot is using getUpdates, will return an object with the url field empty.
@ -1619,17 +1619,17 @@ class Bot(TelegramObject):
return WebhookInfo.de_json(result, self) return WebhookInfo.de_json(result, self)
def setGameScore(self, def set_game_score(self,
user_id, user_id,
score, score,
chat_id=None, chat_id=None,
message_id=None, message_id=None,
inline_message_id=None, inline_message_id=None,
edit_message=None, edit_message=None,
force=None, force=None,
disable_edit_message=None, disable_edit_message=None,
timeout=None, timeout=None,
**kwargs): **kwargs):
"""Use this method to set the score of the specified user in a game. """Use this method to set the score of the specified user in a game.
Args: Args:
@ -1684,13 +1684,13 @@ class Bot(TelegramObject):
else: else:
return Message.de_json(result, self) return Message.de_json(result, self)
def getGameHighScores(self, def get_game_high_scores(self,
user_id, user_id,
chat_id=None, chat_id=None,
message_id=None, message_id=None,
inline_message_id=None, inline_message_id=None,
timeout=None, timeout=None,
**kwargs): **kwargs):
"""Use this method to get data for high score tables. """Use this method to get data for high score tables.
Args: Args:
@ -1736,39 +1736,38 @@ class Bot(TelegramObject):
return (self.__class__, (self.token, self.base_url.replace(self.token, ''), return (self.__class__, (self.token, self.base_url.replace(self.token, ''),
self.base_file_url.replace(self.token, ''))) self.base_file_url.replace(self.token, '')))
# snake_case (PEP8) aliases # camelCase aliases
getMe = get_me
get_me = getMe sendMessage = send_message
send_message = sendMessage forwardMessage = forward_message
forward_message = forwardMessage sendPhoto = send_photo
send_photo = sendPhoto sendAudio = send_audio
send_audio = sendAudio sendDocument = send_document
send_document = sendDocument sendSticker = send_sticker
send_sticker = sendSticker sendVideo = send_video
send_video = sendVideo sendVoice = send_voice
send_voice = sendVoice sendLocation = send_location
send_location = sendLocation sendVenue = send_venue
send_venue = sendVenue sendContact = send_contact
send_contact = sendContact sendGame = send_game
send_game = sendGame sendChatAction = send_chat_action
send_chat_action = sendChatAction answerInlineQuery = answer_inline_query
answer_inline_query = answerInlineQuery getUserProfilePhotos = get_user_profile_photos
get_user_profile_photos = getUserProfilePhotos getFile = get_file
get_file = getFile kickChatMember = kick_chat_member
kick_chat_member = kickChatMember unbanChatMember = unban_chat_member
unban_chat_member = unbanChatMember answerCallbackQuery = answer_callback_query
answer_callback_query = answerCallbackQuery editMessageText = edit_message_text
edit_message_text = editMessageText editMessageCaption = edit_message_caption
edit_message_caption = editMessageCaption editMessageReplyMarkup = edit_message_reply_markup
edit_message_reply_markup = editMessageReplyMarkup getUpdates = get_updates
get_updates = getUpdates setWebhook = set_webhook
set_webhook = setWebhook deleteWebhook = delete_webhook
delete_webhook = deleteWebhook leaveChat = leave_chat
leave_chat = leaveChat getChat = get_chat
get_chat = getChat getChatAdministrators = get_chat_administrators
get_chat_administrators = getChatAdministrators getChatMember = get_chat_member
get_chat_member = getChatMember getChatMembersCount = get_chat_members_count
get_chat_members_count = getChatMembersCount getWebhookInfo = get_webhook_info
get_webhook_info = getWebhookInfo setGameScore = set_game_score
set_game_score = setGameScore getGameHighScores = get_game_high_scores
get_game_high_scores = getGameHighScores