mirror of
https://github.com/Xtao-Labs/twitter2telegram.git
synced 2024-11-21 22:58:08 +00:00
33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
import pyrogram
|
|
import httpx
|
|
|
|
from defs.glover import api_id, api_hash
|
|
from scheduler import scheduler
|
|
from logging import getLogger, INFO, ERROR, StreamHandler, basicConfig, FileHandler, Formatter
|
|
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))
|
|
file_handler = FileHandler("log.txt", mode="w", encoding="utf-8")
|
|
file_handler.setFormatter(Formatter(logging_format))
|
|
root_logger = getLogger()
|
|
root_logger.setLevel(ERROR)
|
|
root_logger.addHandler(logging_handler)
|
|
root_logger.addHandler(file_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)
|