-
Notifications
You must be signed in to change notification settings - Fork 657
/
bot.py
executable file
·46 lines (40 loc) · 1.3 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
#----------------------------------- https://github.com/m4mallu/clonebot --------------------------------------------#
import sys
from user import User
from pyrogram import Client
from presets import Presets as Msg
from pyrogram.enums import ParseMode
from config import Config
from config import LOGGER
class Bot(Client):
USER: User = None
USER_ID: int = None
def __init__(self):
super().__init__(
name="bot_session",
api_hash=Config.API_HASH,
api_id=Config.APP_ID,
bot_token=Config.TG_BOT_TOKEN,
sleep_threshold=30,
workers=8,
plugins={
"root": "plugins"
}
)
self.LOGGER = LOGGER
async def start(self):
await super().start()
usr_bot_me = await self.get_me()
self.set_parse_mode(ParseMode.HTML)
self.LOGGER(__name__).info(
f"@{usr_bot_me.username} started! "
)
self.USER, self.USER_ID = await User().start()
try:
await self.USER.send_message(usr_bot_me.username, "%session_start%")
except Exception:
print(Msg.BOT_BLOCKED_MSG)
sys.exit()
async def stop(self, *args):
await super().stop()
self.LOGGER(__name__).info("Bot stopped. Bye.")