.
675 |
--------------------------------------------------------------------------------
/images/1.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/azolfagharj/DloadBox/00d85f2d8bc9eb13ce59ecf5aecf378d5023764c/images/1.JPG
--------------------------------------------------------------------------------
/images/10.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/azolfagharj/DloadBox/00d85f2d8bc9eb13ce59ecf5aecf378d5023764c/images/10.JPG
--------------------------------------------------------------------------------
/images/11.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/azolfagharj/DloadBox/00d85f2d8bc9eb13ce59ecf5aecf378d5023764c/images/11.JPG
--------------------------------------------------------------------------------
/images/2.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/azolfagharj/DloadBox/00d85f2d8bc9eb13ce59ecf5aecf378d5023764c/images/2.JPG
--------------------------------------------------------------------------------
/images/3.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/azolfagharj/DloadBox/00d85f2d8bc9eb13ce59ecf5aecf378d5023764c/images/3.JPG
--------------------------------------------------------------------------------
/images/4.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/azolfagharj/DloadBox/00d85f2d8bc9eb13ce59ecf5aecf378d5023764c/images/4.JPG
--------------------------------------------------------------------------------
/images/5.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/azolfagharj/DloadBox/00d85f2d8bc9eb13ce59ecf5aecf378d5023764c/images/5.JPG
--------------------------------------------------------------------------------
/images/6.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/azolfagharj/DloadBox/00d85f2d8bc9eb13ce59ecf5aecf378d5023764c/images/6.JPG
--------------------------------------------------------------------------------
/images/7.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/azolfagharj/DloadBox/00d85f2d8bc9eb13ce59ecf5aecf378d5023764c/images/7.JPG
--------------------------------------------------------------------------------
/images/8.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/azolfagharj/DloadBox/00d85f2d8bc9eb13ce59ecf5aecf378d5023764c/images/8.JPG
--------------------------------------------------------------------------------
/images/9.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/azolfagharj/DloadBox/00d85f2d8bc9eb13ce59ecf5aecf378d5023764c/images/9.JPG
--------------------------------------------------------------------------------
/log/dloadbox-aria2-rpc.log:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/azolfagharj/DloadBox/00d85f2d8bc9eb13ce59ecf5aecf378d5023764c/log/dloadbox-aria2-rpc.log
--------------------------------------------------------------------------------
/log/dloadbox-caddy.log:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/azolfagharj/DloadBox/00d85f2d8bc9eb13ce59ecf5aecf378d5023764c/log/dloadbox-caddy.log
--------------------------------------------------------------------------------
/services/dloadbox-ariarpc.service:
--------------------------------------------------------------------------------
1 | [Unit]
2 | Description=DloadBox Aria RPC
3 | After=network-online.target
4 | Wants=network-online.target
5 |
6 | [Service]
7 | Type=simple
8 | User=root
9 | Group=root
10 | ExecStartPre=/usr/bin/env touch /var/tmp/aria2c.session
11 | ExecStartPre=/bin/sleep 10
12 | ExecStart=/opt/dloadbox/bin/dloadbox-aria2c --console-log-level=warn --enable-rpc --rpc-listen-all --conf-path=/opt/dloadbox/config/dloadbox-aria2.conf
13 | TimeoutStopSec=20
14 | Restart=on-failure
15 |
16 | [Install]
17 | WantedBy=multi-user.target
18 |
--------------------------------------------------------------------------------
/services/dloadbox-caddy.service:
--------------------------------------------------------------------------------
1 | [Unit]
2 | Description=Caddy
3 | Documentation=https://caddyserver.com/docs/
4 | After=network.target network-online.target
5 | Requires=network-online.target
6 |
7 | [Service]
8 | ExecStart=/opt/dloadbox/bin/dloadbox-caddy run --config /opt/dloadbox/config/dloadbox-caddy.conf --adapter caddyfile
9 | Restart=always
10 | User=root
11 | Group=root
12 | LimitNOFILE=1048576
13 |
14 | [Install]
15 | WantedBy=multi-user.target
16 |
--------------------------------------------------------------------------------
/services/dloadbox-filebrowser.service:
--------------------------------------------------------------------------------
1 | [Unit]
2 | Description=DloadBox Filebrowser
3 | After=network.target
4 |
5 | [Service]
6 | ExecStart=/usr/bin/dloadbox-filebrowser -c /opt/dloadbox/config/dloadbox-filebrowser.json
7 |
8 | [Install]
9 | WantedBy=multi-user.target
--------------------------------------------------------------------------------
/services/dloadbox-telegrambot.service:
--------------------------------------------------------------------------------
1 | [Unit]
2 | Description=DloadBox Telegram Bot
3 | After=network.target
4 |
5 | [Service]
6 | ExecStart=/opt/dloadbox/bin/dloadbox-telegrambot
7 |
8 | [Install]
9 | WantedBy=multi-user.target
--------------------------------------------------------------------------------
/services/dloadbox.service:
--------------------------------------------------------------------------------
1 | [Unit]
2 | Description=Main service for dloadbox components
3 | Requires=dloadbox-ariarpc.service dloadbox-caddy.service dloadbox-filebrowser.service dloadbox-telegrambot.service
4 | BindsTo=dloadbox-ariarpc.service dloadbox-caddy.service dloadbox-filebrowser.service dloadbox-telegrambot.service
5 | Before=dloadbox-ariarpc.service dloadbox-caddy.service dloadbox-filebrowser.service dloadbox-telegrambot.service
6 |
7 | [Service]
8 | Type=notify
9 | RemainAfterExit=true
10 | ExecStartPre=/opt/dloadbox/bin/dloadbox-configurator.sh
11 | ExecStart=/bin/true
12 | ExecStop=/bin/true
13 |
14 | [Install]
15 | WantedBy=multi-user.target
16 |
--------------------------------------------------------------------------------
/source/dloadbox-telegrambot.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import logging
3 | import os
4 | from telegram import Update
5 | from telegram.ext import ApplicationBuilder, CommandHandler, MessageHandler, ContextTypes
6 | from telegram.ext import filters
7 |
8 | # Function to load configuration from a .conf file
9 | def load_config(file_path):
10 | config = {}
11 | if not os.path.exists(file_path):
12 | # Log error if config file is missing
13 | logger.error(f"Config file not found: {file_path}")
14 | raise FileNotFoundError(f"Config file not found: {file_path}")
15 |
16 | with open(file_path, "r") as file:
17 | for line in file:
18 | line = line.strip()
19 | if "=" in line and not line.startswith("#"): # Ignore comments
20 | key, value = line.split("=", 1)
21 | config[key.strip()] = value.strip()
22 | return config
23 |
24 | # Set up logging to log to the specified file path
25 | LOG_FILE_PATH = "/opt/dloadbox/log/dloadbox-telegrambot.log"
26 | logging.basicConfig(
27 | filename=LOG_FILE_PATH,
28 | level=logging.DEBUG,
29 | format="%(asctime)s - %(message)s",
30 | )
31 |
32 | logger = logging.getLogger(__name__)
33 |
34 | # Default config file path
35 | CONFIG_FILE_PATH = "/opt/dloadbox/config/dloadbox-telegrambot.conf"
36 |
37 | # Load configuration settings (with error handling if the config file is missing)
38 | try:
39 | config = load_config(CONFIG_FILE_PATH)
40 | # Assign configuration variables
41 | LIMIT_PERMISSION = config["LIMIT_PERMISSION"] == "true"
42 | ALLOWED_USERNAMES = config["ALLOWED_USERNAMES"].split(",")
43 | ARIA2_RPC_SECRET = config["ARIA2_RPC_SECRET"]
44 | ARIA2_RPC_URL = config["ARIA2_RPC_URL"]
45 | BOT_TOKEN = config["BOT_TOKEN"]
46 | LOG_FILE_PATH = config["LOG_FILE_PATH"]
47 | except FileNotFoundError as e:
48 | logger.error(str(e)) # Log the error
49 | exit(1) # Exit if config is missing
50 |
51 | # Function to check if the URL is valid
52 | def is_valid_url(url):
53 | try:
54 | response = requests.head(url, timeout=10)
55 | if response.status_code // 100 == 2:
56 | return True
57 | else:
58 | return False
59 | except requests.RequestException as e:
60 | # Log error if URL check fails
61 | logger.error(f"Error checking URL {url}: {str(e)} ❌")
62 | return False
63 |
64 | # Function to add a URI to Aria2 (downloads a file)
65 | async def add_uri_to_aria2(uri):
66 | payload = {
67 | "jsonrpc": "2.0",
68 | "method": "aria2.addUri",
69 | "id": "1",
70 | "params": [ARIA2_RPC_SECRET, [uri]],
71 | }
72 | response = requests.post(ARIA2_RPC_URL, json=payload)
73 | return response.json()
74 |
75 | # Handle /start command (welcomes the user)
76 | async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):
77 | await update.message.reply_text("🚀 Welcome! Send me a download link to start. 🚀")
78 |
79 | # Handle incoming messages (parse download link and add to Aria2)
80 | async def handle_message(update: Update, context: ContextTypes.DEFAULT_TYPE):
81 | # Get the download link from the message
82 | message_text = update.message.text
83 |
84 | # Check if the username is allowed to access the bot
85 | if LIMIT_PERMISSION:
86 | user_username = update.message.from_user.username
87 | if user_username not in ALLOWED_USERNAMES:
88 | # Send message if the user is not allowed
89 | await update.message.reply_text(f"❌ Your access to this bot is restricted (username: {user_username})\nYou can request to have your username added to the Dloadbox server.")
90 | logger.error(f"Unauthorized access attempt by {user_username} ❌")
91 | return
92 |
93 | if not message_text.startswith("http"):
94 | await update.message.reply_text("❌ Please send a valid URL. ❌")
95 | return
96 |
97 | # Check if the URL is valid
98 | if not is_valid_url(message_text):
99 | await update.message.reply_text("❌ The link is not valid or cannot be downloaded. ❌")
100 | logger.error(f"Invalid URL attempted: {message_text} ❌")
101 | return
102 |
103 | # Add the URI to Aria2 for download
104 | response = await add_uri_to_aria2(message_text)
105 | if "result" in response:
106 | gid = response["result"]
107 | # Sending download success message
108 | success_message = f"✅ Download added successfully. GID: {gid} ✅"
109 |
110 | # Send the success message without any link
111 | await update.message.reply_text(success_message)
112 |
113 | elif "error" in response:
114 | await update.message.reply_text(f"❌ Error: {response['error']['message']} ❌")
115 | logger.error(f"Error adding URL to Aria2: {response['error']['message']} ❌")
116 | else:
117 | await update.message.reply_text("❌ An unknown error occurred. ❌")
118 | logger.error("Unknown error occurred while adding URL to Aria2. ❌")
119 |
120 | # Main function to start the bot
121 | def main():
122 | # Build the application and set up token
123 | app = ApplicationBuilder().token(BOT_TOKEN).build()
124 |
125 | # Add command handlers for /start command
126 | app.add_handler(CommandHandler("start", start))
127 | app.add_handler(MessageHandler(filters.TEXT & ~filters.Regex(r"^/"), handle_message))
128 |
129 | # Run the bot continuously (polling)
130 | app.run_polling()
131 |
132 | if __name__ == "__main__":
133 | main()
134 |
--------------------------------------------------------------------------------
/www/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/azolfagharj/DloadBox/00d85f2d8bc9eb13ce59ecf5aecf378d5023764c/www/.gitkeep
--------------------------------------------------------------------------------
/www/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Redirecting...
7 |
25 |
26 |
27 | If you are not redirected, click here.
28 |
29 |
30 |
--------------------------------------------------------------------------------