-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathbot.py
More file actions
100 lines (85 loc) · 3.41 KB
/
bot.py
File metadata and controls
100 lines (85 loc) · 3.41 KB
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
94
95
96
97
98
99
100
import os
from pyrogram import Client
from info import API_ID, API_HASH, BOT_TOKEN, LOG_CHANNEL, PORT, ADMINS
from aiohttp import web
from route import web_server, ping_server, check_expired_premium, start_scheduler
import pytz
from datetime import date, datetime
from utils import temp
class Bot(Client):
def __init__(self):
super().__init__(
name="avbotz",
api_id=API_ID,
api_hash=API_HASH,
bot_token=BOT_TOKEN,
workers=200,
plugins={"root": "plugins"},
sleep_threshold=15,
max_concurrent_transmissions=5,
)
async def start(self):
await super().start()
me = await self.get_me()
temp.ME = me.id
temp.U_NAME = me.username
temp.B_NAME = me.first_name
temp.B_LINK = me.mention
self.username = '@' + me.username
# ----------------- PLUGINS PRINTING LOGIC -----------------
print("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
print("🛠 LOADING PLUGINS...")
plugin_count = 0
for root, dirs, files in os.walk("plugins"):
for file in files:
if file.endswith(".py") and not file.startswith("__"):
print(f"✅ Successfully Loaded: {file}")
plugin_count += 1
print(f"🎉 Total {plugin_count} Plugins Loaded!")
print("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n")
# ----------------------------------------------------------
tz = pytz.timezone('Asia/Kolkata')
today = date.today()
now = datetime.now(tz)
time = now.strftime("%H:%M:%S %p")
# --- BACKGROUND TASKS ---
self.loop.create_task(check_expired_premium(self))
self.loop.create_task(start_scheduler(self))
# ✅ FIX: Removed 'self' from ping_server()
self.loop.create_task(ping_server())
app_instance = await web_server()
app_runner = web.AppRunner(app_instance)
await app_runner.setup()
site = web.TCPSite(app_runner, "0.0.0.0", int(PORT))
await site.start()
print(f"{me.first_name} 𝚂𝚃𝙰𝚁𝚃𝙴𝙳 ⚡️⚡️⚡️")
# ✅ ADMINS MESSAGE
if isinstance(ADMINS, list):
for admin in ADMINS:
try:
await self.send_message(admin, f"**__{me.first_name} Iꜱ Sᴛᴀʀᴛᴇᴅ.....✨️😅😅😅__**")
except:
pass
else:
try:
await self.send_message(ADMINS, f"**__{me.first_name} Iꜱ Sᴛᴀʀᴛᴇᴅ.....✨️😅😅😅__**")
except:
pass
# ✅ LOG CHANNEL MESSAGE
try:
await self.send_message(
LOG_CHANNEL,
text=(
f"<b>ʀᴇsᴛᴀʀᴛᴇᴅ 🤖\n\n"
f"📆 ᴅᴀᴛᴇ - <code>{today}</code>\n"
f"🕙 ᴛɪᴍᴇ - <code>{time}</code>\n"
f"🌍 ᴛɪᴍᴇ ᴢᴏɴᴇ - <code>Asia/Kolkata</code></b>"
)
)
except:
pass
async def stop(self, *args):
await super().stop()
print("Bot Stopped")
if __name__ == "__main__":
Bot().run()