teldrive/README.md

250 lines
12 KiB
Markdown
Raw Normal View History

2023-08-29 00:35:21 +08:00
# Telegram Drive
2024-02-09 03:22:59 +08:00
Telegram Drive is a powerful utility that enables you to organise your telegram files and much more.
2023-08-19 21:53:09 +08:00
2024-02-16 17:14:03 +08:00
[![Discord](https://img.shields.io/discord/1142377485737148479?label=discord&logo=discord&style=flat-square&logoColor=white)](https://discord.gg/8QAeCvTK7G)
**Click on icon to join Discord Server**
2023-08-29 00:35:21 +08:00
## Features
- **UI:** Based on Material You to create nice looking UI themes.
2023-12-08 05:46:06 +08:00
- **Secure:** Your data is secured using robust encryption.
2023-08-29 00:35:21 +08:00
- **Flexible Deployment:** Use Docker Compose or deploy without Docker.
2024-02-09 03:22:59 +08:00
## Advantages Over Alternative Solutions
- **Exceptional Speed:** Teldrive stands out among similar tools, thanks to its implementation in Go, a language known for its efficiency. Its performance surpasses alternatives written in Python and other languages, with the exception of Rust.
- **Enhanced Management Capabilities:** Teldrive not only excels in speed but also offers an intuitive user interface for efficient file interaction which other tool lacks. Its compatibility with Rclone further enhances file management.
> [!IMPORTANT]
> Teldrive functions as a wrapper over your Telegram account, simplifying file access. However, users must adhere to the limitations imposed by the Telegram API. Teldrive is not responsible for any consequences arising from non-compliance with these API limits.You will be banned instantly if you misuse telegram API.
2023-08-16 05:53:02 +08:00
2024-04-19 15:28:07 +08:00
![demo](./public/demo1.png)
2024-04-19 14:51:51 +08:00
<details>
2024-04-19 15:28:07 +08:00
<summary><b>More Images</b></summary>
2024-04-19 14:51:51 +08:00
![demo2](./public/demo2.png)
![demo3](./public/demo3.png)
2024-04-19 15:28:07 +08:00
![demo5](./public/demo6.png)
![demo8](./public/demo8.png)
![demo7](./public/demo7.png)
2024-04-19 14:51:51 +08:00
![demo4](./public/demo4.png)
</details>
<br>
2023-08-16 05:53:02 +08:00
2023-08-16 21:15:53 +08:00
[UI Repo ](https://github.com/divyam234/teldrive-ui)
2024-05-09 02:04:27 +08:00
[UI Library ](https://github.com/divyam234/tw-material)
2024-05-09 02:04:27 +08:00
[File Browser Component ](https://github.com/divyam234/tw-file-browser)
2024-05-01 23:53:51 +08:00
### One Line Installer
[![install count](https://img.shields.io/endpoint?url=https://instl.sh/api/v1/badge/shields.io/stats/divyam234/teldrive&style=for-the-badge)](https://instl.sh/divyam234/teldrive)
#### Linux
```bash
curl -sSL instl.sh/divyam234/teldrive/linux | bash
```
#### Windows
```powershell
iwr instl.sh/divyam234/teldrive/windows | iex
```
#### macOS
```bash
curl -sSL instl.sh/divyam234/teldrive/macos | bash
```
2023-08-16 05:53:02 +08:00
### Deploy using docker-compose
2024-05-01 23:53:51 +08:00
```yml
2024-02-09 03:22:59 +08:00
version: "3.8"
services:
server:
2024-02-09 23:14:16 +08:00
image: ghcr.io/divyam234/teldrive
2024-02-09 03:22:59 +08:00
restart: always
container_name: teldrive
volumes:
- ./session.db:/session.db:rw
- ./config.toml:/config.toml
2024-02-09 03:22:59 +08:00
ports:
- 8080:8080
2024-02-09 03:22:59 +08:00
```
***People Who want to use local Postgres instance***
2024-05-01 23:53:51 +08:00
```yml
2024-02-09 03:22:59 +08:00
version: "3.8"
services:
server:
2024-02-09 23:14:16 +08:00
image: ghcr.io/divyam234/teldrive
2024-02-09 03:22:59 +08:00
restart: always
container_name: teldrive
volumes:
- ./session.db:/session.db:rw
- ./config.toml:/config.toml
2024-02-09 03:22:59 +08:00
ports:
- 8080:8080
depends_on:
db:
condition: service_healthy
db:
image: postgres:15
container_name: teldrive_db
restart: always
environment:
- POSTGRES_USER=teldrive
- POSTGRES_PASSWORD=secret
volumes:
- ./postgres_data:/var/lib/postgresql/data
2024-02-09 03:22:59 +08:00
healthcheck:
test: ["CMD", "pg_isready", "-U", "teldrive"]
interval: 10s
start_period: 30s
2023-08-16 05:53:02 +08:00
```
2023-08-17 20:14:33 +08:00
**Follow Below Steps**
- Create the `config.toml` file with your values and start your container. See how to fill file below.
```toml
[db]
data-source = "postgres://<db username>:<db password>@<db host>/<db name>"
[jwt]
secret = "abcd"
[tg]
app-id =
app-hash = "fwfwfwf"
```
***Only these values are mandatory however you can change or
tweak your config see more in advanced configurations below***.
2023-08-16 05:53:02 +08:00
```sh
touch session.db
2023-08-16 05:53:02 +08:00
docker compose up -d
```
2023-09-08 23:01:20 +08:00
- **Go to http://localhost:8080**
2024-02-07 00:08:12 +08:00
2023-08-29 00:35:21 +08:00
### Use without docker
2023-08-17 20:14:33 +08:00
**Follow Below Steps**
2024-05-01 23:53:51 +08:00
- Run one line installer.
- Add same config file as above.
2023-09-08 19:13:36 +08:00
- Now, run the Teldrive executable binary directly.
- You can also set up without config file.
2024-02-13 17:20:12 +08:00
2023-08-16 05:53:02 +08:00
```sh
teldrive run --tg-app-id="" --tg-app-hash="" --jwt-secret="" --db-data-source=""
2024-02-09 03:22:59 +08:00
```
2024-02-07 00:08:12 +08:00
**Generate JWT**
2023-08-19 16:04:29 +08:00
```bash
2023-09-20 03:20:44 +08:00
$ openssl rand -hex 32
2023-08-19 16:04:29 +08:00
```
2024-02-07 00:08:12 +08:00
You can generate secret from [here](https://generate-secret.vercel.app/32).
## Important
- You can set up a local Postgres instance, but it's not recommended due to backup and data transfer hassles. The recommended approach is to use a free cloud-based Postgres DB like [Neon DB](https://neon.tech/).
- Default Channel can be selected through UI. Make sure to set it from account settings on first login.
- Multi Bots Mode is recommended to avoid flood errors and enable maximum download speed, especially if you are using downloaders like IDM and aria2c, which use multiple connections for downloads.
- To enable multi bots, generate new bot tokens from BotFather and add them through UI on first login.
- Uploads from UI will be slower due to limitations of the browser. Use modified [Rclone](https://github.com/divyam234/rclone) version for teldrive.
- Teldrive supports image thumbnail resizing on the fly. To enable this, you have to deploy a separate image resize service from [here](https://github.com/divyam234/image-resize).
- After deploying this service, add its URL in Teldrive UI settings in the **Resize Host** field.
2024-02-13 21:31:50 +08:00
- Files are deleted at regular interval of one hour through cron job from tg channel after its deleted from teldrive this is done so that person can recover files if he/she accidently deletes them.
2024-02-07 00:08:12 +08:00
### Advanced Configuration
**cli options**
```sh
teldrive run --help
```
| Flag Name | Description | Required | Default Value |
|-------------------------------------|---------------------------------------------------|----------|-------------------------------------------------------|
| --jwt-secret | JWT secret key | Yes | "" |
| --db-data-source | Database connection string | Yes | "" |
| --tg-app-id | API ID for your Telegram account, which can be obtained from my.telegram.org. | Yes | 0 |
| --tg-app-hash | API HASH for your Telegram account, which can be obtained from my.telegram.org. | Yes | "" |
| --jwt-allowed-users | Allow certain Telegram usernames, including yours, to access the app. |No | "" |
| --tg-uploads-encryption-key | Encryption key for encrypting files. | No | "" |
| --config, -c | Config file. | No | $HOME/.teldrive/config.toml |
| --server-port, -p | Server port | No | 8080 |
2024-02-13 18:36:31 +08:00
| --log-level | Logging level<br> <br> DebugLevel = -1 <br>InfoLevel = 0<br> WarnLevel = 1 <br> ErrorLevel = 2 | No | -1 |
| --tg-rate-limit | Enable rate limiting | No | true |
| --tg-rate-burst | Limiting burst | No | 5 |
| --tg-rate | Limiting rate | No | 100 |
2024-02-13 18:36:31 +08:00
| --tg-session-file | Bot session file. | No | $HOME/.teldrive/session.db |
| --tg-bg-bots-limit | Start at most this no of bots in the background to prevent connection recreation on every request.Increase this if you are streaming or downloading large no of files simultaneously. | No | 5
| --tg-uploads-threads | Concurrent Uploads threads for uploading file | No | 16 |
2024-02-20 01:52:02 +08:00
| --tg-uploads-retention | Uploads retention duration.Duration to keep failed uploaded chunks in db for resuming uploads. | No | 7d |
| --tg-proxy | Socks5 or HTTP proxy for telegram client. | No | "" |
**You Can also set config values through env varibles.**
- For example ```tg-session-file``` will become ```TELDRIVE_TG_SESSION_FILE``` same for all possible flags.
- See ```config.sample.toml``` in repo if you want to setup advanced configurations through toml file.
2023-08-16 05:53:02 +08:00
2024-02-07 00:08:12 +08:00
> [!WARNING]
> Keep your Password safe once generated teldrive uses same encryption as of rclone internally
2024-02-10 23:10:56 +08:00
so you don't need to enable crypt in rclone.**Teldrive generates random salt for each file part and saves in database so its more secure than rclone crypt whereas in rclone same salt value is used for all files which can be compromised easily**. Enabling crypt in rclone makes UI redundant so encrypting files in teldrive internally is better way to encrypt files and more secure encryption than rclone.To encrypt files see more about teldrive rclone config.
2024-02-07 00:08:12 +08:00
### For making use of Multi Bots
2024-02-07 00:08:12 +08:00
> [!WARNING]
2024-02-10 00:16:50 +08:00
> Bots will be auto added as admin in channel if you set them from UI if it fails somehow add it manually.For newly logged session you have to wait 20-30 min to add bots to telegram channel.**FRESH_CHANGE_ADMINS_FORBIDDEN** error will be thrown if you try to add bots before that time frame.
2024-02-07 00:08:12 +08:00
### Rclone Config Example
```conf
[teldrive]
type = teldrive
api_host = http://localhost:8080 # default host
access_token = #session token obtained from cookies
chunk_size = 500M
upload_concurrency = 4
encrypt_files = false # Enable this to encrypt files make sure ENCRYPTION_KEY env variable is not empty in teldrive instance.
2024-04-26 14:26:31 +08:00
randomise_part= true # Use random part names when uploading files to channel instead of original filename.
2024-02-07 00:08:12 +08:00
```
**See all options in rclone config command**
2024-02-07 00:08:12 +08:00
[Read Wiki for FAQ](https://github.com/divyam234/teldrive/wiki).
2024-02-07 00:08:12 +08:00
## Best Practices for Using Teldrive
2024-02-07 00:08:12 +08:00
### Dos:
2024-02-07 00:08:12 +08:00
- **Follow Limits:** Adhere to the limits imposed by Telegram servers to avoid account bans and automatic deletion of your channel.
2024-02-07 00:08:12 +08:00
### Don'ts:
2023-12-08 05:46:06 +08:00
2024-02-07 00:08:12 +08:00
- **Data Hoarding:** Avoid excessive data hoarding, as it not only violates Telegram's terms but also leads to unnecessary wastage of storage space.
2024-02-07 00:08:12 +08:00
### Additional Recommendations:
2023-12-08 05:46:06 +08:00
2024-02-07 00:08:12 +08:00
- **Responsible Storage:** Be mindful of the content you store on Telegram. Utilize storage efficiently and only keep data that serves a purpose.
2023-08-16 05:53:02 +08:00
2024-02-07 00:08:12 +08:00
- **Respect Terms of Service:** Familiarize yourself with and adhere to the terms of service provided by Telegram to ensure a positive and sustainable usage experience.
2024-02-07 00:08:12 +08:00
By following these guidelines, you contribute to the responsible and effective use of Telegram, maintaining a fair and equitable environment for all users.
2023-08-16 05:53:02 +08:00
## Contributing
2023-08-16 21:15:53 +08:00
Feel free to contribute to this project if you have any further ideas.
2023-11-05 00:28:29 +08:00
## Donate
If you like this project small contribution would be appreciated [Paypal](https://paypal.me/redux234).