2021-12-08 09:10:31 +00:00
|
|
|
import logging
|
2022-11-24 07:08:30 +00:00
|
|
|
import pyrogram
|
2022-07-25 10:17:37 +00:00
|
|
|
import httpx
|
|
|
|
|
2022-10-06 07:40:03 +00:00
|
|
|
from models.sqlite import Sqlite
|
2022-10-02 15:14:06 +00:00
|
|
|
from defs.glover import api_id, api_hash, ipv6
|
|
|
|
from scheduler import scheduler
|
2021-12-08 09:10:31 +00:00
|
|
|
from logging import getLogger, INFO, ERROR, StreamHandler, basicConfig
|
|
|
|
from coloredlogs import ColoredFormatter
|
|
|
|
from cashews import cache
|
|
|
|
|
2022-11-24 07:08:30 +00:00
|
|
|
from models.temp_fix import temp_fix
|
|
|
|
|
2021-12-08 09:10:31 +00:00
|
|
|
# Config cache
|
|
|
|
cache.setup("mem://")
|
|
|
|
# Enable logging
|
|
|
|
logs = getLogger("iShotaBot")
|
|
|
|
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)
|
|
|
|
logger = logging.getLogger("iShotaBot")
|
2022-10-02 15:14:06 +00:00
|
|
|
|
|
|
|
if not scheduler.running:
|
|
|
|
scheduler.start()
|
2021-12-08 09:10:31 +00:00
|
|
|
# Init client
|
2022-07-25 09:35:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
class UserMe:
|
|
|
|
username = "iShotaBot"
|
|
|
|
id = 2144128213
|
|
|
|
|
|
|
|
|
|
|
|
user_me = UserMe()
|
2022-10-06 07:40:03 +00:00
|
|
|
sqlite = Sqlite()
|
2023-01-12 13:19:54 +00:00
|
|
|
bot = pyrogram.Client(
|
|
|
|
"bot", api_id=api_id, api_hash=api_hash, ipv6=ipv6, plugins=dict(root="modules")
|
|
|
|
)
|
2022-11-24 07:08:30 +00:00
|
|
|
# temp fix topics group
|
|
|
|
setattr(pyrogram.types.Message, "old_parse", getattr(pyrogram.types.Message, "_parse"))
|
|
|
|
setattr(pyrogram.types.Message, "_parse", temp_fix)
|
2022-07-25 10:17:37 +00:00
|
|
|
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"
|
|
|
|
}
|
2022-10-13 14:41:46 +00:00
|
|
|
request = httpx.AsyncClient(timeout=60.0, headers=headers)
|