From 7d8ebdc0dd6fd51f461b60a5f95d73f0e4b66de5 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Thu, 28 Jun 2018 00:11:48 +0200 Subject: [PATCH 1/3] Add "406 Not Acceptable" error class --- compiler/error/source/406_NOT_ACCEPTABLE.tsv | 1 + 1 file changed, 1 insertion(+) create mode 100644 compiler/error/source/406_NOT_ACCEPTABLE.tsv diff --git a/compiler/error/source/406_NOT_ACCEPTABLE.tsv b/compiler/error/source/406_NOT_ACCEPTABLE.tsv new file mode 100644 index 00000000..d82f6e11 --- /dev/null +++ b/compiler/error/source/406_NOT_ACCEPTABLE.tsv @@ -0,0 +1 @@ +id message From 38b7abec3546603697094a22182ec374265c56b3 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Thu, 28 Jun 2018 00:15:53 +0200 Subject: [PATCH 2/3] Add AUTH_KEY_DUPLICATED error --- compiler/error/source/406_NOT_ACCEPTABLE.tsv | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/error/source/406_NOT_ACCEPTABLE.tsv b/compiler/error/source/406_NOT_ACCEPTABLE.tsv index d82f6e11..3a88a7b6 100644 --- a/compiler/error/source/406_NOT_ACCEPTABLE.tsv +++ b/compiler/error/source/406_NOT_ACCEPTABLE.tsv @@ -1 +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 From 6e4c608875885c7753af1862614255b120323865 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Thu, 28 Jun 2018 00:16:12 +0200 Subject: [PATCH 3/3] Handle AUTH_KEY_DUPLICATED error --- pyrogram/session/session.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyrogram/session/session.py b/pyrogram/session/session.py index ef7b565c..b7645b11 100644 --- a/pyrogram/session/session.py +++ b/pyrogram/session/session.py @@ -31,7 +31,7 @@ from pyrogram import __copyright__, __license__, __version__ from pyrogram.api import functions, types, core from pyrogram.api.all import layer from pyrogram.api.core import Message, Object, MsgContainer, Long, FutureSalt, Int -from pyrogram.api.errors import Error, InternalServerError +from pyrogram.api.errors import Error, InternalServerError, AuthKeyDuplicated from pyrogram.connection import Connection from pyrogram.crypto import AES, KDF from .internals import MsgId, MsgFactory, DataCenter @@ -157,6 +157,9 @@ class Session: self.ping_thread.start() log.info("Connection inited: Layer {}".format(layer)) + except AuthKeyDuplicated as e: + self.stop() + raise e except (OSError, TimeoutError, Error): self.stop() except Exception as e: