qqqsfasdf's picture
Update bot.py
a49f716 verified
---
title: Digital Rename Bot
emoji: ๐Ÿค–
colorFrom: blue
colorTo: green
sdk: docker
app_file: app.py
pinned: false
---
# (c) @RknDeveloperr
# Rkn Developer
# Don't Remove Credit ๐Ÿ˜”
# Telegram Channel @RknDeveloper & @Rkn_Botz
# Developer @RknDeveloperr
# Special Thanks To @ReshamOwner
# Update Channel @Digital_Botz & @DigitalBotz_Support
"""
Apache License 2.0
Copyright (c) 2022 @Digital_Botz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Telegram Link : https://t.me/Digital_Botz
Repo Link : https://github.com/DigitalBotz/Digital-Rename-Bot
License Link : https://github.com/DigitalBotz/Digital-Rename-Bot/blob/main/LICENSE
"""
# extra imports
import aiohttp, asyncio, warnings, pytz, datetime
import logging
import logging.config
import glob, sys
import importlib.util
from pathlib import Path
# pyrogram imports
from pyrogram import Client, __version__, errors
from pyrogram.raw.all import layer
from pyrogram import idle
# bots imports
from config import Config
from plugins.web_support import web_server
from plugins.file_rename import app
# Get logging configurations
logging.basicConfig(
level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
handlers=[logging.FileHandler('BotLog.txt'),
logging.StreamHandler()]
)
#logger = logging.getLogger(__name__)
logging.getLogger("pyrofork").setLevel(logging.WARNING)
class DigitalRenameBot(Client):
def __init__(self):
super().__init__(
name="DigitalRenameBot",
api_id=Config.API_ID,
api_hash=Config.API_HASH,
bot_token=Config.BOT_TOKEN,
workers=200,
plugins={"root": "plugins"},
sleep_threshold=5,
max_concurrent_transmissions=50
)
async def start(self):
await super().start()
me = await self.get_me()
self.mention = me.mention
self.username = me.username
self.uptime = Config.BOT_UPTIME
self.premium = Config.PREMIUM_MODE
self.uploadlimit = Config.UPLOAD_LIMIT_MODE
Config.BOT = self
app = aiohttp.web.AppRunner(await web_server())
await app.setup()
bind_address = "0.0.0.0"
await aiohttp.web.TCPSite(app, bind_address, Config.PORT).start()
path = "plugins/*.py"
files = glob.glob(path)
for name in files:
with open(name) as a:
patt = Path(a.name)
plugin_name = patt.stem.replace(".py", "")
plugins_path = Path(f"plugins/{plugin_name}.py")
import_path = "plugins.{}".format(plugin_name)
spec = importlib.util.spec_from_file_location(import_path, plugins_path)
load = importlib.util.module_from_spec(spec)
spec.loader.exec_module(load)
sys.modules["plugins" + plugin_name] = load
print("Digital Botz Imported " + plugin_name)
print(f"{me.first_name} I๊œฑ Sแด›แด€ส€แด›แด‡แด….....โœจ๏ธ")
for id in Config.ADMIN:
if Config.STRING_SESSION:
try: await self.send_message(id, f"๐Ÿฎ๐—š๐—•+ า“ษชสŸแด‡ sแดœแด˜แด˜แดส€แด› สœแด€s ส™แด‡แด‡ษด แด€แด…แด…แด‡แด… แด›แด สแดแดœส€ ส™แดแด›.\n\nNote: ๐“๐ž๐ฅ๐ž๐ ๐ซ๐š๐ฆ ๐ฉ๐ซ๐ž๐ฆ๐ข๐ฎ๐ฆ ๐š๐œ๐œ๐จ๐ฎ๐ง๐ญ ๐ฌ๐ญ๐ซ๐ข๐ง๐  ๐ฌ๐ž๐ฌ๐ฌ๐ข๐จ๐ง ๐ซ๐ž๐ช๐ฎ๐ข๐ซ๐ž๐ ๐“๐ก๐ž๐ง ๐ฌ๐ฎ๐ฉ๐ฉ๐จ๐ซ๐ญ๐ฌ ๐Ÿ๐†๐+ ๐Ÿ๐ข๐ฅ๐ž๐ฌ.\n\n**__{me.first_name} I๊œฑ Sแด›แด€ส€แด›แด‡แด….....โœจ๏ธ__**")
except: pass
else:
try: await self.send_message(id, f"๐Ÿฎ๐—š๐—•- า“ษชสŸแด‡ sแดœแด˜แด˜แดส€แด› สœแด€s ส™แด‡แด‡ษด แด€แด…แด…แด‡แด… แด›แด สแดแดœส€ ส™แดแด›.\n\n**__{me.first_name} I๊œฑ Sแด›แด€ส€แด›แด‡แด….....โœจ๏ธ__**")
except: pass
if Config.LOG_CHANNEL:
try:
curr = datetime.datetime.now(pytz.timezone("Asia/Kolkata"))
date = curr.strftime('%d %B, %Y')
time = curr.strftime('%I:%M:%S %p')
await self.send_message(Config.LOG_CHANNEL, f"**__{me.mention} I๊œฑ Rแด‡sแด›แด€ส€แด›แด‡แด… !!**\n\n๐Ÿ“… Dแด€แด›แด‡ : `{date}`\nโฐ Tษชแดแด‡ : `{time}`\n๐ŸŒ Tษชแดแด‡แดขแดษดแด‡ : `Asia/Kolkata`\n\n๐Ÿ‰ Vแด‡ส€sษชแดษด : `v{__version__} (Layer {layer})`</b>")
except:
print("PสŸแด‡แด€๊œฑแด‡ Mแด€แด‹แด‡ Tสœษช๊œฑ I๊œฑ Aแด…แดษชษด Iษด Yแดแดœส€ Lแดษข Cสœแด€ษดษดแด‡สŸ")
async def stop(self, *args):
for id in Config.ADMIN:
try: await self.send_message(id, f"**Bot Stopped....**")
except: pass
print("Bot Stopped ๐Ÿ™„")
await super().stop()
digital_instance = DigitalRenameBot()
def main():
async def start_services():
if Config.STRING_SESSION:
await asyncio.gather(app.start(), digital_instance.start())
else:
await asyncio.gather(digital_instance.start())
# Idle mode start karo
await idle()
# Bot stop karo
if Config.STRING_SESSION:
await asyncio.gather(app.stop(), digital_instance.stop())
else:
await asyncio.gather(digital_instance.stop())
loop = asyncio.get_event_loop()
try:
loop.run_until_complete(start_services())
except KeyboardInterrupt:
print("\n๐Ÿ›‘ Bot stopped by user!")
finally:
loop.close()
if __name__ == "__main__":
warnings.filterwarnings("ignore", message="There is no current event loop")
try:
main()
except errors.FloodWait as ft:
print(f"โณ FloodWait: Sleeping for {ft.value} seconds")
asyncio.run(asyncio.sleep(ft.value))
print("Now Ready For Deploying!")
main()
# Rkn Developer
# Don't Remove Credit ๐Ÿ˜”
# Telegram Channel @RknDeveloper & @Rkn_Botz
# Developer @RknDeveloperr
# Update Channel @Digital_Botz & @DigitalBotz_Support