diff --git a/compiler/error/source/406_NOT_ACCEPTABLE.tsv b/compiler/error/source/406_NOT_ACCEPTABLE.tsv new file mode 100644 index 00000000..3a88a7b6 --- /dev/null +++ b/compiler/error/source/406_NOT_ACCEPTABLE.tsv @@ -0,0 +1,2 @@ +id message +AUTH_KEY_DUPLICATED Authorization error. You must log out and log in again with your phone number. We apologize for the inconvenience. \ No newline at end of file diff --git a/pyrogram/session/session.py b/pyrogram/session/session.py index 04033885..ca12c92b 100644 --- a/pyrogram/session/session.py +++ b/pyrogram/session/session.py @@ -27,7 +27,7 @@ from pyrogram import __copyright__, __license__, __version__ from pyrogram.api import functions, types from pyrogram.api.all import layer from pyrogram.api.core import Object, MsgContainer, Int, Long, FutureSalt, FutureSalts -from pyrogram.api.errors import Error, InternalServerError +from pyrogram.api.errors import Error, InternalServerError, AuthKeyDuplicated from pyrogram.connection import Connection from pyrogram.crypto import MTProto from .internals import MsgId, MsgFactory, DataCenter @@ -143,6 +143,9 @@ class Session: self.ping_task = asyncio.ensure_future(self.ping()) log.info("Connection inited: Layer {}".format(layer)) + except AuthKeyDuplicated as e: + self.stop() + raise e except (OSError, TimeoutError, Error): await self.stop() except Exception as e: