twitter2telegram/init.py

30 lines
920 B
Python
Raw Normal View History

2023-05-24 15:20:21 +00:00
import pyrogram
import httpx
from defs.glover import api_id, api_hash
from scheduler import scheduler
from logging import getLogger, INFO, ERROR, StreamHandler, basicConfig
from coloredlogs import ColoredFormatter
# Enable logging
logs = getLogger("T2G")
logging_format = "%(levelname)s [%(asctime)s] [%(name)s] %(message)s"
logging_handler = StreamHandler()
logging_handler.setFormatter(ColoredFormatter(logging_format))
root_logger = getLogger()
root_logger.setLevel(ERROR)
root_logger.addHandler(logging_handler)
basicConfig(level=INFO)
logs.setLevel(INFO)
if not scheduler.running:
scheduler.start()
bot = pyrogram.Client(
"bot", api_id=api_id, api_hash=api_hash, plugins=dict(root="plugins")
)
headers = {
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.72 Safari/537.36"
}
request = httpx.AsyncClient(timeout=60.0, headers=headers)