forked from ZEROTH-LORD/Sigma-Rename-Bot
-
Notifications
You must be signed in to change notification settings - Fork 5
/
bot.py
94 lines (81 loc) · 3.11 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import logging
import logging.config
import warnings
from pyrogram import Client, idle
from pyrogram import Client, __version__
from pyrogram.raw.all import layer
from config import Config
from aiohttp import web
from pytz import timezone
from datetime import datetime
import asyncio
from plugins.web_support import web_server
from plugins.file_rename import app
import pyromod
logging.config.fileConfig('logging.conf')
logging.getLogger().setLevel(logging.INFO)
logging.getLogger("pyrogram").setLevel(logging.ERROR)
class Bot(Client):
def __init__(self):
super().__init__(
name="SnowRenamer",
api_id=Config.API_ID,
api_hash=Config.API_HASH,
bot_token=Config.BOT_TOKEN,
workers=200,
plugins={"root": "plugins"},
sleep_threshold=15,
)
async def start(self):
await super().start()
me = await self.get_me()
self.mention = me.mention
self.username = me.username
self.force_channel = Config.FORCE_SUB
if Config.FORCE_SUB:
try:
link = await self.export_chat_invite_link(Config.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
app = web.AppRunner(await web_server())
await app.setup()
bind_address = "0.0.0.0"
await web.TCPSite(app, bind_address, Config.PORT).start()
logging.info(f"{me.first_name} ✅✅ BOT started successfully ✅✅")
for id in Config.ADMIN:
try:
await self.send_message(id, f"**__{me.first_name} Iꜱ Sᴛᴀʀᴛᴇᴅ.....✨️__**")
except:
pass
if Config.LOG_CHANNEL:
try:
curr = datetime.now(timezone("Asia/Kolkata"))
date = curr.strftime('%d %B, %Y')
time = curr.strftime('%I:%M:%S %p')
await self.send_message(Config.LOG_CHANNEL, f"**__{me.mention} Iꜱ Rᴇsᴛᴀʀᴛᴇᴅ !!**\n\n📅 Dᴀᴛᴇ : `{date}`\n⏰ Tɪᴍᴇ : `{time}`\n🌐 Tɪᴍᴇᴢᴏɴᴇ : `Asia/Kolkata`\n\n🉐 Vᴇʀsɪᴏɴ : `v{__version__} (Layer {layer})`</b>")
except:
print("Pʟᴇᴀꜱᴇ Mᴀᴋᴇ Tʜɪꜱ Iꜱ Aᴅᴍɪɴ Iɴ Yᴏᴜʀ Lᴏɢ Cʜᴀɴɴᴇʟ")
async def stop(self, *args):
await super().stop()
logging.info("Bot Stopped 🙄")
bot_instance = Bot()
def main():
async def start_services():
if Config.STRING_SESSION:
await asyncio.gather(
app.start(), # Start the Pyrogram Client
bot_instance.start() # Start the bot instance
)
else:
await asyncio.gather(
bot_instance.start()
)
loop = asyncio.get_event_loop()
loop.run_until_complete(start_services())
loop.run_forever()
if __name__ == "__main__":
warnings.filterwarnings("ignore", message="There is no current event loop")
main()