-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
69 lines (59 loc) · 2.19 KB
/
bot.py
File metadata and controls
69 lines (59 loc) · 2.19 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
# +++ Modified By Yato [telegram username: @i_killed_my_clan & @ProYato] +++ # aNDI BANDI SANDI JISNE BHI CREDIT HATAYA USKI BANDI RAndi
import asyncio
import sys
from datetime import datetime
from pyrogram import Client
from pyrogram.enums import ParseMode
from config import API_HASH, APP_ID, LOGGER, TG_BOT_TOKEN, TG_BOT_WORKERS, PORT, OWNER_ID
from plugins import web_server
import pyrogram.utils
from aiohttp import web
pyrogram.utils.MIN_CHANNEL_ID = -1009147483647
name = """
Links Sharing Started
"""
class Bot(Client):
def __init__(self):
super().__init__(
name="Bot",
api_hash=API_HASH,
api_id=APP_ID,
plugins={"root": "plugins"},
workers=TG_BOT_WORKERS,
bot_token=TG_BOT_TOKEN,
)
self.LOGGER = LOGGER
async def start(self, *args, **kwargs):
await super().start()
usr_bot_me = await self.get_me()
self.uptime = datetime.now()
# Notify owner of bot restart
try:
await self.send_message(
chat_id=OWNER_ID,
text="<b><blockquote>🤖 Bot Restarted ♻️</blockquote></b>",
parse_mode=ParseMode.HTML
)
except Exception as e:
self.LOGGER(__name__).warning(f"Failed to notify owner ({OWNER_ID}) of bot start: {e}")
self.set_parse_mode(ParseMode.HTML)
self.LOGGER(__name__).info("Bot Running..!\n\nCreated by \nhttps://t.me/ProObito")
self.LOGGER(__name__).info(f"{name}")
self.username = usr_bot_me.username
# Web-response
try:
app = web.AppRunner(await web_server())
await app.setup()
bind_address = "0.0.0.0"
await web.TCPSite(app, bind_address, PORT).start()
self.LOGGER(__name__).info(f"Web server started on {bind_address}:{PORT}")
except Exception as e:
self.LOGGER(__name__).error(f"Failed to start web server: {e}")
async def stop(self, *args):
await super().stop()
self.LOGGER(__name__).info("Bot stopped.")
# Global cancel flag for broadcast
is_canceled = False
cancel_lock = asyncio.Lock()
if __name__ == "__main__":
Bot().run()