| --- |
| title: Digital Rename Bot |
| emoji: ๐ค |
| colorFrom: blue |
| colorTo: green |
| sdk: docker |
| app_file: app.py |
| pinned: false |
| --- |
| |
| |
| |
| |
| |
| |
| |
| """ |
| 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 |
| """ |
|
|
| |
| import aiohttp, asyncio, warnings, pytz, datetime |
| import logging |
| import logging.config |
| import glob, sys |
| import importlib.util |
| from pathlib import Path |
|
|
| |
| from pyrogram import Client, __version__, errors |
| from pyrogram.raw.all import layer |
| from pyrogram import idle |
|
|
| |
| from config import Config |
| from plugins.web_support import web_server |
| from plugins.file_rename import app |
|
|
| |
| logging.basicConfig( |
| level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", |
| handlers=[logging.FileHandler('BotLog.txt'), |
| logging.StreamHandler()] |
| ) |
| |
| 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()) |
| |
| |
| await idle() |
| |
| |
| 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() |
| |
|
|
| |
| |
| |
| |
| |
|
|