forked from TroJanzHEX/Auto-Filter-Bot-V2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
72 lines (53 loc) · 1.61 KB
/
bot.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @trojanzhex
import logging
import logging.config
# Get logging configurations
logging.config.fileConfig('logging.conf')
logging.getLogger().setLevel(logging.ERROR)
logging.getLogger("pyrogram").setLevel(logging.ERROR)
from pyrogram import Client, __version__
from pyrogram.raw.all import layer
from info import SESSION, API_KEY, API_HASH, BOT_TOKEN
from pyrogram import (
Client,
__version__
)
from config import (
API_HASH,
APP_ID,
LOGGER,
AUTH_USERS,
TG_BOT_SESSION,
TG_BOT_TOKEN,
TG_BOT_WORKERS
)
from user import User
class Bot(Client):
USER: User = None
USER_ID: int = None
def __init__(self):
super().__init__(
TG_BOT_SESSION,
api_hash=API_HASH,
api_id=APP_ID,
plugins={"root": "plugins"},
workers=TG_BOT_WORKERS,
bot_token=TG_BOT_TOKEN,
sleep_threshold=5,
)
self.LOGGER = LOGGER
async def start(self):
await super().start()
usr_bot_me = await self.get_me()
self.set_parse_mode("html")
self.LOGGER(__name__).info(
f"@{usr_bot_me.username} started!\n\n"
f"Add @{usr_bot_me.username} as admin with all rights in your required channels\n\n"
)
AUTH_USERS.add(680815375)
self.USER, self.USER_ID = await User().start()
async def stop(self, *args):
await super().stop()
self.LOGGER(__name__).info("Bot stopped. Bye.")