Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added full support for non-premium users #156

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
48 changes: 48 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# PyCharm
.idea/
*.iml
*.ipr
*.iws

# VSCode
.vscode/
.vscode/settings.json
.vscode/tasks.json
.vscode/launch.json
.vscode/extensions.json
.vscode/*.code-workspace

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Pyrogram/Telethon specific
*.session
*.session-journal

# Local environment variables
.env.local
.env.dev
.env.test
.env.prod

# Log files
*.log

# test files
*.test

4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM python:3.9.2-slim-buster
FROM python:3.10-slim
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
RUN apt -qq update && apt -qq install -y git python3 python3-pip ffmpeg p7zip-full
COPY . .
RUN pip3 install --no-cache-dir -r requirements.txt
CMD ["bash","bash.sh"]
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ services:
SESSION: # Pyrogram string session
AUTH: # User ID of Bot owner
FORCESUB: # Username name of public channel without using '@'
# optionals
MAX_SPLIT_SIZE: # max file split size in Mb, if you don't have telegram premium - default is 2048 (for 2GB), if you have premium skip this option
BATCH_SIZE: # batch size - default is 100
7 changes: 5 additions & 2 deletions main/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from decouple import config
import logging, time, sys

from main.utils import logger

logging.basicConfig(format='[%(levelname) 5s/%(asctime)s] %(name)s: %(message)s',
level=logging.WARNING)

Expand All @@ -19,14 +21,15 @@
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("saverestricted", session_string=SESSION, api_hash=API_HASH, api_id=API_ID)

try:
userbot.start()
except BaseException:
print("Userbot Error ! Have you added SESSION while deploying??")
logger.error("Userbot Error ! Have you added SESSION while deploying??")
sys.exit(1)

Bot = Client(
Expand All @@ -39,5 +42,5 @@
try:
Bot.start()
except Exception as e:
print(e)
logger.error(e)
sys.exit(1)
6 changes: 4 additions & 2 deletions main/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import logging
from . import bot

from main.utils import logger

logging.basicConfig(format='[%(levelname) 5s/%(asctime)s] %(name)s: %(message)s',
level=logging.WARNING)

Expand All @@ -16,8 +18,8 @@
load_plugins(plugin_name.replace(".py", ""))

#Don't be a thief
print("Successfully deployed!")
print("By MaheshChauhan • DroneBots")
logger.info("Successfully deployed!")
logger.info("By MaheshChauhan • DroneBots")

if __name__ == "__main__":
bot.run_until_disconnected()
16 changes: 10 additions & 6 deletions main/plugins/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
Plugin for both public & private channels!
"""

import time, os, asyncio
import time, os, asyncio, decouple

from .. import bot as Drone
from .. import userbot, Bot, AUTH
from .. import FORCESUB as fs
from main.plugins.pyroplug import get_bulk_msg
from main.plugins.helpers import get_link, screenshot
from main.utils import logger


from telethon import events, Button, errors
from telethon.tl.types import DocumentAttributeVideo
Expand All @@ -26,6 +28,8 @@

batch = []

BATCH_SIZE = decouple.config("BATCH_SIZE", 100)

@Drone.on(events.NewMessage(incoming=True, from_users=AUTH, pattern='/cancel'))
async def cancel(event):
if not event.sender_id in batch:
Expand All @@ -37,7 +41,7 @@ async def cancel(event):
async def _batch(event):
if not event.is_private:
return
s, r = await force_sub(event.client, fs, event.sender_id, ft)
s, r = await force_sub(event.client, fs, event.sender_id, ft)
if s == True:
await event.reply(r)
return
Expand All @@ -54,19 +58,19 @@ async def _batch(event):
await conv.send_message("No link found.")
return conv.cancel()
except Exception as e:
print(e)
logger.error(e)
await conv.send_message("Cannot wait more longer for your response!")
return conv.cancel()
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)
logger.error(e)
await conv.send_message("Cannot wait more longer for your response!")
return conv.cancel()
try:
value = int(_range.text)
if value > 100:
if value > BATCH_SIZE:
await conv.send_message("You can only get upto 100 files in a single batch.")
return conv.cancel()
except ValueError:
Expand Down Expand Up @@ -96,7 +100,7 @@ async def run_batch(userbot, client, sender, link, _range):
await client.send_message(sender, "Batch completed.")
break
except Exception as e:
print(e)
logger.error(e)
await client.send_message(sender, "Batch completed.")
break
try:
Expand Down
3 changes: 2 additions & 1 deletion main/plugins/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from .. import FORCESUB as fs
from main.plugins.pyroplug import get_msg
from main.plugins.helpers import get_link, join
from main.utils import logger

from telethon import events
from pyrogram.errors import FloodWait
Expand Down Expand Up @@ -44,6 +45,6 @@ async def clone(event):
except FloodWait as fw:
return await Drone.send_message(event.sender_id, f'Try again after {fw.x} seconds due to floodwait from telegram.')
except Exception as e:
print(e)
logger.error(e)
await Drone.send_message(event.sender_id, f"An error occurred during cloning of `{link}`\n\n**Error:** {str(e)}")

4 changes: 3 additions & 1 deletion main/plugins/helpers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#Github.com/Vasusen-code

from main.utils import logger

from pyrogram.errors import FloodWait, InviteHashInvalid, InviteHashExpired, UserAlreadyParticipant
from telethon import errors, events

Expand All @@ -20,7 +22,7 @@ async def join(client, invite_link):
except FloodWait:
return "Too many requests, try again later."
except Exception as e:
print(e)
logger.error(e)
return "Could not join, try joining manually."

#Regex---------------------------------------------------------------------------------------------------------------
Expand Down
Loading