-
Notifications
You must be signed in to change notification settings - Fork 4
/
chats.py
35 lines (27 loc) · 1.17 KB
/
chats.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from pyrogram import Client
from pyrogram.enums import ChatType
from configs import CHAT_EXPORT
class Chat:
def __init__(self, app: Client):
self.app = app
async def get_ids(self, private = True) -> list:
dialog_ids = []
async for dialog in self.app.get_dialogs():
# TODO: private channel
# but this is for all channels
if CHAT_EXPORT['public_channels'] is True:
if dialog.chat.type == ChatType.CHANNEL:
dialog_ids.append(dialog.chat.id)
# TODO: but this is for all groups
# TODO: for SUPERGROUP?
# TODO: private groups
if CHAT_EXPORT['public_groups'] is True:
if dialog.chat.type == ChatType.GROUP:
dialog_ids.append(dialog.chat.id)
if CHAT_EXPORT['personal_chats'] is True:
if dialog.chat.type == ChatType.PRIVATE:
dialog_ids.append(dialog.chat.id)
if CHAT_EXPORT['bot_chats'] is True:
if dialog.chat.type == ChatType.BOT:
dialog_ids.append(dialog.chat.id)
return dialog_ids