diff --git a/config.ini.example b/config.ini.example index 68c40e0..ee95054 100644 --- a/config.ini.example +++ b/config.ini.example @@ -59,6 +59,11 @@ Whitelist = @example, username, -1001132836449 ; MediaWhitelist = chatphoto, photo, sticker MediaWhitelist = chatphoto, photo, sticker +# dialog type to download. Options are: +# "user", "group", "channel". +# An empty list (default if omitted) means all are allowed. +DialogWhitelist = user, group, channel + # The maximum allowed file size for a document before skipping it. # For instance, "800KB" will only download files smaller or equal to 800KB. # Allowed units are "B", "KB", "MB" and "GB" (decimal point allowed). diff --git a/telegram_export/__main__.py b/telegram_export/__main__.py index 70de853..94a726b 100644 --- a/telegram_export/__main__.py +++ b/telegram_export/__main__.py @@ -59,6 +59,7 @@ def load_config(filename): 'SessionName': 'exporter', 'OutputDirectory': '.', 'MediaWhitelist': 'chatphoto, photo, sticker', + 'DialogWhitelist': 'user, group, channel', 'MaxSize': '1MB', 'LogLevel': 'INFO', 'DBFileName': 'export', diff --git a/telegram_export/exporter.py b/telegram_export/exporter.py index 2a2b0b6..fa7a09c 100644 --- a/telegram_export/exporter.py +++ b/telegram_export/exporter.py @@ -81,8 +81,20 @@ async def start(self): await self.downloader.start(entity) else: # Neither blacklist nor whitelist - get all + dialog_to_dump = (self.dumper.config.get('DialogWhitelist') or '').replace(' ' ,'').split(',') for dialog in await self.client.get_dialogs(limit=None): - await self.downloader.start(dialog.entity) + if dialog.is_user: + dialogType = 'user' + elif dialog.is_group: + dialogType = 'group' + elif dialog.is_channel: + dialogType = 'channel' + else: + dialogType = 'unknown!' + if dialogType in dialog_to_dump: + await self.downloader.start(dialog.entity) + else: + continue async def download_past_media(self): """