-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse.py
More file actions
27 lines (22 loc) · 1.01 KB
/
Copy pathparse.py
File metadata and controls
27 lines (22 loc) · 1.01 KB
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
from config import app
from pyrogram.enums import ChatType
class Parse:
def __init__(self):
self.users_group = []
def get_all_user_chats(self):
for dialog in app.get_dialogs():
if dialog.chat.type == ChatType.GROUP:
self.users_group.append([dialog.chat.id, dialog.chat.title])
def del_useless_lines(self):
unique_lines = set(open('dist/data.txt', 'r', encoding='utf-8').readlines())
open('dist/data.txt', 'w', encoding='utf-8').writelines(set(unique_lines))
def get_all_chat_members(self, current_chat_id):
for member in app.get_chat_members(current_chat_id):
print(member.user.first_name)
if not(member.user.is_deleted or member.user.is_bot):
with open('dist/data.txt', mode='a', encoding='utf-8') as file:
file.write(str(member.user.id) + ' ' + member.user.username + '\n')
self.del_useless_lines()
@property
def user_group(self):
return self.users_group