-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
52 lines (42 loc) · 1.4 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
import os
import logging
import logging.config
from pyrogram import Client
logging.config.fileConfig("logging.conf")
logging.getLogger().setLevel(logging.INFO)
logging.getLogger("pyrogram").setLevel(logging.ERROR)
BOT_TOKEN = os.environ.get("BOT_TOKEN", "")
API_ID = int(os.environ.get("API_ID", ""))
API_HASH = os.environ.get("API_HASH", "")
FORCE_SUB = os.environ.get("FORCE_SUB", None)
class Bot(Client):
def __init__(self):
super().__init__(
name="renamer",
api_id=API_ID,
api_hash=API_HASH,
bot_token=BOT_TOKEN,
workers=50,
plugins={"root": "plugins"},
sleep_threshold=5,
)
async def start(self):
await super().start()
me = await self.get_me()
self.mention = me.mention
self.username = me.username
self.force_channel = FORCE_SUB
if FORCE_SUB:
try:
link = await self.export_chat_invite_link(FORCE_SUB)
self.invitelink = link
except Exception as e:
logging.warning(e)
logging.warning("Make Sure Bot admin in force sub channel")
self.force_channel = None
logging.info(f"{me.first_name} 𝚂𝚃𝙰𝚁𝚃𝙴𝙳 ⚡️⚡️⚡️")
async def stop(self, *args):
await super().stop()
logging.info("Bot Stopped")
bot = Bot()
bot.run()