-
Notifications
You must be signed in to change notification settings - Fork 8
/
bot.py
64 lines (51 loc) · 1.77 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
import logging
import logging.config
# Get logging configurations
logging.config.fileConfig('logging.conf')
logging.getLogger().setLevel(logging.WARNING)
from pyrogram import Client, __version__
from pyrogram.raw.all import layer
from utils import Media
from info import SESSION, API_ID, API_HASH, BOT_TOKEN, LOG_CHANNEL
from aiohttp import web as webserver
from os import environ
from utils.dbstatus import db
from plugins.webcode import bot_run
from Script import script #for restarttxt
from datetime import date, datetime
import pytz
import pyromod.listen
PORT_CODE = environ.get("PORT", "8080")
class Bot(Client):
def __init__(self):
super().__init__(
name=SESSION,
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()
await Media.ensure_indexes()
me = await self.get_me()
self.username = '@' + me.username
print(f"{me.first_name} with for Pyrogram v{__version__} (Layer {layer}) started on {me.username}.")
print("Recoded By Goutham SER </>")
tz = pytz.timezone('Asia/Kolkata')
today = date.today()
now = datetime.now(tz)
time = now.strftime("%H:%M:%S %p")
await self.send_message(chat_id=LOG_CHANNEL, text=script.RESTART_TXT.format(today, time))
client = webserver.AppRunner(await bot_run())
await client.setup()
bind_address = "0.0.0.0"
await webserver.TCPSite(client, bind_address,
PORT_CODE).start()
async def stop(self, *args):
await super().stop()
print("Bot stopped. Bye.")
app = Bot()
app.run()