From 209a30cfa1b784ce63e8f4d8505216ea359fed63 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Thu, 5 Aug 2021 18:41:30 +0200 Subject: [PATCH] fix disconnect --- main.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 87bfc12..0448956 100644 --- a/main.py +++ b/main.py @@ -52,8 +52,11 @@ class Listener(StreamListener): def on_connect(self): print(f"Scroll sur Twitter avec les abonnements de @{', @'.join(self.users)} comme timeline...") - def on_disconnect(self, notice): - print(f"Déconnexion ({notice['code']}). Raison : {notice['reason']}") + def on_disconnect(notice): + notice = notice["disconnect"] + print(f"Déconnexion (code {notice['code']}).", end = " ") + if len(notice['reason']) > 0: + print(f"Raison : {notice['reason']}") def on_status(self, status): if status._json["user"]["id"] in self.listOfFriendsID: # verification of the author of the tweet