mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-12-31 16:40:53 +01:00
New exception: RetryAfter
Also, small fix to the description text of ChatMigrated
This commit is contained in:
parent
7cf5009517
commit
2463b4b9c8
2 changed files with 20 additions and 4 deletions
|
@ -94,8 +94,20 @@ class ChatMigrated(TelegramError):
|
|||
Args:
|
||||
new_chat_id (int):
|
||||
|
||||
Returns:
|
||||
"""
|
||||
super(ChatMigrated,
|
||||
self).__init__('Group migrated to supergroup. New chat id: {}'.format(new_chat_id))
|
||||
self.new_chat_id = new_chat_id
|
||||
|
||||
|
||||
class RetryAfter(TelegramError):
|
||||
|
||||
def __init__(self, retry_after):
|
||||
"""
|
||||
Args:
|
||||
retry_after (int):
|
||||
|
||||
"""
|
||||
super(ChatMigrated, self).__init__('Chat migrated')
|
||||
self.new_chat_id = new_chat_id
|
||||
super(RetryAfter,
|
||||
self).__init__('Flood control exceeded. Retry in {} seconds'.format(retry_after))
|
||||
self.retry_after = retry_after
|
||||
|
|
|
@ -31,7 +31,8 @@ import urllib3
|
|||
from urllib3.connection import HTTPConnection
|
||||
|
||||
from telegram import (InputFile, TelegramError)
|
||||
from telegram.error import Unauthorized, NetworkError, TimedOut, BadRequest, ChatMigrated
|
||||
from telegram.error import Unauthorized, NetworkError, TimedOut, BadRequest, ChatMigrated, \
|
||||
RetryAfter
|
||||
|
||||
logging.getLogger('urllib3').setLevel(logging.WARNING)
|
||||
|
||||
|
@ -105,6 +106,9 @@ class Request(object):
|
|||
migrate_to_chat_id = parameters.get('migrate_to_chat_id')
|
||||
if migrate_to_chat_id:
|
||||
raise ChatMigrated(migrate_to_chat_id)
|
||||
retry_after = parameters.get('retry_after')
|
||||
if retry_after:
|
||||
raise RetryAfter(retry_after)
|
||||
if description:
|
||||
return description
|
||||
|
||||
|
|
Loading…
Reference in a new issue