forked from vognik/maltego-telegram
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.py
More file actions
46 lines (34 loc) 路 1.43 KB
/
Copy pathsettings.py
File metadata and controls
46 lines (34 loc) 路 1.43 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
43
44
45
46
from pyrogram import Client
import configparser
import asyncio
import os
import multiprocessing
class Config:
def __init__(self, filename="config.ini"):
self.config = configparser.ConfigParser()
if not os.path.exists(filename):
raise FileNotFoundError(f"Config file '{filename}' not found.")
self.config.read(filename)
def get(self, section, key, fallback=None):
try:
return self.config.get(section, key)
except (configparser.NoSectionError, configparser.NoOptionError):
return fallback
def get_bool(self, section, key, fallback=False):
try:
return self.config.getboolean(section, key)
except (configparser.NoSectionError, configparser.NoOptionError, ValueError):
return fallback
config = Config()
api_id = int(config.get("telegram", "api_id", fallback=0))
api_hash = config.get("telegram", "api_hash", fallback="")
bot_token = config.get("telegram", "bot_token", fallback="")
test_tgscan_token = config.get("tgscan", "test_token", fallback="")
prod_tgscan_token = config.get("tgscan", "prod_token", fallback="")
tgscan_debug_mode = config.get_bool("tgscan", "debug", fallback="")
limit = int(config.get("misc", "limit", fallback=0))
threads = int(config.get("misc", "threads", fallback=0))
if threads == 0:
threads = multiprocessing.cpu_count()
app = Client("my_account", api_id, api_hash)
loop = asyncio.get_event_loop()