From a36f4c28cc508f45fd5ca7c0b47ae0962e0bd576 Mon Sep 17 00:00:00 2001 From: Kosat <153023+Kosat@users.noreply.github.com> Date: Sat, 23 Mar 2019 13:43:00 +0100 Subject: [PATCH] Upgraded to Telethon 1.6.2 #30 Fixed NoneType to any kind of InputPeer problem #29 #24 --- setup.py | 2 +- telegram_messages_dump/__init__.py | 2 +- telegram_messages_dump/exporters/common.py | 2 +- telegram_messages_dump/telegram_dumper.py | 10 +++------- travis-scripts/install.linux.sh | 4 ++-- travis-scripts/install.macos.sh | 2 +- 6 files changed, 9 insertions(+), 13 deletions(-) diff --git a/setup.py b/setup.py index 049c63b..9031eda 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ author_email='kostikkv@gmail.com', url='https://github.com/Kosat/telegram-messages-dump', download_url='https://github.com/Kosat/telegram-messages-dump/releases', - install_requires=['telethon==0.19.1.6'], + install_requires=['telethon==1.6.2'], packages=['telegram_messages_dump', "telegram_messages_dump.exporters"], classifiers=[ 'Environment :: Console', diff --git a/telegram_messages_dump/__init__.py b/telegram_messages_dump/__init__.py index a5bca83..0d5b254 100644 --- a/telegram_messages_dump/__init__.py +++ b/telegram_messages_dump/__init__.py @@ -1,4 +1,4 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -__version__ = '0.3.5' +__version__ = '0.4' diff --git a/telegram_messages_dump/exporters/common.py b/telegram_messages_dump/exporters/common.py index ef1bfbb..42399a2 100644 --- a/telegram_messages_dump/exporters/common.py +++ b/telegram_messages_dump/exporters/common.py @@ -34,7 +34,7 @@ def extract_message_data(msg): name = name.strip() if not name: name = '???' - is_sent_by_bot = sender.bot + is_sent_by_bot = getattr(sender, 'bot', None) else: name = '???' diff --git a/telegram_messages_dump/telegram_dumper.py b/telegram_messages_dump/telegram_dumper.py index a26367b..707e0f0 100644 --- a/telegram_messages_dump/telegram_dumper.py +++ b/telegram_messages_dump/telegram_dumper.py @@ -13,7 +13,7 @@ from collections import deque from getpass import getpass from time import sleep -from telethon import TelegramClient +from telethon import TelegramClient, sync from telethon.errors import FloodWaitError, SessionPasswordNeededError, UsernameNotOccupiedError, UsernameInvalidError from telethon.tl.functions.contacts import ResolveUsernameRequest from telegram_messages_dump.utils import sprint @@ -33,8 +33,7 @@ def __init__(self, session_user_id, settings, metadata, exporter): super().__init__(session_user_id, settings.api_id, settings.api_hash, - proxy=None, - update_workers=1) + proxy=None) # Settings as specified by user or defaults or from metadata self.settings = settings @@ -115,10 +114,7 @@ def _init_connect(self): """ Connect to the Telegram server and Authenticate. """ sprint('Connecting to Telegram servers...') if not self.connect(): - sprint('Initial connection failed. Retrying...') - if not self.connect(): - sprint('Could not connect to Telegram servers.') - return + sprint('Initial connection failed.') # Then, ensure we're authorized and have access if not self.is_user_authorized(): diff --git a/travis-scripts/install.linux.sh b/travis-scripts/install.linux.sh index 9bdbdf7..4fe48a4 100644 --- a/travis-scripts/install.linux.sh +++ b/travis-scripts/install.linux.sh @@ -5,7 +5,7 @@ echo pwd pwd #Build for Linux -pip install -I telethon==0.19.1.6 +pip install -I telethon==1.6.2 pyinstaller -F -n telegram-messages-dump \ -c ./telegram_messages_dump/__main__.py \ --hidden-import telegram_messages_dump.exporters.text \ @@ -13,7 +13,7 @@ pyinstaller -F -n telegram-messages-dump \ --hidden-import telegram_messages_dump.exporters.csv #Setup build env for Windows: pyinstaller+telethon -# wine pip install -I telethon==0.19.1.6 +# wine pip install -I telethon==1.6.2 # wine pip install pyinstaller # wine pyinstaller -n telegram-messages-dump.exe --onefile --clean --win-private-assemblies -c --noconfirm --log-level=WARN ./telegram_messages_dump/__main__.py --hidden-import telegram_messages_dump.exporters.text --hidden-import telegram_messages_dump.exporters.jsonl --hidden-import telegram_messages_dump.exporters.csv diff --git a/travis-scripts/install.macos.sh b/travis-scripts/install.macos.sh index 9b4c19e..cedd3b8 100644 --- a/travis-scripts/install.macos.sh +++ b/travis-scripts/install.macos.sh @@ -1,7 +1,7 @@ #!/bin/bash #Install telethon: -pip3 install -I telethon==0.19.1.6 +pip3 install -I telethon==1.6.2 pyinstaller -n telegram-messages-dump --noconsole --onefile \ --hidden-import telegram_messages_dump.exporters.text \ --hidden-import telegram_messages_dump.exporters.jsonl \