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

Alpha Upstream with kangershub #1

Merged
merged 33 commits into from
Nov 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
3b20b4b
Addition fixed from #91
yash-dk Sep 9, 2021
ea405ec
Add custom tracker support from URL TRACKER_SOURCE var.. #76
yash-dk Sep 9, 2021
619bcf5
Merge branch 'yash-dk:alpha' into alpha
AmirulAndalib Sep 9, 2021
3885496
for fixing #86 (#105)
SpEcHiDe Sep 10, 2021
f9af514
Merge branch 'yash-dk:alpha' into alpha
AmirulAndalib Sep 11, 2021
3179afe
Fixes the file cleanup for rclone and tg up
yash-dk Sep 14, 2021
706dabb
Alter the direct link gen format
yash-dk Sep 14, 2021
b472037
Change some stuff in Direct Link Generator
yash-dk Sep 20, 2021
794d471
Use Rar for splitting with USE_RAR_SPLIT var #85
yash-dk Sep 20, 2021
b91a66e
Merge branch 'alpha' of https://github.com/yash-dk/TorToolkit-Telegra…
yash-dk Sep 20, 2021
64834cf
Ignore abs path for rar
yash-dk Sep 20, 2021
3ec1483
Merge branch 'yash-dk:alpha' into alpha
AmirulAndalib Sep 21, 2021
53d2af4
Added sas zip support
yash-dk Sep 21, 2021
dfafcc2
add support for loading SA accounts from zip in settings
yash-dk Sep 21, 2021
98c0227
Fix the extract archive error
yash-dk Sep 21, 2021
b4854aa
Local extract and fix stuff in rclone upload
yash-dk Sep 21, 2021
d0971c5
Merge branch 'yash-dk:alpha' into alpha
AmirulAndalib Sep 22, 2021
b337cbb
..
nikhilesh-claysol Sep 26, 2021
54f3010
Update deploy.yml
nikhilesh-claysol Sep 26, 2021
6da24eb
Update deploy.yml
nikhilesh-claysol Sep 26, 2021
8405d87
Update deploy.yml
nikhilesh-claysol Sep 26, 2021
e1776d1
Merge branch 'alpha' into patch-1
nikhilesh-claysol Sep 26, 2021
0b23ae7
Merge pull request #31 from nikhilesh-claysol/patch-1
AmirulAndalib Sep 26, 2021
1589c8b
Adding to RAR fixed
yash-dk Oct 14, 2021
fb57400
Add the FORCE_SPLIT_UPLOAD and finalize USE_RAR_SPLIT
yash-dk Oct 14, 2021
f0441c8
Merge branch 'yash-dk:alpha' into alpha
AmirulAndalib Oct 14, 2021
012dd74
Added /cleardata
yash-dk Oct 23, 2021
b937b96
Remove the saftey margin in zipping
yash-dk Oct 23, 2021
e0360c6
Fix Handling some https cloudflare traffic error
yash-dk Oct 23, 2021
fe44631
Add both formats to /leech reply and no reply
yash-dk Oct 23, 2021
bbe2185
created del directories
yash-dk Oct 23, 2021
a85f99a
Merge branch 'alpha' of https://github.com/yash-dk/TorToolkit-Telegra…
AmirulAndalib Nov 3, 2021
868ce84
Kangershub
AmirulAndalib Nov 3, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

name: Manually Deploy to heroku

on: workflow_dispatch
Expand Down Expand Up @@ -25,4 +26,8 @@ jobs:
HD_OWNER_ID: ${{secrets.OWNER_ID}}
HD_MAX_DL_LINK_SIZE: ${{secrets.MAX_DL_LINK_SIZE}}
HD_MAX_MEGA_LIMIT: ${{secrets.MAX_MEGA_LIMIT}}
HD_MAX_TORRENT_SIZE: ${{secrets.MAX_TORRENT_SIZE}}
HD_MAX_TORRENT_SIZE: ${{secrets.MAX_TORRENT_SIZE}}
MEGA_UNAME: ${{secrets.MEGA_UNAME}}
MEGA_PASS: ${{secrets.MEGA_PASS}}
MEGA_API: ${{secrets.MEGA_API}}

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ Downloads/
userdata/
torlog.txt
sa_accounts/
sa_files*
2 changes: 1 addition & 1 deletion heroku-deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
🔷 **Here I Don't Provide any Deploy button to heroku, We Use Github Actions to Deploy container to Heroku**

🔷 **It is Reconmended to use any DC-4/DC-2 bot token and Heroku Deployment Region should be EU... **❓why I am saying that?** **In order to get High Upload Speed In telegram Leech Upload it is recomended** **you will get about 20MiB/s in TG upload which is equal to 200mbps and in normal DC-1/DC-5 bot you will get 5MiB/s which is equal to 50Mbps😆**
> **To get DC-4 token (i will make bot with your own username and name and transfer its ownership to you via botfather) CONTACT `@XCODERSHUB` FOR MORE...**
> **To get DC-4 token (i will make bot with your own username and name and transfer its ownership to you via botfather) CONTACT `@KangersHub` FOR MORE...**

🔷 **Make sure to Set the vars correctly in Github-Actions** ❌Dont edit/delete any ENV vars from heroku or Dont add any new vars from heroku either...
> **to edit/add/del ENV vars...Simply go to github actions and rerun the workflow**
Expand Down
6 changes: 3 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
So basically Tortoolkit is aimed to be the most versatile torrent leecher and Youtube-DL bot for telegram. This bot is highly customizable and to customize this bot you don't need to restart the bot every time.
The bot gets started with minimum variables and others can be set as and when needed using the /settings.

## Use [master](https://github.com/XcodersHub/TorToolkitX) branch for stable performance.
## Use [master](https://github.com/KangersHub/TorToolkitX) branch for stable performance.

## The Alpha branch is still in testing and is meant for testers. Soon a stable of this version will come out.


## For any help join this:- [TTKDISC](https://t.me/ttkdisc)
## or this:- [XcodersHubChat](https://t.me/xcodershubchat)
## or this:- [KangersHubChat](https://t.me/KangersHubchat)


## Whats new
Expand Down Expand Up @@ -106,7 +106,7 @@ Steps:-

1. Run the following commands. (Following commands can be used to setup the vps from scratch)

1. `git clone https://github.com/XcodersHub/TorToolkitX.git`
1. `git clone https://github.com/KangersHub/TorToolkitX.git`
2. `sudo apt update`
3. `sudo apt install -y python3.8`
4. `sudo apt install -y python3-venv`
Expand Down
1 change: 1 addition & 0 deletions tortoolkit/config/DefaultCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ class Commands:
SETTHUMB = "setthumb"
CLRTHUMB = "clearthumb"
SPEEDTEST = "speedtest"
CRLDATA = "cleardata"
8 changes: 8 additions & 0 deletions tortoolkit/config/ExecVarsSample.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class ExecVars:
QBIT_UNAME = "admin"
QBIT_PASS = "adminadmin"
QBIT_MAX_RETRIES = 2
ADD_CUSTOM_TRACKERS = True
TRACKER_SOURCE = "https://raw.githubusercontent.com/XIU2/TrackersListCollection/master/all.txt"

# Gdrive Config
GDRIVE_BASE_DIR = "/"
Expand Down Expand Up @@ -104,9 +106,15 @@ class ExecVars:
SA_FOLDER_ID = ""
SA_TD_ID = ""
SA_ACCOUNTS_FOLDER = ""
SA_ZIP_FILE = False

SA_ACCOUNT_NUMBER = 0

UPTOBOX_TOKEN = ""

USE_RAR_SPLIT = False
FORCE_SPLIT_UPLOAD = False

# Name of the RCLONE drive from the config
DEF_RCLONE_DRIVE = ""

Expand Down
48 changes: 40 additions & 8 deletions tortoolkit/core/HandleManager.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# -*- coding: utf-8 -*-
# (c) YashDK [yash-dk@github]

from datetime import datetime

from telethon.client import buttons
from ..uploaders.telegram_uploader import TelegramUploader
from telethon import TelegramClient,events
from telethon import __version__ as telever
Expand All @@ -10,6 +13,7 @@
from ..core.getVars import get_val
from ..utils.speedtest import get_speed
from ..utils import human_format
from ..utils.misc_utils import clear_stuff
from ..downloaders.qbittorrent_downloader import QbittorrentDownloader
from .settings import handle_settings,handle_setting_callback
from .user_settings import handle_user_settings, handle_user_setting_callback
Expand Down Expand Up @@ -153,6 +157,11 @@ def add_handlers(bot: TelegramClient):
chats=get_val("ALD_USR"))
)

bot.add_event_handler(
cleardata_handler,
events.NewMessage(pattern=command_process(get_command("CRLDATA")),
chats=get_val("ALD_USR"))
)

#signal.signal(signal.SIGINT, partial(term_handler,client=bot))
#signal.signal(signal.SIGTERM, partial(term_handler,client=bot))
Expand Down Expand Up @@ -208,15 +217,16 @@ def add_handlers(bot: TelegramClient):
handle_server_command,
events.CallbackQuery(pattern="fullserver")
)
bot.add_event_handler(
cleardata_handler,
events.CallbackQuery(pattern="cleardata")
)
#*********** Handlers Below ***********

async def handle_leech_command(e):
if not e.is_reply:
await e.reply("Reply to a link or magnet")
else:
sequencer = TaskSequence(e, await e.get_reply_message(), TaskSequence.LEECH)
res = await sequencer.execute()
torlog.info("Sequencer out"+ str(res))
sequencer = TaskSequence(e, await e.get_reply_message(), TaskSequence.LEECH)
res = await sequencer.execute()
torlog.info("Sequencer out"+ str(res))


# ###### Qbittorrent Related ######
Expand Down Expand Up @@ -457,7 +467,7 @@ async def set_password_zip(message):
await message.reply(f"Cannot update the password this is not your download.")

async def start_handler(event):
msg = "<b>Hello This is TorToolkitX an instance of</b> <a href='https://github.com/XcodersHub/TorToolkitX'>This Repo</a>. <b>Try the repo for yourself and dont forget to put a STAR and fork.</b>"
msg = "<b>Hello This is TorToolkitX an instance of</b> <a href='https://github.com/KangersHub/TorToolkitX'>This Repo</a>. <b>Try the repo for yourself and dont forget to put a STAR and fork.</b>"
await event.reply(msg, parse_mode="html")

def progress_bar(percentage):
Expand Down Expand Up @@ -628,7 +638,7 @@ async def about_me(message):
f"<b>Telethon Version</b>: {telever}\n"
f"<b>Pyrogram Version</b>: {pyrover}\n"
"<b>Created By</b>: @yaknight\n\n"
"<b>Modified</b>: @XcodersHub\n\n"
"<b>Modified</b>: @KangersHub\n\n"
"<u>Currents Configs:-</u>\n\n"
f"<b>Bot Uptime:-</b> {diff}\n"
"<b>Torrent Download Engine:-</b> <code>qBittorrent [4.3.0 fix active]</code> \n"
Expand Down Expand Up @@ -707,6 +717,28 @@ async def handle_user_settings_(message):

await handle_user_settings(message)

async def cleardata_handler(e):
if await is_admin(e.client,e.sender_id,e.chat_id):
if isinstance(e, events.CallbackQuery.Event):
data = e.data.decode("UTF-8").split(" ")
if data[1] == "yes":
await e.answer("Clearing data.")
await e.edit("Cleared Data @ {}".format(datetime.now().strftime("%d-%B-%Y, %H:%M:%S")))
await clear_stuff("userdata")
await clear_stuff("Downloads")
os.mkdir("Downloads")
os.mkdir("userdata")
else:
await e.answer("Aborting.")
await e.delete()
else:
buttons = [[KeyboardButtonCallback("Yes", data="cleardata yes"),KeyboardButtonCallback("No", data="cleardata no")]]
await e.reply("Are you sure you want to clear data?\n"
"This will delete all your data, including your downloaded files and will affect any ongoing transfers.\n", buttons=buttons)
else:
await e.answer("⚠️ WARN ⚠️ Dont Touch Admin Settings.",alert=True)


def term_handler(signum, frame, client):
# TODO needs rework
return
Expand Down
32 changes: 30 additions & 2 deletions tortoolkit/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
yes = "✅"
# Central object is not used its Acknowledged
tordb = TorToolkitDB()
header = '<b>**TorToolKitX** by <a href="https://github.com/XcodersHub/TorToolkitX">XcodersHub</a></b>\n<u>ADMIN SETTINGS MENU - Beta v1</u>'
header = '<b>**TorToolKitX** by <a href="https://github.com/KangersHub/TorToolkitX">KangersHub</a></b>\n<u>ADMIN SETTINGS MENU - Beta v1</u>'
async def handle_setting_callback(e):
db = tordb
session_id,_ = db.get_variable("SETTING_AUTH_CODE")
Expand Down Expand Up @@ -115,12 +115,19 @@ async def handle_setting_callback(e):
mmes = await e.get_message()
await handle_settings(mmes,True,session_id=session_id)
elif cmd[1] == "rcloneconfig":
await e.answer("Sned the rclone config file which you have generated.",alert=True)
await e.answer("Send the rclone config file which you have generated.",alert=True)
mmes = await e.get_message()
await mmes.edit(f"{mmes.raw_text}\n/ignore to go back",buttons=None)
val = await get_value(e,True)

await general_input_manager(e,mmes,"RCLONE_CONFIG","str",val,db,"rclonemenu")
elif cmd[1] == "sasfileszip":
await e.answer("Send the SAS account zip that you have generated.",alert=True)
mmes = await e.get_message()
await mmes.edit(f"{mmes.raw_text}\n/ignore to go back",buttons=None)
val = await get_value(e,True)

await general_input_manager(e,mmes,"SA_ZIP_FILE","str",val,db,"rclonemenu")
elif cmd[1] == "change_drive":
await e.answer(f"Changed default drive to {cmd[2]}.",alert=True)
db.set_variable("DEF_RCLONE_DRIVE",cmd[2])
Expand Down Expand Up @@ -330,6 +337,7 @@ async def handle_settings(e,edit=False,msg="",submenu=None,session_id=None):
rmess = await e.reply(header+"\nIts recommended to lock the group before setting vars.\n",parse_mode="html",buttons=menu,link_preview=False)
elif submenu == "rclonemenu":
rcval = await get_string_variable("RCLONE_CONFIG",menu,"rcloneconfig",session_id)
await get_string_variable("SA_ZIP_FILE",menu,"sasfileszip",session_id)
if get_val("ENABLE_SA_SUPPORT_FOR_GDRIVE"):
def_drive = get_val("DEF_RCLONE_DRIVE")
if def_drive == "sas_acc":
Expand Down Expand Up @@ -450,6 +458,18 @@ async def general_input_manager(e,mmes,var_name,datatype,value,db,sub_menu):
torlog.error(traceback.format_exc())
await handle_settings(mmes,True,f"<b><u>The conf file is invalid check logs.</b></u>",sub_menu)
return

elif var_name == "SA_ZIP_FILE":
try:
with open(value,"rb") as fi:
data = fi.read()
db.set_variable("SA_ZIP_FILE",0,True,data)
os.remove(value)
except:
torlog.exception("In SA Accounts loading.")
await handle_settings(mmes,True,f"<b><u>There was error loading your file. Send zip file.</b></u>",sub_menu)
return

else:
db.set_variable(var_name,value)
SessionVars.update_var(var_name,value)
Expand Down Expand Up @@ -591,6 +611,14 @@ async def get_string_variable(var_name,menu,callback_name,session_id):
val = "Custom file is loaded. (Click to load another)"
else:
val = "Click here to load RCLONE config."

if var_name == "SA_ZIP_FILE":
db = tordb
_, val1 = db.get_variable(var_name)
if val1 is not None:
val = "SAS Accounts loaded."
else:
val = "SAS Accounts not loaded."

msg = var_name + " " + str(val)
menu.append(
Expand Down
10 changes: 9 additions & 1 deletion tortoolkit/core/task_sequencer.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ def __init__(self, user_msg, entity_message, task_type) -> None:
self._dest_drive = None

async def execute(self):
if self._entity_message is None:
if len(self._user_msg.text.split(" ", 1)) == 2:
self._entity_message = self._user_msg
self._entity_message.text = self._user_msg.text.split(" ", 1)[1]
else:
await self._user_msg.reply("No Link Found.")
return

if self._task_type == self.LEECH:
choices = await self.get_leech_choices()

Expand Down Expand Up @@ -81,7 +89,7 @@ async def execute(self):
if extracted_path is not False:
dl_path = extracted_path

elif choices["zip"]:
elif choices["zip"] or get_val("FORCE_SPLIT_UPLOAD"):
arch_obj = Archiver(dl_path, prev_update_message, self._user_msg, not choices["rclone"])
archived_path = await arch_obj.execute()
if archived_path is not False:
Expand Down
31 changes: 29 additions & 2 deletions tortoolkit/core/varholdern.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,35 @@ def get_var(self, variable):
#Get the variable form the env [overlap]
#try:
envval = os.environ.get(variable)
INTS = ["EDIT_SLEEP_SECS", "MAX_TORRENT_SIZE", "MAX_YTPLAYLIST_SIZE", "TG_UP_LIMIT", "API_ID", "STATUS_DEL_TOUT", "TOR_MAX_TOUT", "OWNER_ID", "QBIT_PORT", "QBIT_MAX_RETRIES", "SERVPORT","MAX_DL_LINK_SIZE"]
BOOLS = ["FORCE_DOCUMENTS", "LEECH_ENABLED", "RCLONE_ENABLED", "USETTINGS_IN_PRIVATE", "MEGA_ENABLE", "ENABLE_BETA_YOUTUBE_DL", "ENABLE_WEB_FILES_VIEW", "CENTRAL_UPDATE", "ENABLE_SA_SUPPORT_FOR_GDRIVE"]
INTS = [
"EDIT_SLEEP_SECS",
"MAX_TORRENT_SIZE",
"MAX_YTPLAYLIST_SIZE",
"TG_UP_LIMIT",
"API_ID",
"STATUS_DEL_TOUT",
"TOR_MAX_TOUT",
"OWNER_ID",
"QBIT_PORT",
"QBIT_MAX_RETRIES",
"SERVPORT",
"MAX_DL_LINK_SIZE"
]

BOOLS = [
"FORCE_DOCUMENTS",
"LEECH_ENABLED",
"RCLONE_ENABLED",
"USETTINGS_IN_PRIVATE",
"MEGA_ENABLE",
"ENABLE_BETA_YOUTUBE_DL",
"ENABLE_WEB_FILES_VIEW",
"CENTRAL_UPDATE",
"ENABLE_SA_SUPPORT_FOR_GDRIVE",
"ADD_CUSTOM_TRACKERS",
"USE_RAR_SPLIT",
"FORCE_SPLIT_UPLOAD"
]

if variable == "ALD_USR":
if envval is not None:
Expand Down
3 changes: 2 additions & 1 deletion tortoolkit/downloaders/aria2_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ async def get_client(self):
aria2_daemon_start_cmd.append("--rpc-listen-all=true")
aria2_daemon_start_cmd.append(f"--rpc-listen-port=8100")
aria2_daemon_start_cmd.append("--rpc-max-request-size=1024M")

# TODO Rmove this when fixed...adding Cert check skip use to error with some cloudflare https traffic
aria2_daemon_start_cmd.append("--check-certificate=false")
aria2_daemon_start_cmd.append("--conf-path=/torapp/tortoolkit/aria2/aria2.conf")
#
torlog.debug(aria2_daemon_start_cmd)
Expand Down
Loading