small changes to logging and added example config
This commit is contained in:
parent
1b16f5c215
commit
ed82071395
20
bot.py
Normal file → Executable file
20
bot.py
Normal file → Executable file
@ -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())
|
||||
|
10
config.yaml.example
Normal file
10
config.yaml.example
Normal file
@ -0,0 +1,10 @@
|
||||
apps:
|
||||
- id: 1234567890
|
||||
hash: 123456780abcdef123456780abcdef
|
||||
sources:
|
||||
- id: 123456789
|
||||
type: User
|
||||
destdir: ./download
|
||||
- id: 987654321
|
||||
type: Channel
|
||||
destdir: /path/to/downloads
|
Loading…
Reference in New Issue
Block a user