-
Notifications
You must be signed in to change notification settings - Fork 20
/
bot.py
54 lines (43 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
47
48
49
50
51
52
53
import logging
import os
from mwk.config import Config
from logging.handlers import RotatingFileHandler
from pyrogram import Client
if os.path.exists("Log.txt"):
with open("Log.txt", "r+") as f_d:
f_d.truncate(0)
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
datefmt="%d-%b-%y %H:%M:%S",
handlers=[
RotatingFileHandler(
"Log.txt",
maxBytes=1000000,
backupCount=10
),
logging.StreamHandler()
]
)
log = logging.getLogger(__name__)
import pyrogram
logging.getLogger("pyrogram").setLevel(logging.WARNING)
class Bot(Client):
def __init__(self):
super().__init__(
session_name="RENAMEBOT",
api_id=Config.APP_ID,
api_hash=Config.API_HASH,
bot_token=Config.TG_BOT_TOKEN,
plugins={"root": "mwk/rename"},
sleep_threshold=5,
)
async def start(self):
await super().start()
if not os.path.isdir(Config.DOWNLOAD_LOCATION):
os.makedirs(Config.DOWNLOAD_LOCATION)
log.info("<<[Bot Started]>>")
async def stop(self, *args):
await super().stop()
log.info("<<[Bot Stopped]>>")
app = Bot()
app.run()