-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
42 lines (31 loc) · 1.27 KB
/
main.py
File metadata and controls
42 lines (31 loc) · 1.27 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from typing import Optional, Type, Union
from py2neo.integration import Table
from telethon.sync import TelegramClient
from core.tg_api_connector import ChannelParser
from db.dal import GraphManager
from models import FetchedChannel
async def entry(client: TelegramClient, channel: Union[str, int]) -> FetchedChannel:
parser = ChannelParser(client)
await parser.start()
await parser.join_channel(channel)
channel_instance = await parser.get_all_participants(channel)
return channel_instance
class DataManager:
@staticmethod
async def load_data(client: TelegramClient, channel: Union[str, int]) -> None:
fetched_channel = await entry(client, channel)
GraphManager.add_fetched_channel(fetched_channel)
@staticmethod
async def add_user(user: tuple, groups: list) -> None:
GraphManager.add_user(user, groups)
# @staticmethod
# async def add_user(user: tuple) -> None:
# GraphManager.add_user(user) # TODO return to previous params
@staticmethod
async def create_relationships() -> None:
GraphManager.create_relationships()
@staticmethod
async def get_data(
query: str, n: Optional[int] = None
) -> Union[Table, dict, Type["DataFrame"]]:
return GraphManager.fetch_data(query, n)