mirror of
https://github.com/tgdrive/teldrive.git
synced 2025-09-05 22:14:30 +08:00
chnaged package name
This commit is contained in:
parent
2f242944dc
commit
a973f1d60d
17 changed files with 193 additions and 37 deletions
2
.vscode/auth.go
vendored
2
.vscode/auth.go
vendored
|
@ -3,7 +3,7 @@ package routes
|
|||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/divyam234/teldrive-go/services"
|
||||
"github.com/divyam234/teldrive/services"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
|
4
.vscode/file.routes.go
vendored
4
.vscode/file.routes.go
vendored
|
@ -6,8 +6,8 @@ import (
|
|||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/divyam234/teldrive-go/database"
|
||||
"github.com/divyam234/teldrive-go/services"
|
||||
"github.com/divyam234/teldrive/database"
|
||||
"github.com/divyam234/teldrive/services"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
|
44
Dockerfile
Normal file
44
Dockerfile
Normal file
|
@ -0,0 +1,44 @@
|
|||
FROM golang:alpine as builder
|
||||
|
||||
RUN apk update && apk add --no-cache git ca-certificates tzdata && update-ca-certificates
|
||||
|
||||
ENV USER=appuser
|
||||
|
||||
ENV UID=10001
|
||||
|
||||
RUN adduser \
|
||||
--disabled-password \
|
||||
--gecos "" \
|
||||
--home "/nonexistent" \
|
||||
--shell "/sbin/nologin" \
|
||||
--no-create-home \
|
||||
--uid "${UID}" \
|
||||
"${USER}"
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# use modules
|
||||
COPY go.mod .
|
||||
|
||||
ENV GO111MODULE=on
|
||||
RUN go mod download && go mod verify
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
|
||||
-ldflags='-w -s -extldflags "-static"' -a \
|
||||
-o /go/bin/teldrive .
|
||||
|
||||
|
||||
FROM scratch
|
||||
|
||||
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
|
||||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||
COPY --from=builder /etc/passwd /etc/passwd
|
||||
COPY --from=builder /etc/group /etc/group
|
||||
|
||||
COPY --from=builder /go/bin/teldrive /go/bin/teldrive
|
||||
|
||||
USER appuser:appuser
|
||||
|
||||
ENTRYPOINT ["/go/bin/teldrive"]
|
114
README.md
114
README.md
|
@ -1 +1,113 @@
|
|||
teldrive-go
|
||||
<h1 align="center"> Telegram Drive</h1>
|
||||
|
||||
<details open="open">
|
||||
<summary>Table of Contents</summary>
|
||||
<ol>
|
||||
<li>
|
||||
<a href="#how-to-make-your-own">How to make your own</a>
|
||||
<ul>
|
||||
<li><a href="prerequisites">Prerequisites</a></li>
|
||||
<li><a href="#deploy-using-docker-compose">Deploy using docker-compose</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#setting-up-things">Setting up things</a></li>
|
||||
<ul>
|
||||
<li><a href="#mandatory-vars">Mandatory Vars</a></li>
|
||||
<li><a href="#optional-vars">Optional Vars</a></li>
|
||||
</ul>
|
||||
</ol>
|
||||
</details>
|
||||
|
||||
## Demo
|
||||
|
||||
|
||||

|
||||
|
||||
### Deploy using docker-compose
|
||||
First clone the repository
|
||||
```sh
|
||||
git clone https://github.com/divyam234/teldrive
|
||||
cd teldrive
|
||||
```
|
||||
now create the `.env` file with your variables. and start your container:
|
||||
**If you are deploying without https replace nginx.conf with nginx_nossl.conf
|
||||
in docker-compose.yml.It should look like this**
|
||||
```yml
|
||||
volumes:
|
||||
- ./nginx_nossl.conf:/etc/nginx/conf.d/default.conf
|
||||
```
|
||||
```sh
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
## Setting up things
|
||||
|
||||
If you're locally hosting, create a file named `.env` in the root directory and add all the variables there.
|
||||
An example of `.env` file:
|
||||
|
||||
```sh
|
||||
API_ID=452525
|
||||
API_HASH=esx576f8738x883f3sfzx83
|
||||
MULTI_TOKEN1=55838383:yourfirstmulticlientbottokenhere
|
||||
MULTI_TOKEN2=55838383:yoursecondmulticlientbottokenhere
|
||||
MULTI_TOKEN3=55838383:yourthirdmulticlientbottokenhere
|
||||
BIN_CHANNEL=-100
|
||||
PORT=8080
|
||||
FQDN=yourserverhost
|
||||
HTTPS=1
|
||||
DATABASE_URL='postgres_url'
|
||||
JWT_SECRET=
|
||||
DATABASE_NAME=drive
|
||||
```
|
||||
### Mandatory Vars
|
||||
Before running the bot, you will need to set up the following mandatory variables:
|
||||
|
||||
- `API_ID` : This is the API ID for your Telegram account, which can be obtained from my.telegram.org.
|
||||
|
||||
- `API_HASH` : This is the API hash for your Telegram account, which can also be obtained from my.telegram.org.
|
||||
|
||||
- `JWT_SECRET` : Used for signing jwt tokens
|
||||
|
||||
- `DATABASE_URL` : Connection String obtained from Postgres DB (you can use Neon db as free alternative fro postgres)
|
||||
|
||||
- `BIN_CHANNEL` : This is the channel ID for the log channel where the bot will forward media messages and store these files to make the generated direct links work. To obtain a channel ID, create a new telegram channel (public or private), post something in the channel, forward the message to [@missrose_bot](https://telegram.dog/MissRose_bot) and **reply the forwarded message** with the /id command. Copy the forwarded channel ID and paste it into the this field.
|
||||
|
||||
### Optional Vars
|
||||
In addition to the mandatory variables, you can also set the following optional variables:
|
||||
|
||||
- `WORKERS` : This sets the maximum number of concurrent workers for handling incoming updates. The default value is 3.
|
||||
|
||||
- `PORT` : This sets the port that your webapp will listen to. The default value is 8080.
|
||||
|
||||
- `HTTPS` : Enable HTTPS support on nginx
|
||||
|
||||
- `USE_SESSION_FILE` : Use session files for client(s) rather than storing the pyrogram sqlite database in the memory
|
||||
|
||||
### For making use of Multi-Client support
|
||||
|
||||
> **Note**
|
||||
> What it multi-client feature and what it does? <br>
|
||||
> This feature shares the Telegram API requests between other bots to avoid getting floodwaited (A kind of rate limiting that Telegram does in the backend to avoid flooding their servers) and to make the server handle more requests. <br>
|
||||
|
||||
To enable multi-client, generate new bot tokens and add it as your environmental variables with the following key names.
|
||||
|
||||
`MULTI_TOKEN1`: Add your first bot token here.
|
||||
|
||||
`MULTI_TOKEN2`: Add your second bot token here.
|
||||
|
||||
you may also add as many as bots you want. (max limit is not tested yet)
|
||||
`MULTI_TOKEN3`, `MULTI_TOKEN4`, etc.
|
||||
|
||||
> **Warning**
|
||||
> Don't forget to add all these bots to the `BIN_CHANNEL` for the proper functioning
|
||||
|
||||
## FAQ
|
||||
|
||||
- How long the links will remain valid or is there any expiration time for the links generated by the bot?
|
||||
> The links will will be valid as longs as your bot is alive and you haven't deleted the log channel.
|
||||
|
||||
## Contributing
|
||||
|
||||
Feel free to contribute to this project if you have any further ideas
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package database
|
|||
import (
|
||||
"time"
|
||||
|
||||
"github.com/divyam234/teldrive-go/utils"
|
||||
"github.com/divyam234/teldrive/utils"
|
||||
"gorm.io/driver/postgres"
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/schema"
|
||||
|
|
2
go.mod
2
go.mod
|
@ -1,4 +1,4 @@
|
|||
module github.com/divyam234/teldrive-go
|
||||
module github.com/divyam234/teldrive
|
||||
|
||||
go 1.21
|
||||
|
||||
|
|
8
main.go
8
main.go
|
@ -3,10 +3,10 @@ package main
|
|||
import (
|
||||
"time"
|
||||
|
||||
"github.com/divyam234/teldrive-go/cache"
|
||||
"github.com/divyam234/teldrive-go/database"
|
||||
"github.com/divyam234/teldrive-go/routes"
|
||||
"github.com/divyam234/teldrive-go/utils"
|
||||
"github.com/divyam234/teldrive/cache"
|
||||
"github.com/divyam234/teldrive/database"
|
||||
"github.com/divyam234/teldrive/routes"
|
||||
"github.com/divyam234/teldrive/utils"
|
||||
|
||||
"github.com/divyam234/cors"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
|
BIN
public/demo.png
Normal file
BIN
public/demo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 280 KiB |
|
@ -3,8 +3,8 @@ package routes
|
|||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/divyam234/teldrive-go/database"
|
||||
"github.com/divyam234/teldrive-go/services"
|
||||
"github.com/divyam234/teldrive/database"
|
||||
"github.com/divyam234/teldrive/services"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
|
|
@ -3,9 +3,9 @@ package routes
|
|||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/divyam234/teldrive-go/database"
|
||||
"github.com/divyam234/teldrive-go/services"
|
||||
"github.com/divyam234/teldrive-go/utils"
|
||||
"github.com/divyam234/teldrive/database"
|
||||
"github.com/divyam234/teldrive/services"
|
||||
"github.com/divyam234/teldrive/utils"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
|
|
@ -4,8 +4,8 @@ import (
|
|||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/divyam234/teldrive-go/services"
|
||||
"github.com/divyam234/teldrive-go/utils/auth"
|
||||
"github.com/divyam234/teldrive/services"
|
||||
"github.com/divyam234/teldrive/utils/auth"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-jose/go-jose/v3/jwt"
|
||||
)
|
||||
|
|
|
@ -3,9 +3,9 @@ package routes
|
|||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/divyam234/teldrive-go/database"
|
||||
"github.com/divyam234/teldrive-go/services"
|
||||
"github.com/divyam234/teldrive-go/utils"
|
||||
"github.com/divyam234/teldrive/database"
|
||||
"github.com/divyam234/teldrive/services"
|
||||
"github.com/divyam234/teldrive/utils"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
|
|
@ -3,7 +3,7 @@ package schemas
|
|||
import (
|
||||
"time"
|
||||
|
||||
"github.com/divyam234/teldrive-go/models"
|
||||
"github.com/divyam234/teldrive/models"
|
||||
)
|
||||
|
||||
type PaginationQuery struct {
|
||||
|
|
|
@ -15,11 +15,11 @@ import (
|
|||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/divyam234/teldrive-go/models"
|
||||
"github.com/divyam234/teldrive-go/schemas"
|
||||
"github.com/divyam234/teldrive-go/types"
|
||||
"github.com/divyam234/teldrive-go/utils"
|
||||
"github.com/divyam234/teldrive-go/utils/auth"
|
||||
"github.com/divyam234/teldrive/models"
|
||||
"github.com/divyam234/teldrive/schemas"
|
||||
"github.com/divyam234/teldrive/types"
|
||||
"github.com/divyam234/teldrive/utils"
|
||||
"github.com/divyam234/teldrive/utils/auth"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-jose/go-jose/v3/jwt"
|
||||
"github.com/gorilla/websocket"
|
||||
|
|
|
@ -11,12 +11,12 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/divyam234/teldrive-go/cache"
|
||||
"github.com/divyam234/teldrive-go/models"
|
||||
"github.com/divyam234/teldrive-go/schemas"
|
||||
"github.com/divyam234/teldrive-go/utils"
|
||||
"github.com/divyam234/teldrive/cache"
|
||||
"github.com/divyam234/teldrive/models"
|
||||
"github.com/divyam234/teldrive/schemas"
|
||||
"github.com/divyam234/teldrive/utils"
|
||||
|
||||
"github.com/divyam234/teldrive-go/types"
|
||||
"github.com/divyam234/teldrive/types"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gotd/td/telegram"
|
||||
|
|
|
@ -6,13 +6,13 @@ import (
|
|||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/divyam234/teldrive-go/cache"
|
||||
"github.com/divyam234/teldrive-go/schemas"
|
||||
"github.com/divyam234/teldrive-go/utils"
|
||||
"github.com/divyam234/teldrive/cache"
|
||||
"github.com/divyam234/teldrive/schemas"
|
||||
"github.com/divyam234/teldrive/utils"
|
||||
|
||||
"github.com/divyam234/teldrive-go/types"
|
||||
"github.com/divyam234/teldrive/types"
|
||||
|
||||
"github.com/divyam234/teldrive-go/models"
|
||||
"github.com/divyam234/teldrive/models"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gotd/td/telegram/message"
|
||||
"github.com/gotd/td/telegram/uploader"
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"encoding/json"
|
||||
"os"
|
||||
|
||||
"github.com/divyam234/teldrive-go/types"
|
||||
"github.com/divyam234/teldrive/types"
|
||||
"github.com/go-jose/go-jose/v3"
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue