From ed82071395b7ea4bd4596dade10915c654d356ee Mon Sep 17 00:00:00 2001 From: Aleksey Date: Mon, 8 Apr 2024 18:08:13 +0400 Subject: [PATCH] small changes to logging and added example config --- bot.py | 20 +++++++++++++++++--- config.yaml.example | 10 ++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) mode change 100644 => 100755 bot.py create mode 100644 config.yaml.example diff --git a/bot.py b/bot.py old mode 100644 new mode 100755 index 13aea25..6a1f198 --- a/bot.py +++ b/bot.py @@ -159,8 +159,14 @@ class ArchiveWalker: async def fetch_dialogs(self): async for dialog in self.client.iter_dialogs(): + self._log.info(dialog.stringify()) + self._log.debug(dialog) e = dialog.entity + if isinstance(e, types.Channel): + print(f"Channel: id:{e.id} title:'{e.title}'") + elif isinstance(e, types.User): + print(f"User: id:{e.id} name:'{e.first_name} {e.last_name or ''}'") for src in self.archives: if e.id != src['id']: continue @@ -169,9 +175,8 @@ class ArchiveWalker: self._log.debug("dialog %s is not a channel", e.id) continue elif src['type'] == 'User' and not isinstance(e, types.User): - continue self._log.debug("dialog %s is not a user", e.id) - self._log.info(dialog.stringify()) + continue yield dialog, src async def walk(self): @@ -207,6 +212,15 @@ if __name__ == '__main__': app_id = cfg['apps'][0]['id'] app_hash = cfg['apps'][0]['hash'] log.debug("client id %s hash %s", app_id, app_hash) - client = TelegramClient('session0'+str(app_id), app_id, app_hash) + client = TelegramClient( + 'session0'+str(app_id), + app_id, + app_hash, + system_version="Windows 11", + device_model = "Gentoo", + app_version = "1.0.0", + lang_code = "en", + system_lang_code = "en-US" + ) with client: client.loop.run_until_complete(main()) diff --git a/config.yaml.example b/config.yaml.example new file mode 100644 index 0000000..6361f04 --- /dev/null +++ b/config.yaml.example @@ -0,0 +1,10 @@ +apps: + - id: 1234567890 + hash: 123456780abcdef123456780abcdef +sources: + - id: 123456789 + type: User + destdir: ./download + - id: 987654321 + type: Channel + destdir: /path/to/downloads