forked from Umaidahmad01/LazyPrincess
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
81 lines (73 loc) · 2.91 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
import logging
import logging.config
# Credit @LazyDeveloper.
# Please Don't remove credit.
# Born to make history @LazyDeveloper !
# Thank you LazyDeveloper for helping us in this Journey
# 🥰 Thank you for giving me credit @LazyDeveloperr 🥰
# for any error please contact me -> telegram@LazyDeveloperr or insta @LazyDeveloperr
# rip paid developers 🤣 - >> No need to buy paid source code while @LazyDeveloperr is here 😍😍
# Get logging configurations
logging.config.fileConfig('logging.conf')
logging.getLogger().setLevel(logging.INFO)
logging.getLogger("pyrogram").setLevel(logging.ERROR)
logging.getLogger("imdbpy").setLevel(logging.ERROR)
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
)
logging.getLogger("aiohttp").setLevel(logging.ERROR)
logging.getLogger("aiohttp.web").setLevel(logging.ERROR)
logging.getLogger("pyrogram").setLevel(logging.WARNING)
import os
from pyrogram import Client, __version__
from pyrogram.raw.all import layer
from database.ia_filterdb import Media
from database.users_chats_db import db
from info import *
from utils import temp
from typing import Union, Optional, AsyncGenerator
from pyrogram import types
from aiohttp import web
from plugins import web_server
import asyncio
from pyrogram import idle
from lazybot import LazyPrincessBot
from util.keepalive import ping_server
from lazybot.clients import initialize_clients
PORT = "8080"
LazyPrincessBot.start()
loop = asyncio.get_event_loop()
async def Lazy_start():
print('\n')
print(' Initalizing Telegram Bot ')
if not os.path.isdir(DOWNLOAD_LOCATION):
os.makedirs(DOWNLOAD_LOCATION)
bot_info = await LazyPrincessBot.get_me()
LazyPrincessBot.username = bot_info.username
await initialize_clients()
if ON_HEROKU:
asyncio.create_task(ping_server())
b_users, b_chats , lz_verified = await db.get_banned()
temp.BANNED_USERS = b_users
temp.BANNED_CHATS = b_chats
temp.LAZY_VERIFIED_CHATS = lz_verified
await Media.ensure_indexes()
me = await LazyPrincessBot.get_me()
temp.ME = me.id
temp.U_NAME = me.username
temp.B_NAME = me.first_name
LazyPrincessBot.username = '@' + me.username
app = web.AppRunner(await web_server())
await app.setup()
bind_address = "0.0.0.0" if ON_HEROKU else BIND_ADRESS
await web.TCPSite(app, bind_address, PORT).start()
logging.info(f"{me.first_name} with for Pyrogram v{__version__} (Layer {layer}) started on {me.username}.")
logging.info(LOG_STR)
await idle()
if __name__ == '__main__':
try:
loop.run_until_complete(Lazy_start())
logging.info('-----------------------🧐 Service running in Lazy Mode 😴-----------------------')
except KeyboardInterrupt:
logging.info('-----------------------😜 Service Stopped Sweetheart 😝-----------------------')