Skip to content

Commit

Permalink
Formatted Code
Browse files Browse the repository at this point in the history
  • Loading branch information
GopalSaraf committed Jan 30, 2022
1 parent 26b1ca1 commit c7e10f8
Show file tree
Hide file tree
Showing 21 changed files with 716 additions and 394 deletions.
3 changes: 1 addition & 2 deletions tobrot/UserDynaConfig.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
class UserDynaConfig:

def __init__(self, user_id, upload_as_doc=False):
self.user_id = user_id
self.upload_as_doc = upload_as_doc
Expand All @@ -10,4 +9,4 @@ def __hash__(self):
def __eq__(self, other):
if not isinstance(other, type(self)):
return NotImplemented
return self.user_id == other.user_id
return self.user_id == other.user_id
19 changes: 9 additions & 10 deletions tobrot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
format="%(asctime)s - %(levelname)s - %(message)s [%(filename)s:%(lineno)d]",
datefmt="%d-%b-%y %H:%M:%S",
handlers=[
RotatingFileHandler(
"TorrentLeech.txt", maxBytes=50000000, backupCount=10
),
RotatingFileHandler("TorrentLeech.txt", maxBytes=50000000, backupCount=10),
logging.StreamHandler(),
],
)
Expand Down Expand Up @@ -54,8 +52,7 @@

# Get these values from my.telegram.org
# to store the channel ID who are authorized to use the bot
AUTH_CHANNEL = [int(x) for x in
os.environ.get("AUTH_CHANNEL", "").split()]
AUTH_CHANNEL = [int(x) for x in os.environ.get("AUTH_CHANNEL", "").split()]

# the download location, where the HTTP Server runs
DOWNLOAD_LOCATION = "./DOWNLOADS"
Expand All @@ -70,7 +67,7 @@
# default thumbnail to be used in the videos
DEF_THUMB_NAIL_VID_S = os.environ.get(
"DEF_THUMB_NAIL_VID_S",
"https://images.unsplash.com/photo-1562907550-096d3bf9b25c?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=735&q=80"
"https://images.unsplash.com/photo-1562907550-096d3bf9b25c?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=735&q=80",
)
# maximum message length in Telegram
MAX_MESSAGE_LENGTH = 4096
Expand Down Expand Up @@ -102,11 +99,13 @@
DESTINATION_FOLDER = os.environ.get("DESTINATION_FOLDER", "/")
INDEX_LINK = os.environ.get("INDEX_LINK", "")
TELEGRAM_LEECH_COMMAND = os.environ.get("TELEGRAM_LEECH_COMMAND", "tleech")
TELEGRAM_LEECH_UNZIP_COMMAND = os.environ.get("TELEGRAM_LEECH_UNZIP_COMMAND", "tleechunzip")
TELEGRAM_LEECH_UNZIP_COMMAND = os.environ.get(
"TELEGRAM_LEECH_UNZIP_COMMAND", "tleechunzip"
)
CANCEL_COMMAND_G = os.environ.get("CANCEL_COMMAND_G", "cancel")
GET_SIZE_G = os.environ.get("GET_SIZE_G", "getsize")
STATUS_COMMAND = os.environ.get("STATUS_COMMAND", "status")
STATS_COMMAND = os.environ.get("STATS_COMMAND", 'stats')
STATS_COMMAND = os.environ.get("STATS_COMMAND", "stats")
HELP_COMMAND = os.environ.get("HELP_COMMAND", "help")
SAVE_THUMBNAIL = os.environ.get("SAVE_THUMBNAIL", "savethumbnail")
CLEAR_THUMBNAIL = os.environ.get("CLEAR_THUMBNAIL", "clearthumbnail")
Expand All @@ -120,7 +119,7 @@
UPLOAD_COMMAND = os.environ.get("UPLOAD_COMMAND", "upload")
RENEWME_COMMAND = os.environ.get("RENEWME_COMMAND", "renewme")
RENAME_COMMAND = os.environ.get("RENAME_COMMAND", "rename")
LIST_COMMAND = os.environ.get("LIST_COMMAND", 'list')
LIST_COMMAND = os.environ.get("LIST_COMMAND", "list")
COMPLETE_LIST_COMMAND = os.environ.get("FULL_LIST_COMMAND", "completelist")
TOGGLE_VID = os.environ.get("TOGGLE_VID", "uploadvid")
TOGGLE_DOC = os.environ.get("TOGGLE_DOC", "uploaddoc")
Expand All @@ -134,7 +133,7 @@
gid_dict = defaultdict(lambda: [])

# Telegraph token things
sname = ''.join(random.SystemRandom().choices(string.ascii_letters, k=8))
sname = "".join(random.SystemRandom().choices(string.ascii_letters, k=8))
telegraph = Telegraph()
telegraph.create_account(short_name=sname)
telegraph_token = telegraph.get_access_token()
Expand Down
86 changes: 41 additions & 45 deletions tobrot/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os

from pyrogram import Client, filters
from pyrogram.handlers import CallbackQueryHandler, MessageHandler

Expand All @@ -9,33 +10,35 @@
CANCEL_COMMAND_G,
CLEAR_THUMBNAIL,
CLONE_COMMAND_G,
CLONE_TAR_COMMAND,
CLONE_ZIP_COMMAND,
COMPLETE_LIST_COMMAND,
DOWNLOAD_LOCATION,
GET_SIZE_G,
GLEECH_COMMAND,
GLEECH_UNZIP_COMMAND,
GLEECH_ZIP_COMMAND,
GPYTDL_COMMAND,
GYTDL_COMMAND,
HELP_COMMAND,
LEECH_COMMAND,
LEECH_UNZIP_COMMAND,
LEECH_ZIP_COMMAND,
LIST_COMMAND,
LOG_COMMAND,
PYTDL_COMMAND,
RENEWME_COMMAND,
RENAME_COMMAND,
RENEWME_COMMAND,
SAVE_THUMBNAIL,
STATUS_COMMAND,
STATS_COMMAND,
TELEGRAM_LEECH_UNZIP_COMMAND,
STATUS_COMMAND,
TELEGRAM_LEECH_COMMAND,
TELEGRAM_LEECH_UNZIP_COMMAND,
TG_BOT_TOKEN,
TOGGLE_DOC,
TOGGLE_VID,
UPLOAD_COMMAND,
YTDL_COMMAND,
GYTDL_COMMAND,
GPYTDL_COMMAND,
TOGGLE_VID,
TOGGLE_DOC,
HELP_COMMAND,
LIST_COMMAND,
COMPLETE_LIST_COMMAND, CLONE_ZIP_COMMAND, CLONE_TAR_COMMAND,
)
from tobrot.helper_funcs.download import down_load_media_f
from tobrot.helper_funcs.help_func import help_message_f
Expand All @@ -46,8 +49,8 @@
from tobrot.plugins.custom_thumbnail import clear_thumb_nail, save_thumb_nail
from tobrot.plugins.incoming_message_fn import (
g_clonee,
gclone_zip,
g_yt_playlist,
gclone_zip,
incoming_message_f,
incoming_purge_message_f,
incoming_youtube_dl_f,
Expand All @@ -59,14 +62,14 @@
cancel_message_f,
eval_message_f,
exec_message_f,
full_list_fn,
list_fn,
stats_message_fn,
status_message_f,
upload_document_f,
upload_log_file,
upload_as_doc,
upload_as_video,
list_fn,
full_list_fn,
stats_message_fn
upload_document_f,
upload_log_file,
)

if __name__ == "__main__":
Expand Down Expand Up @@ -94,14 +97,14 @@
GLEECH_ZIP_COMMAND,
]
)
& filters.chat(chats=AUTH_CHANNEL),
& filters.chat(chats=AUTH_CHANNEL),
)
app.add_handler(incoming_message_handler)
#
incoming_telegram_download_handler = MessageHandler(
down_load_media_f,
filters=filters.command([TELEGRAM_LEECH_COMMAND, TELEGRAM_LEECH_UNZIP_COMMAND])
& filters.chat(chats=AUTH_CHANNEL),
& filters.chat(chats=AUTH_CHANNEL),
)
app.add_handler(incoming_telegram_download_handler)
#
Expand All @@ -113,15 +116,14 @@
#
incoming_clone_handler = MessageHandler(
g_clonee,
filters=filters.command([CLONE_COMMAND_G])
& filters.chat(chats=AUTH_CHANNEL),
filters=filters.command([CLONE_COMMAND_G]) & filters.chat(chats=AUTH_CHANNEL),
)
app.add_handler(incoming_clone_handler)
#
incoming_clonezip_handler = MessageHandler(
gclone_zip,
filters=filters.command([CLONE_ZIP_COMMAND, CLONE_TAR_COMMAND])
& filters.chat(chats=AUTH_CHANNEL),
& filters.chat(chats=AUTH_CHANNEL),
)
app.add_handler(incoming_clonezip_handler)
#
Expand All @@ -133,43 +135,40 @@
#
incoming_g_clear_handler = MessageHandler(
g_clearme,
filters=filters.command([RENEWME_COMMAND])
& filters.chat(chats=AUTH_CHANNEL),
filters=filters.command([RENEWME_COMMAND]) & filters.chat(chats=AUTH_CHANNEL),
)
app.add_handler(incoming_g_clear_handler)
#
incoming_youtube_dl_handler = MessageHandler(
incoming_youtube_dl_f,
filters=filters.command([YTDL_COMMAND, GYTDL_COMMAND])
& filters.chat(chats=AUTH_CHANNEL),
& filters.chat(chats=AUTH_CHANNEL),
)
app.add_handler(incoming_youtube_dl_handler)
#
incoming_youtube_playlist_dl_handler = MessageHandler(
g_yt_playlist,
filters=filters.command([PYTDL_COMMAND, GPYTDL_COMMAND])
& filters.chat(chats=AUTH_CHANNEL),
& filters.chat(chats=AUTH_CHANNEL),
)
app.add_handler(incoming_youtube_playlist_dl_handler)
#
status_message_handler = MessageHandler(
status_message_f,
filters=filters.command([STATUS_COMMAND])
& filters.chat(chats=AUTH_CHANNEL),
filters=filters.command([STATUS_COMMAND]) & filters.chat(chats=AUTH_CHANNEL),
)
app.add_handler(status_message_handler)
#
stats_message_handler = MessageHandler(
stats_message_fn,
filters=filters.command([STATS_COMMAND, 'stats'])
& filters.chat(chats=AUTH_CHANNEL),
filters=filters.command([STATS_COMMAND, "stats"])
& filters.chat(chats=AUTH_CHANNEL),
)
app.add_handler(stats_message_handler)
#
cancel_message_handler = MessageHandler(
cancel_message_f,
filters=filters.command([CANCEL_COMMAND_G])
& filters.chat(chats=AUTH_CHANNEL),
filters=filters.command([CANCEL_COMMAND_G]) & filters.chat(chats=AUTH_CHANNEL),
)
app.add_handler(cancel_message_handler)
#
Expand All @@ -193,8 +192,7 @@
#
upload_document_handler = MessageHandler(
upload_document_f,
filters=filters.command([UPLOAD_COMMAND])
& filters.chat(chats=AUTH_CHANNEL),
filters=filters.command([UPLOAD_COMMAND]) & filters.chat(chats=AUTH_CHANNEL),
)
app.add_handler(upload_document_handler)
#
Expand All @@ -204,10 +202,7 @@
)
app.add_handler(upload_log_handler)
#
start_cmd_handler = MessageHandler(
start_fn,
filters=filters.command(['start'])
)
start_cmd_handler = MessageHandler(start_fn, filters=filters.command(["start"]))
app.add_handler(start_cmd_handler)
#
call_back_button_handler = CallbackQueryHandler(button)
Expand All @@ -216,14 +211,14 @@
save_thumb_nail_handler = MessageHandler(
save_thumb_nail,
filters=filters.command([f"{SAVE_THUMBNAIL}"])
& filters.chat(chats=AUTH_CHANNEL),
& filters.chat(chats=AUTH_CHANNEL),
)
app.add_handler(save_thumb_nail_handler)
#
clear_thumb_nail_handler = MessageHandler(
clear_thumb_nail,
filters=filters.command([f"{CLEAR_THUMBNAIL}"])
& filters.chat(chats=AUTH_CHANNEL),
& filters.chat(chats=AUTH_CHANNEL),
)
app.add_handler(clear_thumb_nail_handler)
#
Expand All @@ -246,22 +241,23 @@
#
help_message_handler = MessageHandler(
help_message_f,
filters=filters.command([HELP_COMMAND])
& filters.chat(chats=AUTH_CHANNEL),
filters=filters.command([HELP_COMMAND]) & filters.chat(chats=AUTH_CHANNEL),
)
app.add_handler(help_message_handler)
#
list_message_handler = MessageHandler(
list_fn,
filters=filters.command([LIST_COMMAND, 'list', 'search'])
& filters.chat(chats=AUTH_CHANNEL),
filters=filters.command([LIST_COMMAND, "list", "search"])
& filters.chat(chats=AUTH_CHANNEL),
)
app.add_handler(list_message_handler)
#
full_list_message_handler = MessageHandler(
full_list_fn,
filters=filters.command([COMPLETE_LIST_COMMAND, 'fulllist', 'fullsearch', 'completelist'])
& filters.chat(chats=AUTH_CHANNEL),
filters=filters.command(
[COMPLETE_LIST_COMMAND, "fulllist", "fullsearch", "completelist"]
)
& filters.chat(chats=AUTH_CHANNEL),
)
app.add_handler(full_list_message_handler)
#
Expand Down
Loading

0 comments on commit c7e10f8

Please sign in to comment.