-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_user_ids.py
45 lines (38 loc) · 1.67 KB
/
get_user_ids.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
35
36
37
38
39
40
41
42
43
44
45
from telethon import TelegramClient, sync
import yaml
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--config', default='config.yaml')
args = parser.parse_args()
config = {}
with open(args.config) as f:
config = yaml.load(f, Loader=yaml.loader.SafeLoader)
proxy = None
if config['proxy']:
proxy_str = f"{config['proxy']['proxy_type']}://{config['proxy']['addr']}:{config['proxy']['port']}"
proxies = {"http": proxy_str,
"https": proxy_str}
proxy = config['proxy']
client = TelegramClient(config['session'], config['api_id'], config['api_hash'], proxy=proxy).start(bot_token=config['bot_token'])
if __name__ == '__main__':
allowed_youtube_user_ids = []
allowed_insta_user_ids = []
allowed_clip_user_ids = []
allowed_stt_user_ids = []
with client:
for user in config['allowed_youtube_usernames']:
entity = client.get_entity(user)
allowed_youtube_user_ids.append(entity.id)
for user in config['allowed_insta_usernames']:
entity = client.get_entity(user)
allowed_insta_user_ids.append(entity.id)
for user in config['allowed_clip_usernames']:
entity = client.get_entity(user)
allowed_clip_user_ids.append(entity.id)
for user in config['allowed_stt_usernames']:
entity = client.get_entity(user)
allowed_stt_user_ids.append(entity.id)
print(f"allowed_youtube_user_ids: {allowed_youtube_user_ids}")
print(f"allowed_insta_user_ids: {allowed_insta_user_ids}")
print(f"allowed_clip_user_ids: {allowed_clip_user_ids}")
print(f"allowed_stt_user_ids: {allowed_stt_user_ids}")