Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ The following wonderful people contributed directly or indirectly to this projec
- `Pieter Schutz <https://github.com/eldinnie>`_
- `Rahiel Kasim <https://github.com/rahiel>`_
- `Joscha Götzer <https://github.com/Rostgnom>`_
- `Sascha <https://github.com/saschalalala>`_
- `Shelomentsev D <https://github.com/shelomentsevd>`_
- `sooyhwang <https://github.com/sooyhwang>`_
- `thodnev <https://github.com/thodnev>`_
Expand Down
14 changes: 7 additions & 7 deletions examples/paymentbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ def shipping_callback(bot, update):
# check the payload, is this from your bot?
if query.invoice_payload != 'Custom-Payload':
# answer False pre_checkout_query
bot.answerShippingQuery(shipping_query_id=query.id, ok=False,
error_message="Something went wrong...")
bot.answer_shipping_query(shipping_query_id=query.id, ok=False,
error_message="Something went wrong...")
return
else:
options = list()
Expand All @@ -85,8 +85,8 @@ def shipping_callback(bot, update):
# an array of LabeledPrice objects
price_list = [LabeledPrice('B1', 150), LabeledPrice('B2', 200)]
options.append(ShippingOption('2', 'Shipping Option B', price_list))
bot.answerShippingQuery(shipping_query_id=query.id, ok=True,
shipping_options=options)
bot.answer_shipping_query(shipping_query_id=query.id, ok=True,
shipping_options=options)


# after (optional) shipping, it's the pre-checkout
Expand All @@ -95,10 +95,10 @@ def precheckout_callback(bot, update):
# check the payload, is this from your bot?
if query.invoice_payload != 'Custom-Payload':
# answer False pre_checkout_query
bot.answerPreCheckoutQuery(pre_checkout_query_id=query.id, ok=False,
error_message="Something went wrong...")
bot.answer_pre_checkout_query(pre_checkout_query_id=query.id, ok=False,
error_message="Something went wrong...")
else:
bot.answerPreCheckoutQuery(pre_checkout_query_id=query.id, ok=True)
bot.answer_pre_checkout_query(pre_checkout_query_id=query.id, ok=True)


# finally, after contacting to the payment provider...
Expand Down
2 changes: 1 addition & 1 deletion telegram/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def info(func):
@functools.wraps(func)
def decorator(self, *args, **kwargs):
if not self.bot:
self.getMe()
self.get_me()

result = func(self, *args, **kwargs)
return result
Expand Down
28 changes: 14 additions & 14 deletions telegram/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,29 +89,29 @@ def de_json(data, bot):
return Chat(bot=bot, **data)

def send_action(self, *args, **kwargs):
"""Shortcut for ``bot.sendChatAction(update.message.chat.id, *args, **kwargs)``"""
return self.bot.sendChatAction(self.id, *args, **kwargs)
"""Shortcut for ``bot.send_chat_action(update.message.chat.id, *args, **kwargs)``"""
return self.bot.send_chat_action(self.id, *args, **kwargs)

def leave(self, *args, **kwargs):
"""Shortcut for ``bot.leaveChat(update.message.chat.id, *args, **kwargs)``"""
return self.bot.leaveChat(self.id, *args, **kwargs)
"""Shortcut for ``bot.leave_chat(update.message.chat.id, *args, **kwargs)``"""
return self.bot.leave_chat(self.id, *args, **kwargs)

def get_administrators(self, *args, **kwargs):
"""Shortcut for ``bot.getChatAdministrators(update.message.chat.id, *args, **kwargs)``"""
return self.bot.getChatAdministrators(self.id, *args, **kwargs)
"""Shortcut for ``bot.get_chat_administrators(update.message.chat.id, *args, **kwargs)``"""
return self.bot.get_chat_administrators(self.id, *args, **kwargs)

def get_members_count(self, *args, **kwargs):
"""Shortcut for ``bot.getChatMembersCount(update.message.chat.id, *args, **kwargs)``"""
return self.bot.getChatMembersCount(self.id, *args, **kwargs)
"""Shortcut for ``bot.get_chat_members_count(update.message.chat.id, *args, **kwargs)``"""
return self.bot.get_chat_members_count(self.id, *args, **kwargs)

def get_member(self, *args, **kwargs):
"""Shortcut for ``bot.getChatMember(update.message.chat.id, *args, **kwargs)``"""
return self.bot.getChatMember(self.id, *args, **kwargs)
"""Shortcut for ``bot.get_chat_member(update.message.chat.id, *args, **kwargs)``"""
return self.bot.get_chat_member(self.id, *args, **kwargs)

def kick_member(self, *args, **kwargs):
"""Shortcut for ``bot.kickChatMember(update.message.chat.id, *args, **kwargs)``"""
return self.bot.kickChatMember(self.id, *args, **kwargs)
"""Shortcut for ``bot.kick_chat_member(update.message.chat.id, *args, **kwargs)``"""
return self.bot.kick_chat_member(self.id, *args, **kwargs)

def unban_member(self, *args, **kwargs):
"""Shortcut for ``bot.unbanChatMember(update.message.chat.id, *args, **kwargs)``"""
return self.bot.unbanChatMember(self.id, *args, **kwargs)
"""Shortcut for ``bot.unban_chat_member(update.message.chat.id, *args, **kwargs)``"""
return self.bot.unban_chat_member(self.id, *args, **kwargs)
10 changes: 5 additions & 5 deletions telegram/ext/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def _start_polling(self, poll_interval, timeout, read_latency, bootstrap_retries

while self.running:
try:
updates = self.bot.getUpdates(
updates = self.bot.get_updates(
self.last_update_id,
timeout=timeout,
read_latency=read_latency,
Expand Down Expand Up @@ -367,11 +367,11 @@ def _bootstrap(self, max_retries, clean, webhook_url, allowed_updates, cert=None
try:
if clean:
# Disable webhook for cleaning
self.bot.deleteWebhook()
self.bot.delete_webhook()
self._clean_updates()
sleep(1)

self.bot.setWebhook(
self.bot.set_webhook(
url=webhook_url, certificate=cert, allowed_updates=allowed_updates)
except (Unauthorized, InvalidToken):
raise
Expand All @@ -390,9 +390,9 @@ def _bootstrap(self, max_retries, clean, webhook_url, allowed_updates, cert=None

def _clean_updates(self):
self.logger.debug('Cleaning updates from Telegram server')
updates = self.bot.getUpdates()
updates = self.bot.get_updates()
while updates:
updates = self.bot.getUpdates(updates[-1].update_id + 1)
updates = self.bot.get_updates(updates[-1].update_id + 1)

def stop(self):
"""
Expand Down
4 changes: 2 additions & 2 deletions telegram/inlinequery.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,5 @@ def to_dict(self):
return data

def answer(self, *args, **kwargs):
"""Shortcut for ``bot.answerInlineQuery(update.inline_query.id, *args, **kwargs)``"""
return self.bot.answerInlineQuery(self.id, *args, **kwargs)
"""Shortcut for ``bot.answer_inline_query(update.inline_query.id, *args, **kwargs)``"""
return self.bot.answer_inline_query(self.id, *args, **kwargs)
50 changes: 25 additions & 25 deletions telegram/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def _quote(self, kwargs):

def reply_text(self, *args, **kwargs):
"""
Shortcut for ``bot.sendMessage(update.message.chat_id, *args, **kwargs)``
Shortcut for ``bot.send_message(update.message.chat_id, *args, **kwargs)``

Keyword Args:
quote (Optional[bool]): If set to ``True``, the message is sent as an actual reply to
Expand All @@ -337,11 +337,11 @@ def reply_text(self, *args, **kwargs):
"""

self._quote(kwargs)
return self.bot.sendMessage(self.chat_id, *args, **kwargs)
return self.bot.send_message(self.chat_id, *args, **kwargs)

def reply_photo(self, *args, **kwargs):
"""
Shortcut for ``bot.sendPhoto(update.message.chat_id, *args, **kwargs)``
Shortcut for ``bot.send_photo(update.message.chat_id, *args, **kwargs)``

Keyword Args:
quote (Optional[bool]): If set to ``True``, the photo is sent as an actual reply to
Expand All @@ -354,11 +354,11 @@ def reply_photo(self, *args, **kwargs):
"""

self._quote(kwargs)
return self.bot.sendPhoto(self.chat_id, *args, **kwargs)
return self.bot.send_photo(self.chat_id, *args, **kwargs)

def reply_audio(self, *args, **kwargs):
"""
Shortcut for ``bot.sendAudio(update.message.chat_id, *args, **kwargs)``
Shortcut for ``bot.send_audio(update.message.chat_id, *args, **kwargs)``

Keyword Args:
quote (Optional[bool]): If set to ``True``, the audio is sent as an actual reply to
Expand All @@ -371,11 +371,11 @@ def reply_audio(self, *args, **kwargs):
"""

self._quote(kwargs)
return self.bot.sendAudio(self.chat_id, *args, **kwargs)
return self.bot.send_audio(self.chat_id, *args, **kwargs)

def reply_document(self, *args, **kwargs):
"""
Shortcut for ``bot.sendDocument(update.message.chat_id, *args, **kwargs)``
Shortcut for ``bot.send_document(update.message.chat_id, *args, **kwargs)``

Keyword Args:
quote (Optional[bool]): If set to ``True``, the document is sent as an actual reply to
Expand All @@ -388,11 +388,11 @@ def reply_document(self, *args, **kwargs):
"""

self._quote(kwargs)
return self.bot.sendDocument(self.chat_id, *args, **kwargs)
return self.bot.send_document(self.chat_id, *args, **kwargs)

def reply_sticker(self, *args, **kwargs):
"""
Shortcut for ``bot.sendSticker(update.message.chat_id, *args, **kwargs)``
Shortcut for ``bot.send_sticker(update.message.chat_id, *args, **kwargs)``

Keyword Args:
quote (Optional[bool]): If set to ``True``, the sticker is sent as an actual reply to
Expand All @@ -405,11 +405,11 @@ def reply_sticker(self, *args, **kwargs):
"""

self._quote(kwargs)
return self.bot.sendSticker(self.chat_id, *args, **kwargs)
return self.bot.send_sticker(self.chat_id, *args, **kwargs)

def reply_video(self, *args, **kwargs):
"""
Shortcut for ``bot.sendVideo(update.message.chat_id, *args, **kwargs)``
Shortcut for ``bot.send_video(update.message.chat_id, *args, **kwargs)``

Keyword Args:
quote (Optional[bool]): If set to ``True``, the video is sent as an actual reply to
Expand All @@ -422,7 +422,7 @@ def reply_video(self, *args, **kwargs):
"""

self._quote(kwargs)
return self.bot.sendVideo(self.chat_id, *args, **kwargs)
return self.bot.send_video(self.chat_id, *args, **kwargs)

def reply_video_note(self, *args, **kwargs):
"""
Expand All @@ -443,7 +443,7 @@ def reply_video_note(self, *args, **kwargs):

def reply_voice(self, *args, **kwargs):
"""
Shortcut for ``bot.sendVoice(update.message.chat_id, *args, **kwargs)``
Shortcut for ``bot.send_voice(update.message.chat_id, *args, **kwargs)``

Keyword Args:
quote (Optional[bool]): If set to ``True``, the voice is sent as an actual reply to
Expand All @@ -456,11 +456,11 @@ def reply_voice(self, *args, **kwargs):
"""

self._quote(kwargs)
return self.bot.sendVoice(self.chat_id, *args, **kwargs)
return self.bot.send_voice(self.chat_id, *args, **kwargs)

def reply_location(self, *args, **kwargs):
"""
Shortcut for ``bot.sendLocation(update.message.chat_id, *args, **kwargs)``
Shortcut for ``bot.send_location(update.message.chat_id, *args, **kwargs)``

Keyword Args:
quote (Optional[bool]): If set to ``True``, the location is sent as an actual reply to
Expand All @@ -473,11 +473,11 @@ def reply_location(self, *args, **kwargs):
"""

self._quote(kwargs)
return self.bot.sendLocation(self.chat_id, *args, **kwargs)
return self.bot.send_location(self.chat_id, *args, **kwargs)

def reply_venue(self, *args, **kwargs):
"""
Shortcut for ``bot.sendVenue(update.message.chat_id, *args, **kwargs)``
Shortcut for ``bot.send_venue(update.message.chat_id, *args, **kwargs)``

Keyword Args:
quote (Optional[bool]): If set to ``True``, the venue is sent as an actual reply to
Expand All @@ -490,11 +490,11 @@ def reply_venue(self, *args, **kwargs):
"""

self._quote(kwargs)
return self.bot.sendVenue(self.chat_id, *args, **kwargs)
return self.bot.send_venue(self.chat_id, *args, **kwargs)

def reply_contact(self, *args, **kwargs):
"""
Shortcut for ``bot.sendContact(update.message.chat_id, *args, **kwargs)``
Shortcut for ``bot.send_contact(update.message.chat_id, *args, **kwargs)``

Keyword Args:
quote (Optional[bool]): If set to ``True``, the contact is sent as an actual reply to
Expand All @@ -507,12 +507,12 @@ def reply_contact(self, *args, **kwargs):
"""

self._quote(kwargs)
return self.bot.sendContact(self.chat_id, *args, **kwargs)
return self.bot.send_contact(self.chat_id, *args, **kwargs)

def forward(self, chat_id, disable_notification=False):
"""Shortcut for

>>> bot.forwardMessage(chat_id=chat_id,
>>> bot.forward_message(chat_id=chat_id,
... from_chat_id=update.message.chat_id,
... disable_notification=disable_notification,
... message_id=update.message.message_id)
Expand All @@ -521,7 +521,7 @@ def forward(self, chat_id, disable_notification=False):
:class:`telegram.Message`: On success, instance representing the message forwarded.

"""
return self.bot.forwardMessage(
return self.bot.forward_message(
chat_id=chat_id,
from_chat_id=self.chat_id,
disable_notification=disable_notification,
Expand All @@ -531,7 +531,7 @@ def edit_text(self, *args, **kwargs):
"""
Shortcut for

>>> bot.editMessageText(chat_id=message.chat_id,
>>> bot.edit_message_text(chat_id=message.chat_id,
... message_id=message.message_id,
... *args, **kwargs)

Expand All @@ -548,7 +548,7 @@ def edit_caption(self, *args, **kwargs):
"""
Shortcut for

>>> bot.editMessageCaption(chat_id=message.chat_id,
>>> bot.edit_message_caption(chat_id=message.chat_id,
... message_id=message.message_id,
... *args, **kwargs)

Expand All @@ -564,7 +564,7 @@ def edit_reply_markup(self, *args, **kwargs):
"""
Shortcut for

>>> bot.editReplyMarkup(chat_id=message.chat_id,
>>> bot.edit_message_reply_markup(chat_id=message.chat_id,
... message_id=message.message_id,
... *args, **kwargs)

Expand Down
5 changes: 3 additions & 2 deletions telegram/precheckoutquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def to_dict(self):

def answer(self, *args, **kwargs):
"""
Shortcut for ``bot.answerPreCheckoutQuery(update.pre_checkout_query.id, *args, **kwargs)``
Shortcut for
``bot.answer_pre_checkout_query(update.pre_checkout_query.id, *args, **kwargs)``
"""
return self.bot.answerPreCheckoutQuery(self.id, *args, **kwargs)
return self.bot.answer_pre_checkout_query(self.id, *args, **kwargs)
4 changes: 2 additions & 2 deletions telegram/shippingquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,5 @@ def to_dict(self):
return data

def answer(self, *args, **kwargs):
"""Shortcut for ``bot.answerShippingQuery(update.shipping_query.id, *args, **kwargs)``"""
return self.bot.answerShippingQuery(self.id, *args, **kwargs)
"""Shortcut for ``bot.answer_shipping_query(update.shipping_query.id, *args, **kwargs)``"""
return self.bot.answer_shipping_query(self.id, *args, **kwargs)
4 changes: 2 additions & 2 deletions telegram/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ def de_json(data, bot):

def get_profile_photos(self, *args, **kwargs):
"""
Shortcut for ``bot.getUserProfilePhotos(update.message.from_user.id, *args, **kwargs)``
Shortcut for ``bot.get_user_profile_photos(update.message.from_user.id, *args, **kwargs)``
"""
return self.bot.getUserProfilePhotos(self.id, *args, **kwargs)
return self.bot.get_user_profile_photos(self.id, *args, **kwargs)

@staticmethod
def de_list(data, bot):
Expand Down
Loading