forked from gagharutyunyan1993/SaveRestrictedContentBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
init project, changed dependencies and added comment for windows os i…
…n Dockerfile, Updated Readme.md file
- Loading branch information
0 parents
commit ee0f0a0
Showing
18 changed files
with
1,525 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,10 @@ | ||
FROM python:3.9.2-slim-buster | ||
RUN mkdir /app && chmod 777 /app | ||
WORKDIR /app | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
RUN apt -qq update && apt -qq install -y git python3 python3-pip ffmpeg | ||
COPY . . | ||
RUN pip3 install --no-cache-dir -r requirements.txt | ||
# Or for Windows | ||
# RUN dos2unix bash.sh && pip3 install --no-cache-dir -r requirements.txt | ||
CMD ["bash","bash.sh"] |
Large diffs are not rendered by default.
Oops, something went wrong.
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 @@ | ||
Drone: python -m main |
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,113 @@ | ||
<h1 align="center"> | ||
<b>Save restricted content Bot</b> | ||
</h1> | ||
|
||
Contact: [Telegram](https://t.me/MaheshChauhan) | ||
|
||
A stable telegram bot to get restricted messages with custom thumbnail support , made by Mahesh Chauhan. | ||
|
||
- works for both public and private channels | ||
- Custom thumbnail support for Pvt medias | ||
- supports text and webpage media messages | ||
- Faster speed | ||
- Forcesubscribe available | ||
- `/batch` - (For owner only) Use this command to save upto 100 files from a pvt or public restricted channel at once. | ||
- Time delay is added to avoid FloodWait and keep user account safe. | ||
|
||
# Variables | ||
|
||
- `API_ID` | ||
- `API_HASH` | ||
- `SESSION` | ||
- `BOT_TOKEN` | ||
- `AUTH` - Owner user id | ||
- `FORCESUB` - Public channel username without '@'. Don't forget to add bot in channel as administrator. | ||
|
||
# Get API & PYROGRAM string session from: | ||
|
||
API: [API scrapper Bot](https://t.me/USETGSBOT) or [Telegram.org](https://my.telegram.org/auth) | ||
|
||
PYROGRAM SESSION: [SessionGen Bot](https://t.me/SessionStringGeneratorZBot) or [](https://replit.com/@dashezup/generate-pyrogram-session-string) | ||
|
||
BOT TOKEN: @Botfather on telegram | ||
|
||
# Deploy | ||
|
||
Deploy on `VPS` | ||
|
||
### Easy Method: | ||
|
||
##### For Linux | ||
- Intall docker-compose | ||
- Fill in the variables in docker-compose.yml file using your favorite text editor or nano | ||
- Start the container | ||
|
||
``` | ||
sudo apt install docker-compose -y | ||
nano docker-compose.yml | ||
sudo docker-compose up --build | ||
``` | ||
|
||
##### For Windows | ||
Replace | ||
|
||
```RUN pip3 install --no-cache-dir -r requirements.txt``` | ||
|
||
with | ||
|
||
```RUN dos2unix bash.sh && pip3 install --no-cache-dir -r requirements.txt``` | ||
in Dockerfile | ||
|
||
Then run this command in terminal | ||
``` | ||
docker-compose up --build -d | ||
``` | ||
|
||
### The hard Way: | ||
|
||
- Fill vars in your fork in [this](https://github.com/vasusen-code/SaveRestrictedContentBot/blob/master/main/__init__.py) file as shown in this [picture](https://t.me/MaheshChauhan/36) | ||
- enter all the below commands | ||
|
||
``` | ||
sudo apt update | ||
sudo apt install ffmpeg git python3-pip | ||
git clone your_repo_link | ||
cd saverestrictedcontentbot | ||
pip3 install -r requirements.txt | ||
python3 -m main | ||
``` | ||
|
||
- if you want bot to be running in background then enter `screen -S srcb` before `python3 -m main` | ||
- after `python3 -m main`, click ctrl+A, ctrl+D | ||
- if you want to stop bot, then enter `screen -r srcb` and click ctrl+A then press K and enter Y. | ||
|
||
Deploy your bot on `Render` | ||
|
||
Tutorial - [Click here](https://telegra.ph/SRCB-on-Render-05-17) | ||
|
||
Deploy your bot on `heroku` | ||
|
||
» Method - 1: | ||
- Star the repo, and fork it in desktop mode | ||
- Go to settings of your forked repo | ||
- Rename your repo by any other name | ||
- Click on [](https://heroku.com/deploy) | ||
|
||
» Method - 2: | ||
- Star the repo, and fork it in desktop mode | ||
- create app in heroku | ||
- go to settings of app›› config vars›› add all variables | ||
- add buildpacks | ||
- connect to github and deploy | ||
- turn on dynos | ||
|
||
Buildpacks for manual deploy: | ||
|
||
- `heroku/python` | ||
- `https://github.com/jonathanong/heroku-buildpack-ffmpeg-latest.git` | ||
|
||
Deploy your bot on `Okteto` [Useless] | ||
|
||
Tutorial for okteto - [click here](https://telegra.ph/Okteto-Deploy-04-01) | ||
|
||
[](https://cloud.okteto.com) |
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,47 @@ | ||
{ | ||
"name": "Save restricted content bot", | ||
"description": "Telegram bot to save restricted content.", | ||
"logo": "", | ||
"keywords": [ | ||
"telegram", | ||
"Save restricted content", | ||
"bot" | ||
], | ||
"repository": "https://github.com/vasusen-code/SaveRestrictedContentBot", | ||
"website": "", | ||
"success_url": "https://t.me/DroneBots", | ||
"env": { | ||
"API_HASH": { | ||
"description": "Your API HASH from my.telegram.org", | ||
"value": "" | ||
}, | ||
"API_ID": { | ||
"description": "Your API ID from my.telegram.org", | ||
"value": "" | ||
}, | ||
"BOT_TOKEN": { | ||
"description": "Bot token, get it from @BotFather.", | ||
"value": "" | ||
}, | ||
"SESSION": { | ||
"description": "Pyrogram string session.", | ||
"value": "" | ||
}, | ||
"AUTH": { | ||
"description": "User ID of Bot owner.", | ||
"value": "" | ||
}, | ||
"FORCESUB": { | ||
"description": "Username name of public channel without using '@'.", | ||
"value": "" | ||
} | ||
}, | ||
"buildpacks": [ | ||
{ | ||
"url": "heroku/python" | ||
}, | ||
{ | ||
"url": "https://github.com/jonathanong/heroku-buildpack-ffmpeg-latest.git" | ||
} | ||
] | ||
} |
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,2 @@ | ||
echo "starting Bot ~@DroneBots"; | ||
python3 -m main |
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 @@ | ||
version: "3.3" | ||
|
||
services: | ||
app: | ||
container_name: srcbot | ||
build: . | ||
command: bash bash.sh | ||
environment: | ||
API_ID: # Your API HASH from my.telegram.org | ||
API_HASH: # Your API ID from my.telegram.org | ||
BOT_TOKEN: # Bot token, get it from @BotFather | ||
SESSION: # Pyrogram string session | ||
AUTH: # User ID of Bot owner | ||
FORCESUB: # Username name of public channel without using '@' |
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,46 @@ | ||
#Github.com/Vasusen-code | ||
|
||
from pyrogram import Client | ||
|
||
from telethon.sessions import StringSession | ||
from telethon.sync import TelegramClient | ||
|
||
from decouple import config | ||
import logging, time, sys | ||
|
||
logging.basicConfig(format='[%(levelname) 5s/%(asctime)s] %(name)s: %(message)s', | ||
level=logging.WARNING) | ||
|
||
# variables | ||
API_ID = config("API_ID", default=None, cast=int) | ||
API_HASH = config("API_HASH", default=None) | ||
BOT_TOKEN = config("BOT_TOKEN", default=None) | ||
SESSION = config("SESSION", default=None) | ||
FORCESUB = config("FORCESUB", default=None) | ||
AUTH = config("AUTH", default=None, cast=int) | ||
|
||
bot = TelegramClient('bot', API_ID, API_HASH).start(bot_token=BOT_TOKEN) | ||
|
||
userbot = Client( | ||
session_name=SESSION, | ||
api_hash=API_HASH, | ||
api_id=API_ID) | ||
|
||
try: | ||
userbot.start() | ||
except BaseException: | ||
print("Userbot Error ! Have you added SESSION while deploying??") | ||
sys.exit(1) | ||
|
||
Bot = Client( | ||
"SaveRestricted", | ||
bot_token=BOT_TOKEN, | ||
api_id=int(API_ID), | ||
api_hash=API_HASH | ||
) | ||
|
||
try: | ||
Bot.start() | ||
except Exception as e: | ||
print(e) | ||
sys.exit(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,23 @@ | ||
import glob | ||
from pathlib import Path | ||
from main.utils import load_plugins | ||
import logging | ||
from . import bot | ||
|
||
logging.basicConfig(format='[%(levelname) 5s/%(asctime)s] %(name)s: %(message)s', | ||
level=logging.WARNING) | ||
|
||
path = "main/plugins/*.py" | ||
files = glob.glob(path) | ||
for name in files: | ||
with open(name) as a: | ||
patt = Path(a.name) | ||
plugin_name = patt.stem | ||
load_plugins(plugin_name.replace(".py", "")) | ||
|
||
#Don't be a thief | ||
print("Successfully deployed!") | ||
print("By MaheshChauhan • DroneBots") | ||
|
||
if __name__ == "__main__": | ||
bot.run_until_disconnected() |
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,126 @@ | ||
#Tg:MaheshChauhan/DroneBots | ||
#Github.com/Vasusen-code | ||
|
||
""" | ||
Plugin for both public & private channels! | ||
""" | ||
|
||
import time, os, asyncio | ||
|
||
from .. import bot as Drone | ||
from .. import userbot, Bot, AUTH | ||
from .. import FORCESUB as fs | ||
from main.plugins.pyroplug import check, get_bulk_msg | ||
from main.plugins.helpers import get_link, screenshot | ||
|
||
from telethon import events, Button, errors | ||
from telethon.tl.types import DocumentAttributeVideo | ||
|
||
from pyrogram import Client | ||
from pyrogram.errors import FloodWait | ||
|
||
from ethon.pyfunc import video_metadata | ||
from ethon.telefunc import force_sub | ||
|
||
ft = f"To use this bot you've to join @{fs}." | ||
|
||
batch = [] | ||
batch_ = [] | ||
|
||
async def get_pvt_content(event, chat, id): | ||
msg = await userbot.get_messages(chat, ids=id) | ||
await event.client.send_message(event.chat_id, msg) | ||
|
||
@Drone.on(events.NewMessage(incoming=True, from_users=AUTH, pattern='/batch')) | ||
async def _batch(event): | ||
if not event.is_private: | ||
return | ||
# wtf is the use of fsub here if the command is meant for the owner? | ||
# well am too lazy to clean | ||
s, r = await force_sub(event.client, fs, event.sender_id, ft) | ||
if s == True: | ||
await event.reply(r) | ||
return | ||
if f'{event.sender_id}' in batch: | ||
return await event.reply("You've already started one batch, wait for it to complete you dumbfuck owner!") | ||
async with Drone.conversation(event.chat_id) as conv: | ||
if s != True: | ||
await conv.send_message("Send me the message link you want to start saving from, as a reply to this message.", buttons=Button.force_reply()) | ||
try: | ||
link = await conv.get_reply() | ||
try: | ||
_link = get_link(link.text) | ||
except Exception: | ||
await conv.send_message("No link found.") | ||
except Exception as e: | ||
print(e) | ||
return await conv.send_message("Cannot wait more longer for your response!") | ||
await conv.send_message("Send me the number of files/range you want to save from the given message, as a reply to this message.", buttons=Button.force_reply()) | ||
try: | ||
_range = await conv.get_reply() | ||
except Exception as e: | ||
print(e) | ||
return await conv.send_message("Cannot wait more longer for your response!") | ||
try: | ||
value = int(_range.text) | ||
if value > 100: | ||
return await conv.send_message("You can only get upto 100 files in a single batch.") | ||
except ValueError: | ||
return await conv.send_message("Range must be an integer!") | ||
if s != True: | ||
await conv.send_message(r) | ||
return | ||
batch.append(f'{event.sender_id}') | ||
batch_.append(f'{event.sender_id}') | ||
cd = await conv.send_message("**Batch process ongoing.**\n\nProcess completed: ", | ||
buttons=[[Button.inline("CANCEL❌", data="cancel")]]) | ||
await run_batch(userbot, Bot, event.sender_id, value, cd, _link) | ||
conv.cancel() | ||
batch.clear() | ||
batch_.clear() | ||
|
||
@Drone.on(events.callbackquery.CallbackQuery(data="cancel")) | ||
async def cancel(event): | ||
batch_.clear() | ||
|
||
async def run_batch(userbot, client, sender, range_, countdown, link): | ||
for i in range(range_ + 1): | ||
timer = 60 | ||
if i < 25: | ||
timer = 5 | ||
if i < 50 and i > 25: | ||
timer = 10 | ||
if i < 100 and i > 50: | ||
timer = 15 | ||
if not 't.me/c/' in link: | ||
if i < 25: | ||
timer = 2 | ||
else: | ||
timer = 3 | ||
try: | ||
check_ = batch_[0] | ||
count_down = f"**Batch process ongoing.**\n\nProcess completed: {i+1}" | ||
out = await get_bulk_msg(userbot, client, sender, link, i) | ||
if not out == None: | ||
if out - 5 > 300: | ||
await client.send_message(sender, f'You have floodwaits of {out - 5} seconds, cancelling batch') | ||
batch_.clear() | ||
break | ||
else: | ||
fw_alert = await client.send_message(sender, f'Sleeping for {out} second(s) due to telegram flooodwait.') | ||
await asyncio.sleep(out) | ||
await fw_alert.delete() | ||
await get_bulk_msg(userbot, client, sender, link, i) | ||
protection = await client.send_message(sender, f"Sleeping for `{timer}` seconds to avoid Floodwaits and Protect account!") | ||
await countdown.edit(count_down) | ||
await asyncio.sleep(timer) | ||
await protection.delete() | ||
except IndexError: | ||
await client.send_message(sender, "Batch successfully completed!") | ||
await countdown.delete() | ||
break | ||
except Exception as e: | ||
print(e) | ||
if not countdown.text == count_down: | ||
await countdown.edit(count_down) | ||
|
Oops, something went wrong.