-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
16 changed files
with
601 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
worker: python3 bot.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# RENAME-PRO | ||
|
||
# NOTE [READ THIS] | ||
|
||
AFTER FORK DON'T FORGET TO MAKE YOUR OWN DEPLOY LINK OTHERWISE BOT WILL NOT WORK | ||
|
||
## DEMO-BOT 👇👇 | ||
|
||
[RENAME PRO ROBOT](https://t.me/Hx_RenameBot) | ||
|
||
|
||
|
||
|
||
A File Rename Bot with Custom Thumbnail Support | ||
|
||
|
||
|
||
<p align="center"> | ||
<a href="https://www.python.org"> | ||
<img src="http://ForTheBadge.com/images/badges/made-with-python.svg"> | ||
|
||
</a> | ||
</p> | ||
</p> | ||
|
||
|
||
|
||
|
||
|
||
|
||
## Configs | ||
|
||
* TG_BOT_TOKEN - Get bot token from @BotFather | ||
|
||
* API_ID - From my.telegram.org | ||
|
||
* API_HASH - From my.telegram.org | ||
|
||
* ADMIN - Your User ID | ||
|
||
* DATABASE_NAME - Your database name from mongoDB. Default will be 'my' | ||
|
||
* DATABASE_URI - Mongo Database URL from https://cloud.mongodb.com/ | ||
|
||
# HOW TO FILL - | ||
|
||
EXAMPLE - mongodb+srv://[UserName]:[password]@cluster0.dciqs.mongodb.net/myFirstDatabase?retryWrites=true&w=majority | ||
|
||
FILL THIS WAY 👇 | ||
|
||
mongodb+srv://MRUSERNAME:MRPASSWORD@cluster0.dciqs.mongodb.net/myFirstDatabase?retryWrites=true&w=majority | ||
|
||
|
||
|
||
|
||
|
||
### Deploy to Heroku | ||
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?) | ||
|
||
|
||
|
||
## Bot Commands | ||
> Check Bot Status | ||
* `/start` Check bot Status | ||
> View Thumbnail | ||
* `/viewthumb` View Thumbnail | ||
> Delete Thumbnail | ||
* `/delthumb` Delete Thumbnail | ||
> Broadcast Message | ||
* `/broadcast` 'your message' | ||
|
||
|
||
|
||
## Follow Me🔥: | ||
|
||
|
||
<p align="left"> | ||
<a href="https://t.me/HxSupport"><img src="https://img.shields.io/badge/Join%20Our%20Group-HxSupport-darkblue?style=for-the-badge&logo=telegram"></a> | ||
</p> | ||
<p align="left"> | ||
<a href="https://github.com/oVo-HxBots"><img src="https://img.shields.io/badge/GitHub-Follow%20on%20GitHub-inactive.svg?style=for-the-badge&logo=github"></a> | ||
</p> | ||
<p align="left"> | ||
<a href="https://instagram.com/HxBots"><img src="https://img.shields.io/badge/Instagram-HxBots-magenta?style=for-the-badge&logo=instagram"></a> | ||
</p> | ||
|
||
## CONTACT ME ON ⬇️ | ||
|
||
<p align="left"> | ||
<a href="https://t.me/Kirodewal"><img src="https://img.shields.io/badge/Kirodewal-darkblue?style=for-the-badge&logo=telegram"></a> | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"name": "Renamer Bot", | ||
"description": "Telegram File Renamer Bot ", | ||
"keywords": [ | ||
"Renamer Bot", | ||
"Mongo DB", | ||
"Telegram Bot" | ||
], | ||
"repository": "https://github.com/oVo-HxBots/RENAME-PRO", | ||
"success_url": "https://t.me/HxBots", | ||
"env": { | ||
"APP_ID": { | ||
"description": "Your APP ID From my.telegram.org ", | ||
"value": "" | ||
}, | ||
"API_HASH": { | ||
"description": "Your API Hash From my.telegram.org ", | ||
"value": "" | ||
}, | ||
"TOKEN": { | ||
"description": "Your Bot Token From @BotFather", | ||
"value": "" | ||
}, | ||
"ADMIN": { | ||
"description":"754495556" | ||
}, | ||
"DB_URL": { | ||
"description": "Your Mongo DB URL Obtained From mongodb.com", | ||
"value": "" | ||
}, | ||
"DB_NAME":{ | ||
"description":"Your Mongo DB Database Name ", | ||
"value": "my", | ||
"required": false | ||
} | ||
}, | ||
"buildpacks": [ | ||
{ | ||
"url": "heroku/python" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from pyrogram import Client | ||
import os | ||
|
||
from config import Config | ||
|
||
|
||
if __name__ == "__main__" : | ||
plugins = dict( | ||
root="plugins" | ||
) | ||
app = Client( | ||
"renamer", | ||
bot_token=Config.TOKEN, | ||
api_id=Config.APP_ID, | ||
api_hash=Config.API_HASH, | ||
plugins=plugins | ||
) | ||
app.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import os | ||
|
||
class Config(object): | ||
# get a token from @BotFather | ||
TOKEN = os.environ.get("TOKEN", "") | ||
# The Telegram API things | ||
APP_ID = int(os.environ.get("APP_ID", "")) | ||
API_HASH = os.environ.get("API_HASH", "") | ||
#Array to store users who are authorized to use the bot | ||
ADMIN = os.environ.get("ADMIN", "754495556") | ||
#Your Mongo DB Database Name | ||
DB_NAME = os.environ.get("DB_NAME", "my") | ||
#Your Mongo DB URL Obtained From mongodb.com | ||
DB_URL = os.environ.get("DB_URL", "") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import pymongo | ||
import os | ||
|
||
DB_NAME = os.environ.get("DB_NAME","") | ||
DB_URL = os.environ.get("DB_URL","") | ||
mongo = pymongo.MongoClient(DB_URL) | ||
db = mongo[DB_NAME] | ||
dbcol = db["user"] | ||
|
||
def insert(chat_id): | ||
user_id = int(chat_id) | ||
user_det = {"_id":user_id,"file_id":None} | ||
try: | ||
dbcol.insert_one(user_det) | ||
except: | ||
pass | ||
|
||
def addthumb(chat_id, file_id): | ||
dbcol.update_one({"_id":chat_id},{"$set":{"file_id":file_id}}) | ||
|
||
def delthumb(chat_id): | ||
dbcol.update_one({"_id":chat_id},{"$set":{"file_id":None}}) | ||
|
||
def find(chat_id): | ||
id = {"_id":chat_id} | ||
x = dbcol.find(id) | ||
for i in x: | ||
lgcd = i["file_id"] | ||
return lgcd | ||
|
||
def getid(): | ||
values = [] | ||
for key in dbcol.find(): | ||
id = key["_id"] | ||
values.append((id)) | ||
return values |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import math | ||
import time | ||
|
||
async def progress_for_pyrogram( | ||
current, | ||
total, | ||
ud_type, | ||
message, | ||
start | ||
): | ||
|
||
now = time.time() | ||
diff = now - start | ||
if round(diff % 10.00) == 0 or current == total: | ||
# if round(current / total * 100, 0) % 5 == 0: | ||
percentage = current * 100 / total | ||
speed = current / diff | ||
elapsed_time = round(diff) * 1000 | ||
time_to_completion = round((total - current) / speed) * 1000 | ||
estimated_total_time = elapsed_time + time_to_completion | ||
|
||
elapsed_time = TimeFormatter(milliseconds=elapsed_time) | ||
estimated_total_time = TimeFormatter(milliseconds=estimated_total_time) | ||
|
||
progress = "[{0}{1}] \n**Progress**: {2}%\n".format( | ||
''.join(["■" for i in range(math.floor(percentage / 5))]), | ||
''.join(["□" for i in range(20 - math.floor(percentage / 5))]), | ||
round(percentage, 2)) | ||
|
||
tmp = progress + "{0} of {1}\n**Speed**: {2}/s\n**ETA**: {3}\n".format( | ||
humanbytes(current), | ||
humanbytes(total), | ||
humanbytes(speed), | ||
# elapsed_time if elapsed_time != '' else "0 s", | ||
estimated_total_time if estimated_total_time != '' else "0 s" | ||
) | ||
try: | ||
await message.edit( | ||
text="{}\n {}".format( | ||
ud_type, | ||
tmp | ||
) | ||
) | ||
except: | ||
pass | ||
|
||
|
||
def humanbytes(size): | ||
# https://stackoverflow.com/a/49361727/4723940 | ||
# 2**10 = 1024 | ||
if not size: | ||
return "" | ||
power = 2**10 | ||
n = 0 | ||
Dic_powerN = {0: ' ', 1: 'Ki', 2: 'Mi', 3: 'Gi', 4: 'Ti'} | ||
while size > power: | ||
size /= power | ||
n += 1 | ||
return str(round(size, 2)) + " " + Dic_powerN[n] + 'B' | ||
|
||
|
||
def TimeFormatter(milliseconds: int) -> str: | ||
seconds, milliseconds = divmod(int(milliseconds), 1000) | ||
minutes, seconds = divmod(seconds, 60) | ||
hours, minutes = divmod(minutes, 60) | ||
days, hours = divmod(hours, 24) | ||
tmp = ((str(days) + "d, ") if days else "") + \ | ||
((str(hours) + "h, ") if hours else "") + \ | ||
((str(minutes) + "m, ") if minutes else "") + \ | ||
((str(seconds) + "s, ") if seconds else "") + \ | ||
((str(milliseconds) + "ms, ") if milliseconds else "") | ||
return tmp[:-2] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import os | ||
from pyrogram import Client ,filters | ||
from helper.database import getid | ||
ADMIN = int(os.environ.get("ADMIN")) | ||
|
||
@Client.on_message(filters.private & filters.user(ADMIN) & filters.command(["broadcast"])) | ||
async def broadcast(bot, message): | ||
if (message.reply_to_message): | ||
ms = await message.reply_text("Geting All ids from database ...........") | ||
ids = getid() | ||
tot = len(ids) | ||
await ms.edit(f"Starting Broadcast .... \n Sending Message To {tot} Users") | ||
for id in ids: | ||
try: | ||
await message.reply_to_message.copy(id) | ||
except: | ||
pass |
Oops, something went wrong.