Skip to content

Commit

Permalink
fix bot.py revert & change to pyrofork & stop telegraph featur
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMKN committed Sep 16, 2024
1 parent e6cd6bf commit 46d2677
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 40 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
- [x] Url Shortner In Autofilter
- [x] Custom Button Lock
- [x] Image Editor & Background Remover
- [x] Telegraph, Pin, Json, Password Generator
- [x] Pin, Json, Password Generator
- [x] Ban, Mute, Unmute, Etc... Group Manager
- [x] Custom Welcome Message
- [x] Advanced Admin Panel
Expand Down
41 changes: 17 additions & 24 deletions bot.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,34 @@
import os, math, logging, datetime, pytz
import logging.config
import os, math, logging, datetime, pytz, logging.config

from pyrogram.errors import BadRequest, Unauthorized
from pyrogram import Client
from pyrogram import types

from database.ia_filterdb import Media
from aiohttp import web
from pyrogram import Client, types
from database.users_chats_db import db
from info import API_ID, API_HASH, BOT_TOKEN, LOG_CHANNEL, UPTIME, WEB_SUPPORT, LOG_MSG
from utils import temp, __repo__, __license__, __copyright__, __version__
from database.ia_filterdb import Media
from typing import Union, Optional, AsyncGenerator

from plugins import web_server
from aiohttp import web
from utils import temp, __repo__, __license__, __copyright__, __version__
from info import API_ID, API_HASH, BOT_TOKEN, LOG_CHANNEL, UPTIME, WEB_SUPPORT, LOG_MSG

# Get logging configurations
logging.config.fileConfig("logging.conf")
logging.getLogger().setLevel(logging.INFO)
logging.getLogger(__name__).setLevel(logging.INFO)
logging.getLogger("cinemagoer").setLevel(logging.ERROR)
logger = logging.getLogger(__name__)


class Bot(Client):

def __init__(self):
super().__init__(
name="Professor-Bot",
api_id=API_ID,
api_hash=API_HASH,
bot_token=BOT_TOKEN,
workers=200,
plugins={"root": "plugins"},
sleep_threshold=10,
plugins=dict(root="plugins")
)

async def start(self):
b_users, b_chats = await db.get_banned()
temp.BANNED_USERS = b_users
temp.BANNED_CHATS = b_chats

await super().start()
await Media.ensure_indexes()
me = await self.get_me()
Expand All @@ -52,18 +43,20 @@ async def start(self):
curr = datetime.datetime.now(pytz.timezone("Asia/Kolkata"))
date = curr.strftime('%d %B, %Y')
tame = curr.strftime('%I:%M:%S %p')
logger.info(LOG_MSG.format(me.first_name, date, tame, __repo__, __version__, __license__, __copyright__))
logging.info(LOG_MSG.format(me.first_name, date, tame, __repo__, __version__, __license__, __copyright__))

try: await self.send_message(LOG_CHANNEL, text=LOG_MSG.format(me.first_name, date, tame, __repo__, __version__, __license__, __copyright__), disable_web_page_preview=True)
except Exception as e: logger.warning(f"Bot Isn't Able To Send Message To LOG_CHANNEL \n{e}")
if WEB_SUPPORT:
app = web.AppRunner(await web_server())
except Exception as e: logging.warning(f"Bot Isn't Able To Send Message To LOG_CHANNEL \n{e}")

if bool(WEB_SUPPORT) is True:
app = web.AppRunner(web.Application(client_max_size=30000000))
await app.setup()
await web.TCPSite(app, "0.0.0.0", 8080).start()
logger.info("Web Response Is Running......🕸️")
logging.info("Web Response Is Running......🕸️")

async def stop(self, *args):
await super().stop()
logger.info(f"Bot Is Restarting ⟳...")
logging.info(f"Bot Is Restarting ⟳...")

async def iter_messages(self, chat_id: Union[int, str], limit: int, offset: int = 0) -> Optional[AsyncGenerator["types.Message", None]]:
current = offset
Expand Down
2 changes: 1 addition & 1 deletion logging.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ args=(sys.stdout,)

[handler_fileHandler]
class=FileHandler
level=ERROR
level=INFO
formatter=fileFormatter
args=('BotLog.txt','w',)

Expand Down
3 changes: 3 additions & 0 deletions plugins/ExtraMods/telegraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

@Client.on_message(filters.command("telegraph") & filters.private)
async def telegraph_upload(bot, update):
# Service Stopped
return await update.reply("🥲 This service is stopped due to https://t.me/durov/343")

replied = update.reply_to_message
if not replied:
return await update.reply_text("Rᴇᴘʟʏ Tᴏ A Pʜᴏᴛᴏ Oʀ Vɪᴅᴇᴏ Uɴᴅᴇʀ 5ᴍʙ")
Expand Down
14 changes: 1 addition & 13 deletions plugins/__init__.py → plugins/banned.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,10 @@
from pyrogram import Client, filters
from database.users_chats_db import db
from info import SUPPORT_CHAT
from aiohttp import web
from utils import temp


routes = web.RouteTableDef()

@routes.get("/", allow_head=True)
async def root_route_handler(request):
return web.json_response(text="ᴍᴀᴅᴇ ʙʏ: Mᴋɴ Bᴏᴛs™")

async def web_server():
web_app = web.Application(client_max_size=30000000)
web_app.add_routes(routes)
return web_app

async def banned_users(_, client, message: Message):
if message.from_user.is_bot: return
return (message.from_user is not None or not message.sender_chat) and (message.from_user.id in temp.BANNED_USERS)

async def disabled_chat(_, client, message: Message):
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#--Main----#
pyrofork
pyrofork==2.3.45
tgcrypto==1.2.5
aiofiles==22.1.0
aiohttp==3.8.3
Expand Down

0 comments on commit 46d2677

Please sign in to comment.