├── Procfile
├── goreleaser.Dockerfile
├── .gitattributes
├── internal
├── types
│ ├── response.go
│ └── file.go
├── bot
│ ├── middleware.go
│ ├── client.go
│ ├── userbot.go
│ └── workers.go
├── utils
│ ├── hashing.go
│ ├── time_format.go
│ ├── logger.go
│ ├── reader.go
│ └── helpers.go
├── commands
│ ├── commands.go
│ ├── start.go
│ └── stream.go
├── routes
│ ├── routes.go
│ └── stream.go
└── cache
│ └── cache.go
├── Dockerfile
├── docker-compose.yaml
├── .gitignore
├── .github
└── workflows
│ ├── notify.yml
│ ├── release.yml
│ └── build.yml
├── .vscode
└── launch.json
├── fsb.sample.env
├── cmd
└── fsb
│ ├── main.go
│ ├── session.go
│ └── run.go
├── .goreleaser.yaml
├── pkg
└── qrlogin
│ ├── encoder.go
│ └── qrcode.go
├── app.json
├── go.mod
├── config
└── config.go
├── README.md
├── go.sum
└── LICENSE
/Procfile:
--------------------------------------------------------------------------------
1 | web: fsb run
--------------------------------------------------------------------------------
/goreleaser.Dockerfile:
--------------------------------------------------------------------------------
1 | FROM golang:1.21
2 | CMD ["/app/fsb"]
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/internal/types/response.go:
--------------------------------------------------------------------------------
1 | package types
2 |
3 | type RootResponse struct {
4 | Message string `json:"message"`
5 | Ok bool `json:"ok"`
6 | Uptime string `json:"uptime"`
7 | Version string `json:"version"`
8 | }
9 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM golang:1.21-alpine3.18 as builder
2 | RUN apk update && apk upgrade --available && sync
3 | WORKDIR /app
4 | COPY . .
5 | RUN CGO_ENABLED=0 go build -o /app/fsb -ldflags="-w -s" ./cmd/fsb
6 |
7 | FROM scratch
8 | COPY --from=builder /app/fsb /app/fsb
9 | EXPOSE ${PORT}
10 | ENTRYPOINT ["/app/fsb", "run"]
11 |
--------------------------------------------------------------------------------
/docker-compose.yaml:
--------------------------------------------------------------------------------
1 | name: TG File Stream Bot
2 |
3 | services:
4 | fsb-run:
5 | image: ghcr.io/everythingsuckz/fsb
6 | container_name: fsb
7 | restart: always
8 | volumes:
9 | - ./logs:/app/logs
10 | - ./fsb.env:/app/fsb.env
11 | ports:
12 | - "${PORT:-8038}:${PORT:-8038}"
13 | env_file:
14 | - path: ./fsb.env
15 | required: true
16 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Binaries for programs and plugins
2 | *.exe
3 | *.exe~
4 | *.dll
5 | *.so
6 | *.dylib
7 |
8 | # Test binary, built with `go test -c`
9 | *.test
10 |
11 | # Output of the go coverage tool, specifically when used with LiteIDE
12 | *.out
13 |
14 | # Dependency directories
15 | vendor/
16 |
17 | # Go workspace file
18 | go.work
19 |
20 | # Env files
21 | fsb.env
22 | .env
23 |
24 | # Session files
25 | *.session*
26 | sessons/
27 |
28 | # build folder
29 | dist/
30 |
31 | # logs folder
32 | logs/
33 | *.log
--------------------------------------------------------------------------------
/internal/bot/middleware.go:
--------------------------------------------------------------------------------
1 | package bot
2 |
3 | import (
4 | "time"
5 |
6 | "github.com/gotd/contrib/middleware/floodwait"
7 | "github.com/gotd/contrib/middleware/ratelimit"
8 | "github.com/gotd/td/telegram"
9 | "go.uber.org/zap"
10 | "golang.org/x/time/rate"
11 | )
12 |
13 | func GetFloodMiddleware(log *zap.Logger) []telegram.Middleware {
14 | waiter := floodwait.NewSimpleWaiter().WithMaxRetries(10)
15 | ratelimiter := ratelimit.New(rate.Every(time.Millisecond*100), 5)
16 | return []telegram.Middleware{
17 | waiter,
18 | ratelimiter,
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/internal/utils/hashing.go:
--------------------------------------------------------------------------------
1 | package utils
2 |
3 | import (
4 | "EverythingSuckz/fsb/config"
5 | "EverythingSuckz/fsb/internal/types"
6 | )
7 |
8 | func PackFile(fileName string, fileSize int64, mimeType string, fileID int64) string {
9 | return (&types.HashableFileStruct{FileName: fileName, FileSize: fileSize, MimeType: mimeType, FileID: fileID}).Pack()
10 | }
11 |
12 | func GetShortHash(fullHash string) string {
13 | return fullHash[:config.ValueOf.HashLength]
14 | }
15 |
16 | func CheckHash(inputHash string, expectedHash string) bool {
17 | return inputHash == GetShortHash(expectedHash)
18 | }
19 |
--------------------------------------------------------------------------------
/internal/commands/commands.go:
--------------------------------------------------------------------------------
1 | package commands
2 |
3 | import (
4 | "reflect"
5 |
6 | "github.com/celestix/gotgproto/dispatcher"
7 | "go.uber.org/zap"
8 | )
9 |
10 | type command struct {
11 | log *zap.Logger
12 | }
13 |
14 | func Load(log *zap.Logger, dispatcher dispatcher.Dispatcher) {
15 | log = log.Named("commands")
16 | defer log.Info("Initialized all command handlers")
17 | Type := reflect.TypeOf(&command{log})
18 | Value := reflect.ValueOf(&command{log})
19 | for i := 0; i < Type.NumMethod(); i++ {
20 | Type.Method(i).Func.Call([]reflect.Value{Value, reflect.ValueOf(dispatcher)})
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/.github/workflows/notify.yml:
--------------------------------------------------------------------------------
1 | name: Notify on Telegram
2 |
3 | on:
4 | fork:
5 | push:
6 | release:
7 | types: published
8 | issue_comment:
9 | types: created
10 | watch:
11 | types: started
12 | pull_request_review_comment:
13 | types: created
14 | pull_request:
15 | types: [opened, closed, reopened]
16 | issues:
17 | types: [opened, pinned, closed, reopened]
18 | jobs:
19 | notify:
20 | runs-on: ubuntu-latest
21 | steps:
22 | - uses: actions/checkout@v3
23 | - name: Notify the commit on Telegram.
24 | uses: EverythingSuckz/github-telegram-notify@main
25 | with:
26 | bot_token: '${{ secrets.BOT_TOKEN }}'
27 | chat_id: '${{ secrets.CHAT_ID }}'
28 | topic_id: '${{ secrets.TOPIC_ID }}'
29 |
--------------------------------------------------------------------------------
/internal/routes/routes.go:
--------------------------------------------------------------------------------
1 | package routes
2 |
3 | import (
4 | "reflect"
5 |
6 | "github.com/gin-gonic/gin"
7 | "go.uber.org/zap"
8 | )
9 |
10 | type Route struct {
11 | Name string
12 | Engine *gin.Engine
13 | }
14 |
15 | func (r *Route) Init(engine *gin.Engine) {
16 | r.Engine = engine
17 | }
18 |
19 | type allRoutes struct {
20 | log *zap.Logger
21 | }
22 |
23 | func Load(log *zap.Logger, r *gin.Engine) {
24 | log = log.Named("routes")
25 | defer log.Sugar().Info("Loaded all API Routes")
26 | route := &Route{Name: "/", Engine: r}
27 | route.Init(r)
28 | Type := reflect.TypeOf(&allRoutes{log})
29 | Value := reflect.ValueOf(&allRoutes{log})
30 | for i := 0; i < Type.NumMethod(); i++ {
31 | Type.Method(i).Func.Call([]reflect.Value{Value, reflect.ValueOf(route)})
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Launch Package",
9 | "type": "go",
10 | "request": "launch",
11 | "mode": "auto",
12 | "program": "./cmd/fsb/",
13 | "args": [
14 | "run"
15 | ]
16 | },
17 | {
18 | "name": "Generate Session",
19 | "type": "go",
20 | "request": "launch",
21 | "mode": "auto",
22 | "program": "./cmd/fsb/",
23 | "args": [
24 | "session"
25 | ],
26 | "console": "integratedTerminal"
27 | }
28 | ]
29 | }
--------------------------------------------------------------------------------
/fsb.sample.env:
--------------------------------------------------------------------------------
1 | # Required Variables (DO NOT SKIP THESE)
2 |
3 | API_ID=
4 | API_HASH=
5 | BOT_TOKEN=
6 | LOG_CHANNEL=
7 |
8 | # Optional Variables
9 |
10 | PORT=8080
11 |
12 | # The length of the hash in your URLs
13 | # https://domain.tld/1254?hash=asd45a
14 | # ^^^^^^
15 | # /
16 | # This is the hash
17 |
18 | HASH_LENGTH=6
19 |
20 | # you can use IP address
21 | # HOST=http://:
22 | # Or you can also use a domain name
23 | # HOST=https://example.com
24 |
25 | # For muti token support
26 | # Refer https://github.com/EverythingSuckz/TG-FileStreamBot/tree/golang#use-multiple-bots-to-speed-up
27 |
28 | # MULTI_TOKEN1=1857821156:AAEvrINCsduhjkjhahadvHRdk7oF46KZnc
29 | # MULTI_TOKEN2=1355359001:AAF4dgddVVxDCt51FZqy1unh9h0SOTw0gU
30 | # MULTI_TOKEN3=6941936497:AAGJzfoMHXshS8gVcsefUzpwyrbfU7gKRMM
31 | # MULTI_TOKEN4=6546079247:AAF2k3uvO9Hqadfhjaskjds8jnzOAfQYUzTZ
--------------------------------------------------------------------------------
/internal/types/file.go:
--------------------------------------------------------------------------------
1 | package types
2 |
3 | import (
4 | "crypto/md5"
5 | "encoding/hex"
6 | "reflect"
7 | "strconv"
8 |
9 | "github.com/gotd/td/tg"
10 | )
11 |
12 | type File struct {
13 | Location *tg.InputDocumentFileLocation
14 | FileSize int64
15 | FileName string
16 | MimeType string
17 | ID int64
18 | }
19 |
20 | type HashableFileStruct struct {
21 | FileName string
22 | FileSize int64
23 | MimeType string
24 | FileID int64
25 | }
26 |
27 | func (f *HashableFileStruct) Pack() string {
28 | hasher := md5.New()
29 | val := reflect.ValueOf(*f)
30 | for i := 0; i < val.NumField(); i++ {
31 | field := val.Field(i)
32 |
33 | var fieldValue []byte
34 | switch field.Kind() {
35 | case reflect.String:
36 | fieldValue = []byte(field.String())
37 | case reflect.Int64:
38 | fieldValue = []byte(strconv.FormatInt(field.Int(), 10))
39 | }
40 |
41 | hasher.Write(fieldValue)
42 | }
43 | return hex.EncodeToString(hasher.Sum(nil))
44 | }
45 |
--------------------------------------------------------------------------------
/cmd/fsb/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "EverythingSuckz/fsb/config"
5 | "fmt"
6 | "os"
7 |
8 | "github.com/spf13/cobra"
9 | )
10 |
11 | const versionString = "3.0.0"
12 |
13 | var rootCmd = &cobra.Command{
14 | Use: "fsb [command]",
15 | Short: "Telegram File Stream Bot",
16 | Long: "Telegram Bot to generate direct streamable links for telegram media.",
17 | Example: "fsb run --port 8080",
18 | Version: versionString,
19 | CompletionOptions: cobra.CompletionOptions{DisableDefaultCmd: true},
20 | Run: func(cmd *cobra.Command, args []string) {
21 | cmd.Help()
22 | },
23 | }
24 |
25 | func init() {
26 | config.SetFlagsFromConfig(runCmd)
27 | rootCmd.AddCommand(runCmd)
28 | rootCmd.AddCommand(sessionCmd)
29 | rootCmd.SetVersionTemplate(fmt.Sprintf(`Telegram File Stream Bot version %s`, versionString))
30 | }
31 |
32 | func main() {
33 | if err := rootCmd.Execute(); err != nil {
34 | fmt.Println(err)
35 | os.Exit(1)
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/internal/utils/time_format.go:
--------------------------------------------------------------------------------
1 | package utils
2 |
3 | import (
4 | "fmt"
5 | "math/bits"
6 | )
7 |
8 | func TimeFormat(seconds uint64) (timeStr string) {
9 | hours, remainder := bits.Div64(0, seconds, 3600)
10 | minutes, seconds := bits.Div64(0, remainder, 60)
11 | days, hours := bits.Div64(0, hours, 24)
12 | timeStr = ""
13 | if days > 0 {
14 | if days == 1 {
15 | timeStr += fmt.Sprintf("%d day, ", days)
16 | } else {
17 | timeStr += fmt.Sprintf("%d days, ", days)
18 | }
19 | }
20 | if hours > 0 {
21 | if hours == 1 {
22 | timeStr += fmt.Sprintf("%d hour, ", hours)
23 | } else {
24 | timeStr += fmt.Sprintf("%d hours, ", hours)
25 | }
26 | }
27 | if minutes > 0 {
28 | if minutes == 1 {
29 | timeStr += fmt.Sprintf("%d minute, ", minutes)
30 | } else {
31 | timeStr += fmt.Sprintf("%d minutes, ", minutes)
32 | }
33 | }
34 | if seconds > 0 {
35 | if seconds == 1 {
36 | timeStr += fmt.Sprintf("%d second", seconds)
37 | } else {
38 | timeStr += fmt.Sprintf("%d seconds", seconds)
39 | }
40 | }
41 | return timeStr
42 | }
43 |
--------------------------------------------------------------------------------
/internal/commands/start.go:
--------------------------------------------------------------------------------
1 | package commands
2 |
3 | import (
4 | "EverythingSuckz/fsb/config"
5 | "EverythingSuckz/fsb/internal/utils"
6 |
7 | "github.com/celestix/gotgproto/dispatcher"
8 | "github.com/celestix/gotgproto/dispatcher/handlers"
9 | "github.com/celestix/gotgproto/ext"
10 | "github.com/celestix/gotgproto/storage"
11 | )
12 |
13 | func (m *command) LoadStart(dispatcher dispatcher.Dispatcher) {
14 | log := m.log.Named("start")
15 | defer log.Sugar().Info("Loaded")
16 | dispatcher.AddHandler(handlers.NewCommand("start", start))
17 | }
18 |
19 | func start(ctx *ext.Context, u *ext.Update) error {
20 | chatId := u.EffectiveChat().GetID()
21 | peerChatId := ctx.PeerStorage.GetPeerById(chatId)
22 | if peerChatId.Type != int(storage.TypeUser) {
23 | return dispatcher.EndGroups
24 | }
25 | if len(config.ValueOf.AllowedUsers) != 0 && !utils.Contains(config.ValueOf.AllowedUsers, chatId) {
26 | ctx.Reply(u, "You are not allowed to use this bot.", nil)
27 | return dispatcher.EndGroups
28 | }
29 | ctx.Reply(u, "Hi, send me any file to get a direct streamble link to that file.", nil)
30 | return dispatcher.EndGroups
31 | }
32 |
--------------------------------------------------------------------------------
/.goreleaser.yaml:
--------------------------------------------------------------------------------
1 | version: 1
2 | project_name: TG-FileStreamBot
3 | env:
4 | - GO111MODULE=on
5 | before:
6 | hooks:
7 | - go mod tidy
8 | - go generate ./...
9 |
10 | builds:
11 | - main: ./cmd/fsb
12 | env:
13 | - CGO_ENABLED=0
14 | flags: -tags=musl
15 | ldflags: "-extldflags -static -s -w"
16 | binary: fsb
17 | goos:
18 | - linux
19 | - windows
20 | - darwin
21 | goarch:
22 | - amd64
23 | - arm64
24 | mod_timestamp: '{{ .CommitTimestamp }}'
25 |
26 | archives:
27 | - format: tar.gz
28 | name_template: "{{ .ProjectName }}-{{ .Tag }}-{{ .Os }}-{{ .Arch }}"
29 | format_overrides:
30 | - goos: windows
31 | format: zip
32 |
33 | signs:
34 | - artifacts: checksum
35 | cmd: gpg2
36 | args:
37 | - "--batch"
38 | - "-u"
39 | - "{{ .Env.GPG_FINGERPRINT }}"
40 | - "--output"
41 | - "${signature}"
42 | - "--detach-sign"
43 | - "${artifact}"
44 |
45 | checksum:
46 | name_template: "{{ .ProjectName }}-{{ .Tag }}-checksums.txt"
47 |
48 | changelog:
49 | sort: asc
50 | filters:
51 | exclude:
52 | - "^docs:"
53 | - "^test:"
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: Goreleaser
2 |
3 | on:
4 | workflow_dispatch:
5 | inputs:
6 | goReleaserArgs:
7 | description: 'Args goreleaser'
8 | required: false
9 | default: '--clean'
10 | push:
11 | tags:
12 | - "*"
13 |
14 | permissions:
15 | contents: write
16 |
17 | jobs:
18 | goreleaser:
19 | runs-on: ubuntu-latest
20 | steps:
21 | - name: Checkout
22 | uses: actions/checkout@v3
23 | with:
24 | fetch-depth: 0
25 | - run: git fetch --force --tags
26 | - name: Set up Go
27 | uses: actions/setup-go@v4
28 | with:
29 | go-version: 1.21
30 | - name: Import GPG key
31 | id: import_gpg
32 | uses: crazy-max/ghaction-import-gpg@v6
33 | with:
34 | gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
35 | passphrase: ${{ secrets.PASSPHRASE }}
36 | - name: Run GoReleaser
37 | uses: goreleaser/goreleaser-action@v5
38 | with:
39 | distribution: goreleaser
40 | version: latest
41 | args: release ${{ github.event.inputs.goReleaserArgs }}"
42 | env:
43 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44 | GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
--------------------------------------------------------------------------------
/cmd/fsb/session.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 |
6 | "EverythingSuckz/fsb/pkg/qrlogin"
7 |
8 | "github.com/spf13/cobra"
9 | )
10 |
11 | var sessionCmd = &cobra.Command{
12 | Use: "session",
13 | Short: "Generate a string session.",
14 | DisableSuggestions: false,
15 | Run: generateSession,
16 | }
17 |
18 | func init() {
19 | sessionCmd.Flags().StringP("login-type", "T", "qr", "The login type to use. Can be either 'qr' or 'phone'")
20 | sessionCmd.Flags().Int32P("api-id", "I", 0, "The API ID to use for the session (required).")
21 | sessionCmd.Flags().StringP("api-hash", "H", "", "The API hash to use for the session (required).")
22 | sessionCmd.MarkFlagRequired("api-id")
23 | sessionCmd.MarkFlagRequired("api-hash")
24 | }
25 |
26 | func generateSession(cmd *cobra.Command, args []string) {
27 | loginType, _ := cmd.Flags().GetString("login-type")
28 | apiId, _ := cmd.Flags().GetInt32("api-id")
29 | apiHash, _ := cmd.Flags().GetString("api-hash")
30 | if loginType == "qr" {
31 | qrlogin.GenerateQRSession(int(apiId), apiHash)
32 | } else if loginType == "phone" {
33 | generatePhoneSession()
34 | } else {
35 | fmt.Println("Invalid login type. Please use either 'qr' or 'phone'")
36 | }
37 | }
38 |
39 | func generatePhoneSession() {
40 | fmt.Println("Phone session is not implemented yet.")
41 | }
42 |
--------------------------------------------------------------------------------
/internal/utils/logger.go:
--------------------------------------------------------------------------------
1 | package utils
2 |
3 | import (
4 | "os"
5 | "time"
6 |
7 | "go.uber.org/zap"
8 | "go.uber.org/zap/zapcore"
9 | "gopkg.in/natefinch/lumberjack.v2"
10 | )
11 |
12 | var Logger *zap.Logger
13 |
14 | func InitLogger(debugMode bool) {
15 | customTimeEncoder := func(t time.Time, enc zapcore.PrimitiveArrayEncoder) {
16 | enc.AppendString(t.Format("02/01/2006 03:04 PM"))
17 | }
18 | consoleConfig := zap.NewDevelopmentEncoderConfig()
19 | consoleConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder
20 | consoleConfig.EncodeTime = customTimeEncoder
21 | consoleEncoder := zapcore.NewConsoleEncoder(consoleConfig)
22 |
23 | fileEncoderConfig := zap.NewProductionEncoderConfig()
24 | fileEncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
25 | fileEncoder := zapcore.NewJSONEncoder(fileEncoderConfig)
26 |
27 | fileWriter := zapcore.AddSync(&lumberjack.Logger{
28 | Filename: "logs/app.log",
29 | MaxSize: 10,
30 | MaxBackups: 3,
31 | MaxAge: 7,
32 | Compress: true,
33 | })
34 |
35 | var consoleLevel zapcore.Level
36 | if debugMode {
37 | consoleLevel = zapcore.DebugLevel
38 | } else {
39 | consoleLevel = zapcore.InfoLevel
40 | }
41 |
42 | core := zapcore.NewTee(
43 | zapcore.NewCore(consoleEncoder, zapcore.AddSync(os.Stdout), consoleLevel),
44 | zapcore.NewCore(fileEncoder, fileWriter, zapcore.DebugLevel),
45 | )
46 |
47 | Logger = zap.New(core, zap.AddStacktrace(zapcore.FatalLevel))
48 | }
49 |
--------------------------------------------------------------------------------
/internal/bot/client.go:
--------------------------------------------------------------------------------
1 | package bot
2 |
3 | import (
4 | "EverythingSuckz/fsb/config"
5 | "EverythingSuckz/fsb/internal/commands"
6 | "context"
7 | "time"
8 |
9 | "go.uber.org/zap"
10 |
11 | "github.com/celestix/gotgproto"
12 | "github.com/celestix/gotgproto/sessionMaker"
13 | "github.com/glebarez/sqlite"
14 | )
15 |
16 | var Bot *gotgproto.Client
17 |
18 | func StartClient(log *zap.Logger) (*gotgproto.Client, error) {
19 | ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
20 | defer cancel()
21 | resultChan := make(chan struct {
22 | client *gotgproto.Client
23 | err error
24 | })
25 | go func(ctx context.Context) {
26 | client, err := gotgproto.NewClient(
27 | int(config.ValueOf.ApiID),
28 | config.ValueOf.ApiHash,
29 | gotgproto.ClientTypeBot(config.ValueOf.BotToken),
30 | &gotgproto.ClientOpts{
31 | Session: sessionMaker.SqlSession(
32 | sqlite.Open("fsb.session"),
33 | ),
34 | DisableCopyright: true,
35 | },
36 | )
37 | resultChan <- struct {
38 | client *gotgproto.Client
39 | err error
40 | }{client, err}
41 | }(ctx)
42 |
43 | select {
44 | case <-ctx.Done():
45 | return nil, ctx.Err()
46 | case result := <-resultChan:
47 | if result.err != nil {
48 | return nil, result.err
49 | }
50 | commands.Load(log, result.client.Dispatcher)
51 | log.Info("Client started", zap.String("username", result.client.Self.Username))
52 | Bot = result.client
53 | return result.client, nil
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | name: Package Build
2 |
3 | on:
4 | workflow_dispatch:
5 | inputs:
6 | tag:
7 | description: 'Tag to release'
8 | required: true
9 | push:
10 | tags:
11 | - '*'
12 | env:
13 | DOCKER_BUILDKIT: 1
14 |
15 | jobs:
16 | build_image:
17 | name: Build Image
18 | runs-on: ubuntu-latest
19 | steps:
20 | - name: Checkout
21 | uses: actions/checkout@v4
22 | with:
23 | fetch-depth: 0
24 |
25 | - name: Set up Docker Buildx
26 | uses: docker/setup-buildx-action@v3
27 | with:
28 | config-inline: |
29 | [worker.oci]
30 | platforms = ["linux/amd64", "linux/arm64"]
31 | max-parallelism = 4
32 |
33 | - name: Login to GitHub Container Registry
34 | uses: docker/login-action@v3
35 | with:
36 | registry: ghcr.io
37 | username: ${{ github.actor }}
38 | password: ${{ secrets.GITHUB_TOKEN }}
39 |
40 | - name: Setup ENV vars
41 | id: env-vars
42 | run: |
43 | echo "TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
44 | echo "IMAGE_NAME=ghcr.io/${GITHUB_ACTOR,,}/fsb" >> $GITHUB_ENV
45 |
46 | - name: Build docker image and push
47 | uses: docker/build-push-action@v5
48 | with:
49 | context: ./
50 | pull: true
51 | push: true
52 | platforms: linux/amd64,linux/arm64
53 | tags: ${{ env.IMAGE_NAME }}:${{ env.TAG }} , ${{ env.IMAGE_NAME }}:latest
--------------------------------------------------------------------------------
/internal/cache/cache.go:
--------------------------------------------------------------------------------
1 | package cache
2 |
3 | import (
4 | "EverythingSuckz/fsb/internal/types"
5 | "bytes"
6 | "encoding/gob"
7 | "sync"
8 |
9 | "github.com/coocood/freecache"
10 | "github.com/gotd/td/tg"
11 | "go.uber.org/zap"
12 | )
13 |
14 | var cache *Cache
15 |
16 | type Cache struct {
17 | cache *freecache.Cache
18 | mu sync.RWMutex
19 | log *zap.Logger
20 | }
21 |
22 | func InitCache(log *zap.Logger) {
23 | log = log.Named("cache")
24 | gob.Register(types.File{})
25 | gob.Register(tg.InputDocumentFileLocation{})
26 | defer log.Sugar().Info("Initialized")
27 | cache = &Cache{cache: freecache.NewCache(10 * 1024 * 1024), log: log}
28 | }
29 |
30 | func GetCache() *Cache {
31 | return cache
32 | }
33 |
34 | func (c *Cache) Get(key string, value *types.File) error {
35 | c.mu.RLock()
36 | defer c.mu.RUnlock()
37 | data, err := cache.cache.Get([]byte(key))
38 | if err != nil {
39 | return err
40 | }
41 | dec := gob.NewDecoder(bytes.NewReader(data))
42 | err = dec.Decode(&value)
43 | if err != nil {
44 | return err
45 | }
46 | return nil
47 | }
48 |
49 | func (c *Cache) Set(key string, value *types.File, expireSeconds int) error {
50 | c.mu.Lock()
51 | defer c.mu.Unlock()
52 | var buf bytes.Buffer
53 | enc := gob.NewEncoder(&buf)
54 | err := enc.Encode(value)
55 | if err != nil {
56 | return err
57 | }
58 | cache.cache.Set([]byte(key), buf.Bytes(), expireSeconds)
59 | return nil
60 | }
61 |
62 | func (c *Cache) Delete(key string) error {
63 | c.mu.Lock()
64 | defer c.mu.Unlock()
65 | cache.cache.Del([]byte(key))
66 | return nil
67 | }
68 |
--------------------------------------------------------------------------------
/pkg/qrlogin/encoder.go:
--------------------------------------------------------------------------------
1 | // This file is a part of EverythingSuckz/TG-FileStreamBot
2 | // And is licenced under the Affero General Public License.
3 | // Any distributions of this code MUST be accompanied by a copy of the AGPL
4 | // with proper attribution to the original author(s).
5 |
6 | package qrlogin
7 |
8 | import (
9 | "bytes"
10 | "encoding/base64"
11 | "encoding/binary"
12 | "errors"
13 | "strings"
14 |
15 | "github.com/gotd/td/session"
16 | )
17 |
18 | func EncodeToPyrogramSession(data *session.Data, appID int32) (string, error) {
19 | buf := new(bytes.Buffer)
20 | if err := buf.WriteByte(byte(data.DC)); err != nil {
21 | return "", err
22 | }
23 | if err := binary.Write(buf, binary.BigEndian, appID); err != nil {
24 | return "", err
25 | }
26 | var testMode byte
27 | if data.Config.TestMode {
28 | testMode = 1
29 | }
30 | if err := buf.WriteByte(testMode); err != nil {
31 | return "", err
32 | }
33 | if len(data.AuthKey) != 256 {
34 | return "", errors.New("auth key must be 256 bytes long")
35 | }
36 | if _, err := buf.Write(data.AuthKey); err != nil {
37 | return "", err
38 | }
39 | if len(data.AuthKeyID) != 8 {
40 | return "", errors.New("auth key ID must be 8 bytes long")
41 | }
42 | if _, err := buf.Write(data.AuthKeyID); err != nil {
43 | return "", err
44 | }
45 | if err := buf.WriteByte(0); err != nil {
46 | return "", err
47 | }
48 | // Convert the bytes buffer to a base64 string
49 | encodedString := base64.URLEncoding.EncodeToString(buf.Bytes())
50 | trimmedEncoded := strings.TrimRight(encodedString, "=")
51 | return trimmedEncoded, nil
52 | }
53 |
--------------------------------------------------------------------------------
/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "TG FileStreamBot",
3 | "description": "Stream Telegram files to web",
4 | "keywords": [
5 | "telegram",
6 | "web",
7 | "go",
8 | "golang",
9 | "file-streaming",
10 | "file-to-link",
11 | "TG-FileStreamBot"
12 | ],
13 | "repository": "https://github.com/EverythingSuckz/TG-FileStreamBot",
14 | "logo": "https://telegra.ph/file/a8bb3f6b334ad1200ddb4.png",
15 | "env": {
16 | "API_ID": {
17 | "description": "Get this value from https://my.telegram.org"
18 | },
19 | "API_HASH": {
20 | "description": "Get this value from https://my.telegram.org"
21 | },
22 | "BOT_TOKEN": {
23 | "description": "Get this value from @BotFather"
24 | },
25 | "LOG_CHANNEL": {
26 | "description": "channel ID for the log channel where the bot will forward media messages and store these files"
27 | },
28 | "HOST": {
29 | "description": "A Fully Qualified Domain Name or Heroku App URL. (eg. https://example.herokuapp.com). Update it After Deploying the Bot",
30 | "required": false
31 | },
32 | "HASH_LENGTH": {
33 | "description": "Custom hash length for generated URLs. The hash length must be greater than 5 and less than or equal to 32. Default to 6",
34 | "value": "6",
35 | "required": false
36 | },
37 | "USE_SESSION_FILE": {
38 | "description": "Use session files for worker client(s). This speeds up the worker bot startups. default to false",
39 | "required": false
40 | },
41 | "USER_SESSION": {
42 | "description": "A pyrogram session string for a user bot. Used for auto adding the bots to LOG_CHANNEL. Default to null",
43 | "required": false
44 | }
45 | },
46 | "buildpacks": [{
47 | "url": "heroku/go"
48 | }],
49 | "formation": {
50 | "web": {
51 | "quantity": 1,
52 | "size": "Eco"
53 | }
54 | }
55 | }
--------------------------------------------------------------------------------
/cmd/fsb/run.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "EverythingSuckz/fsb/config"
5 | "EverythingSuckz/fsb/internal/bot"
6 | "EverythingSuckz/fsb/internal/cache"
7 | "EverythingSuckz/fsb/internal/routes"
8 | "EverythingSuckz/fsb/internal/types"
9 | "EverythingSuckz/fsb/internal/utils"
10 | "fmt"
11 | "net/http"
12 | "time"
13 |
14 | "github.com/spf13/cobra"
15 |
16 | "github.com/gin-gonic/gin"
17 | "go.uber.org/zap"
18 | )
19 |
20 | var runCmd = &cobra.Command{
21 | Use: "run",
22 | Short: "Run the bot with the given configuration.",
23 | DisableSuggestions: false,
24 | Run: runApp,
25 | }
26 |
27 | var startTime time.Time = time.Now()
28 |
29 | func runApp(cmd *cobra.Command, args []string) {
30 | utils.InitLogger(config.ValueOf.Dev)
31 | log := utils.Logger
32 | mainLogger := log.Named("Main")
33 | mainLogger.Info("Starting server")
34 | config.Load(log, cmd)
35 | router := getRouter(log)
36 |
37 | mainBot, err := bot.StartClient(log)
38 | if err != nil {
39 | log.Panic("Failed to start main bot", zap.Error(err))
40 | }
41 | cache.InitCache(log)
42 | workers, err := bot.StartWorkers(log)
43 | if err != nil {
44 | log.Panic("Failed to start workers", zap.Error(err))
45 | return
46 | }
47 | workers.AddDefaultClient(mainBot, mainBot.Self)
48 | bot.StartUserBot(log)
49 | mainLogger.Info("Server started", zap.Int("port", config.ValueOf.Port))
50 | mainLogger.Info("File Stream Bot", zap.String("version", versionString))
51 | mainLogger.Sugar().Infof("Server is running at %s", config.ValueOf.Host)
52 | err = router.Run(fmt.Sprintf(":%d", config.ValueOf.Port))
53 | if err != nil {
54 | mainLogger.Sugar().Fatalln(err)
55 | }
56 | }
57 |
58 | func getRouter(log *zap.Logger) *gin.Engine {
59 | if config.ValueOf.Dev {
60 | gin.SetMode(gin.DebugMode)
61 | } else {
62 | gin.SetMode(gin.ReleaseMode)
63 | }
64 | router := gin.Default()
65 | router.Use(gin.ErrorLogger())
66 | router.GET("/", func(ctx *gin.Context) {
67 | ctx.JSON(http.StatusOK, types.RootResponse{
68 | Message: "Server is running.",
69 | Ok: true,
70 | Uptime: utils.TimeFormat(uint64(time.Since(startTime).Seconds())),
71 | Version: versionString,
72 | })
73 | })
74 | routes.Load(log, router)
75 | return router
76 | }
77 |
--------------------------------------------------------------------------------
/internal/routes/stream.go:
--------------------------------------------------------------------------------
1 | package routes
2 |
3 | import (
4 | "EverythingSuckz/fsb/internal/bot"
5 | "EverythingSuckz/fsb/internal/utils"
6 | "fmt"
7 | "io"
8 | "net/http"
9 | "strconv"
10 |
11 | range_parser "github.com/quantumsheep/range-parser"
12 | "go.uber.org/zap"
13 |
14 | "github.com/gin-gonic/gin"
15 | )
16 |
17 | var log *zap.Logger
18 |
19 | func (e *allRoutes) LoadHome(r *Route) {
20 | log = e.log.Named("Stream")
21 | defer log.Info("Loaded stream route")
22 | r.Engine.GET("/stream/:messageID", getStreamRoute)
23 | }
24 |
25 | func getStreamRoute(ctx *gin.Context) {
26 | w := ctx.Writer
27 | r := ctx.Request
28 |
29 | messageIDParm := ctx.Param("messageID")
30 | messageID, err := strconv.Atoi(messageIDParm)
31 | if err != nil {
32 | http.Error(w, err.Error(), http.StatusBadRequest)
33 | return
34 | }
35 |
36 | authHash := ctx.Query("hash")
37 | if authHash == "" {
38 | http.Error(w, "missing hash param", http.StatusBadRequest)
39 | return
40 | }
41 |
42 | ctx.Header("Accept-Ranges", "bytes")
43 | var start, end int64
44 | rangeHeader := r.Header.Get("Range")
45 |
46 | worker := bot.GetNextWorker()
47 |
48 | file, err := utils.FileFromMessage(ctx, worker.Client, messageID)
49 | if err != nil {
50 | http.Error(w, err.Error(), http.StatusBadRequest)
51 | return
52 | }
53 |
54 | expectedHash := utils.PackFile(
55 | file.FileName,
56 | file.FileSize,
57 | file.MimeType,
58 | file.ID,
59 | )
60 | if !utils.CheckHash(authHash, expectedHash) {
61 | http.Error(w, "invalid hash", http.StatusBadRequest)
62 | return
63 | }
64 |
65 | if rangeHeader == "" {
66 | start = 0
67 | end = file.FileSize - 1
68 | w.WriteHeader(http.StatusOK)
69 | } else {
70 | ranges, err := range_parser.Parse(file.FileSize, r.Header.Get("Range"))
71 | if err != nil {
72 | http.Error(w, err.Error(), http.StatusBadRequest)
73 | return
74 | }
75 | start = ranges[0].Start
76 | end = ranges[0].End
77 | ctx.Header("Content-Range", fmt.Sprintf("bytes %d-%d/%d", start, end, file.FileSize))
78 | log.Info("Content-Range", zap.Int64("start", start), zap.Int64("end", end), zap.Int64("fileSize", file.FileSize))
79 | w.WriteHeader(http.StatusPartialContent)
80 | }
81 |
82 | contentLength := end - start + 1
83 | mimeType := file.MimeType
84 |
85 | if mimeType == "" {
86 | mimeType = "application/octet-stream"
87 | }
88 |
89 | ctx.Header("Content-Type", mimeType)
90 | ctx.Header("Content-Length", strconv.FormatInt(contentLength, 10))
91 |
92 | disposition := "inline"
93 |
94 | if ctx.Query("d") == "true" {
95 | disposition = "attachment"
96 | }
97 |
98 | ctx.Header("Content-Disposition", fmt.Sprintf("%s; filename=\"%s\"", disposition, file.FileName))
99 |
100 | if r.Method != "HEAD" {
101 | if err != nil {
102 | http.Error(w, err.Error(), http.StatusInternalServerError)
103 | return
104 | }
105 | lr, _ := utils.NewTelegramReader(ctx, worker.Client, file.Location, start, end, contentLength)
106 | if _, err := io.CopyN(w, lr, contentLength); err != nil {
107 | log.Error("Error while copying stream", zap.Error(err))
108 | }
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/go.mod:
--------------------------------------------------------------------------------
1 | module EverythingSuckz/fsb
2 |
3 | go 1.21.3
4 |
5 | require (
6 | github.com/celestix/gotgproto v1.0.0-beta18
7 | github.com/gin-gonic/gin v1.9.1
8 | github.com/gotd/td v0.105.0
9 | github.com/joho/godotenv v1.5.1
10 | github.com/kelseyhightower/envconfig v1.4.0
11 | github.com/quantumsheep/range-parser v1.1.0
12 | github.com/spf13/cobra v1.8.0
13 | )
14 |
15 | require (
16 | github.com/AnimeKaizoku/cacher v1.0.1 // indirect
17 | github.com/cenkalti/backoff/v4 v4.3.0 // indirect
18 | github.com/cespare/xxhash/v2 v2.2.0 // indirect
19 | github.com/chenzhuoyu/iasm v0.9.1 // indirect
20 | github.com/dustin/go-humanize v1.0.1 // indirect
21 | github.com/glebarez/go-sqlite v1.22.0 // indirect
22 | github.com/glebarez/sqlite v1.11.0 // indirect
23 | github.com/go-faster/errors v0.7.1 // indirect
24 | github.com/go-faster/jx v1.1.0 // indirect
25 | github.com/go-faster/xor v1.0.0 // indirect
26 | github.com/google/uuid v1.6.0 // indirect
27 | github.com/gotd/ige v0.2.2 // indirect
28 | github.com/gotd/neo v0.1.5 // indirect
29 | github.com/inconshreveable/mousetrap v1.1.0 // indirect
30 | github.com/jinzhu/inflection v1.0.0 // indirect
31 | github.com/jinzhu/now v1.1.5 // indirect
32 | github.com/klauspost/compress v1.17.9 // indirect
33 | github.com/ncruces/go-strftime v0.1.9 // indirect
34 | github.com/pkg/errors v0.9.1 // indirect
35 | github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
36 | github.com/segmentio/asm v1.2.0 // indirect
37 | github.com/spf13/pflag v1.0.5 // indirect
38 | go.opentelemetry.io/otel v1.28.0 // indirect
39 | go.opentelemetry.io/otel/trace v1.28.0 // indirect
40 | go.uber.org/atomic v1.11.0 // indirect
41 | go.uber.org/multierr v1.11.0 // indirect
42 | golang.org/x/sync v0.7.0 // indirect
43 | gorm.io/gorm v1.25.11 // indirect
44 | modernc.org/libc v1.55.2 // indirect
45 | modernc.org/mathutil v1.6.0 // indirect
46 | modernc.org/memory v1.8.0 // indirect
47 | modernc.org/sqlite v1.30.2 // indirect
48 | nhooyr.io/websocket v1.8.11 // indirect
49 | rsc.io/qr v0.2.0 // indirect
50 | )
51 |
52 | require (
53 | github.com/bytedance/sonic v1.10.2 // indirect
54 | github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
55 | github.com/coocood/freecache v1.2.4
56 | github.com/gabriel-vasile/mimetype v1.4.3 // indirect
57 | github.com/gin-contrib/sse v0.1.0 // indirect
58 | github.com/go-playground/locales v0.14.1 // indirect
59 | github.com/go-playground/universal-translator v0.18.1 // indirect
60 | github.com/go-playground/validator/v10 v10.18.0 // indirect
61 | github.com/goccy/go-json v0.10.2 // indirect
62 | github.com/gotd/contrib v0.19.0
63 | github.com/json-iterator/go v1.1.12 // indirect
64 | github.com/klauspost/cpuid/v2 v2.2.7 // indirect
65 | github.com/leodido/go-urn v1.4.0 // indirect
66 | github.com/mattn/go-isatty v0.0.20 // indirect
67 | github.com/mdp/qrterminal v1.0.1
68 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
69 | github.com/modern-go/reflect2 v1.0.2 // indirect
70 | github.com/pelletier/go-toml/v2 v2.1.1 // indirect
71 | github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
72 | github.com/ugorji/go/codec v1.2.12 // indirect
73 | go.uber.org/zap v1.27.0
74 | golang.org/x/arch v0.7.0 // indirect
75 | golang.org/x/crypto v0.25.0 // indirect
76 | golang.org/x/net v0.27.0 // indirect
77 | golang.org/x/sys v0.22.0 // indirect
78 | golang.org/x/text v0.16.0 // indirect
79 | golang.org/x/time v0.5.0
80 | google.golang.org/protobuf v1.32.0 // indirect
81 | gopkg.in/natefinch/lumberjack.v2 v2.2.1
82 | gopkg.in/yaml.v3 v3.0.1 // indirect
83 | )
84 |
--------------------------------------------------------------------------------
/internal/utils/reader.go:
--------------------------------------------------------------------------------
1 | package utils
2 |
3 | import (
4 | "context"
5 | "fmt"
6 | "io"
7 |
8 | "github.com/celestix/gotgproto"
9 | "github.com/gotd/td/tg"
10 | "go.uber.org/zap"
11 | )
12 |
13 | type telegramReader struct {
14 | ctx context.Context
15 | log *zap.Logger
16 | client *gotgproto.Client
17 | location *tg.InputDocumentFileLocation
18 | start int64
19 | end int64
20 | next func() ([]byte, error)
21 | buffer []byte
22 | bytesread int64
23 | chunkSize int64
24 | i int64
25 | contentLength int64
26 | }
27 |
28 | func (*telegramReader) Close() error {
29 | return nil
30 | }
31 |
32 | func NewTelegramReader(
33 | ctx context.Context,
34 | client *gotgproto.Client,
35 | location *tg.InputDocumentFileLocation,
36 | start int64,
37 | end int64,
38 | contentLength int64,
39 | ) (io.ReadCloser, error) {
40 |
41 | r := &telegramReader{
42 | ctx: ctx,
43 | log: Logger.Named("telegramReader"),
44 | location: location,
45 | client: client,
46 | start: start,
47 | end: end,
48 | chunkSize: int64(1024 * 1024),
49 | contentLength: contentLength,
50 | }
51 | r.log.Sugar().Debug("Start")
52 | r.next = r.partStream()
53 | return r, nil
54 | }
55 |
56 | func (r *telegramReader) Read(p []byte) (n int, err error) {
57 |
58 | if r.bytesread == r.contentLength {
59 | r.log.Sugar().Debug("EOF (bytesread == contentLength)")
60 | return 0, io.EOF
61 | }
62 |
63 | if r.i >= int64(len(r.buffer)) {
64 | r.buffer, err = r.next()
65 | r.log.Debug("Next Buffer", zap.Int64("len", int64(len(r.buffer))))
66 | if err != nil {
67 | return 0, err
68 | }
69 | if len(r.buffer) == 0 {
70 | r.next = r.partStream()
71 | r.buffer, err = r.next()
72 | if err != nil {
73 | return 0, err
74 | }
75 |
76 | }
77 | r.i = 0
78 | }
79 | n = copy(p, r.buffer[r.i:])
80 | r.i += int64(n)
81 | r.bytesread += int64(n)
82 | return n, nil
83 | }
84 |
85 | func (r *telegramReader) chunk(offset int64, limit int64) ([]byte, error) {
86 |
87 | req := &tg.UploadGetFileRequest{
88 | Offset: offset,
89 | Limit: int(limit),
90 | Location: r.location,
91 | }
92 |
93 | res, err := r.client.API().UploadGetFile(r.ctx, req)
94 |
95 | if err != nil {
96 | return nil, err
97 | }
98 |
99 | switch result := res.(type) {
100 | case *tg.UploadFile:
101 | return result.Bytes, nil
102 | default:
103 | return nil, fmt.Errorf("unexpected type %T", r)
104 | }
105 | }
106 |
107 | func (r *telegramReader) partStream() func() ([]byte, error) {
108 |
109 | start := r.start
110 | end := r.end
111 | offset := start - (start % r.chunkSize)
112 |
113 | firstPartCut := start - offset
114 | lastPartCut := (end % r.chunkSize) + 1
115 | partCount := int((end - offset + r.chunkSize) / r.chunkSize)
116 | currentPart := 1
117 |
118 | readData := func() ([]byte, error) {
119 | if currentPart > partCount {
120 | return make([]byte, 0), nil
121 | }
122 | res, err := r.chunk(offset, r.chunkSize)
123 | if err != nil {
124 | return nil, err
125 | }
126 | if len(res) == 0 {
127 | return res, nil
128 | } else if partCount == 1 {
129 | res = res[firstPartCut:lastPartCut]
130 | } else if currentPart == 1 {
131 | res = res[firstPartCut:]
132 | } else if currentPart == partCount {
133 | res = res[:lastPartCut]
134 | }
135 |
136 | currentPart++
137 | offset += r.chunkSize
138 | r.log.Sugar().Debugf("Part %d/%d", currentPart, partCount)
139 | return res, nil
140 | }
141 | return readData
142 | }
143 |
--------------------------------------------------------------------------------
/internal/bot/userbot.go:
--------------------------------------------------------------------------------
1 | package bot
2 |
3 | import (
4 | "EverythingSuckz/fsb/config"
5 | "errors"
6 |
7 | "github.com/celestix/gotgproto"
8 | "github.com/celestix/gotgproto/sessionMaker"
9 | "github.com/gotd/td/tg"
10 | "go.uber.org/zap"
11 | )
12 |
13 | type UserBotStruct struct {
14 | log *zap.Logger
15 | client *gotgproto.Client
16 | }
17 |
18 | var UserBot *UserBotStruct = &UserBotStruct{}
19 |
20 | func StartUserBot(l *zap.Logger) {
21 | log := l.Named("USERBOT")
22 | if config.ValueOf.UserSession == "" {
23 | log.Warn("User session is empty")
24 | return
25 | }
26 | log.Sugar().Infoln("Starting userbot")
27 | client, err := gotgproto.NewClient(
28 | int(config.ValueOf.ApiID),
29 | config.ValueOf.ApiHash,
30 | gotgproto.ClientTypePhone(""),
31 | &gotgproto.ClientOpts{
32 | Session: sessionMaker.PyrogramSession(config.ValueOf.UserSession),
33 | DisableCopyright: true,
34 | },
35 | )
36 | if err != nil {
37 | log.Error("Failed to start userbot", zap.Error(err))
38 | return
39 | }
40 | UserBot.log = log
41 | UserBot.client = client
42 | log.Info("Userbot started", zap.String("username", client.Self.Username), zap.String("FirstName", client.Self.FirstName), zap.String("LastName", client.Self.LastName))
43 | if err := UserBot.AddBotsAsAdmins(); err != nil {
44 | log.Error("Failed to add bots as admins", zap.Error(err))
45 | return
46 | }
47 | }
48 |
49 | func (u *UserBotStruct) AddBotsAsAdmins() error {
50 | u.log.Info("Preparing to add bots as admins")
51 | ctx := u.client.CreateContext()
52 | channel := config.ValueOf.LogChannelID
53 | channelInfos, err := u.client.API().ChannelsGetChannels(
54 | ctx,
55 | []tg.InputChannelClass{
56 | &tg.InputChannel{
57 | ChannelID: channel,
58 | },
59 | },
60 | )
61 | if err != nil {
62 | u.log.Error("Failed to get channel info", zap.Error(err))
63 | return errors.New("failed to get channel info")
64 | }
65 | if len(channelInfos.GetChats()) == 0 {
66 | return errors.New("no channels found")
67 | }
68 | inputChannel := channelInfos.GetChats()[0].(*tg.Channel).AsInput()
69 | currentAdmins := []int64{}
70 | admins, err := u.client.API().ChannelsGetParticipants(ctx, &tg.ChannelsGetParticipantsRequest{
71 | Channel: inputChannel,
72 | Filter: &tg.ChannelParticipantsAdmins{},
73 | Offset: 0,
74 | Limit: 100,
75 | })
76 | if err != nil {
77 | u.log.Error("Failed to get admins", zap.Error(err))
78 | return err
79 | }
80 | for _, admin := range admins.(*tg.ChannelsChannelParticipants).Participants {
81 | if user, ok := admin.(*tg.ChannelParticipantAdmin); ok {
82 | currentAdmins = append(currentAdmins, user.UserID)
83 | }
84 | }
85 | for _, bot := range Workers.Bots {
86 | isAdmin := false
87 | for _, admin := range currentAdmins {
88 | if admin == bot.Self.ID {
89 | u.log.Sugar().Infof("Bot @%s is already an admin", bot.Self.Username)
90 | isAdmin = true
91 | continue
92 | }
93 | }
94 | if isAdmin {
95 | continue
96 | }
97 | botInfo, err := ctx.ResolveUsername(bot.Self.Username)
98 | if err != nil {
99 | u.log.Warn(err.Error())
100 | }
101 | _, err = u.client.API().ChannelsEditAdmin(
102 | u.client.CreateContext().Context,
103 | &tg.ChannelsEditAdminRequest{
104 | Channel: inputChannel,
105 | UserID: botInfo.GetInputUser(),
106 | AdminRights: tg.ChatAdminRights{
107 | PostMessages: true,
108 | },
109 | Rank: "admin",
110 | },
111 | )
112 | if err != nil {
113 | u.log.Sugar().Warnf("Failed to add @%s as admin", bot.Self.Username)
114 | u.log.Warn(err.Error())
115 | }
116 | u.log.Sugar().Infof("Added @%s as admin", bot.Self.Username)
117 | }
118 | return nil
119 | }
120 |
--------------------------------------------------------------------------------
/internal/commands/stream.go:
--------------------------------------------------------------------------------
1 | package commands
2 |
3 | import (
4 | "fmt"
5 | "strings"
6 |
7 | "EverythingSuckz/fsb/config"
8 | "EverythingSuckz/fsb/internal/utils"
9 |
10 | "github.com/celestix/gotgproto/dispatcher"
11 | "github.com/celestix/gotgproto/dispatcher/handlers"
12 | "github.com/celestix/gotgproto/ext"
13 | "github.com/celestix/gotgproto/storage"
14 | "github.com/celestix/gotgproto/types"
15 | "github.com/gotd/td/telegram/message/styling"
16 | "github.com/gotd/td/tg"
17 | )
18 |
19 | func (m *command) LoadStream(dispatcher dispatcher.Dispatcher) {
20 | log := m.log.Named("start")
21 | defer log.Sugar().Info("Loaded")
22 | dispatcher.AddHandler(
23 | handlers.NewMessage(nil, sendLink),
24 | )
25 | }
26 |
27 | func supportedMediaFilter(m *types.Message) (bool, error) {
28 | if not := m.Media == nil; not {
29 | return false, dispatcher.EndGroups
30 | }
31 | switch m.Media.(type) {
32 | case *tg.MessageMediaDocument:
33 | return true, nil
34 | case *tg.MessageMediaPhoto:
35 | return false, nil
36 | case tg.MessageMediaClass:
37 | return false, dispatcher.EndGroups
38 | default:
39 | return false, nil
40 | }
41 | }
42 |
43 | func sendLink(ctx *ext.Context, u *ext.Update) error {
44 | chatId := u.EffectiveChat().GetID()
45 | peerChatId := ctx.PeerStorage.GetPeerById(chatId)
46 | if peerChatId.Type != int(storage.TypeUser) {
47 | return dispatcher.EndGroups
48 | }
49 | if len(config.ValueOf.AllowedUsers) != 0 && !utils.Contains(config.ValueOf.AllowedUsers, chatId) {
50 | ctx.Reply(u, "You are not allowed to use this bot.", nil)
51 | return dispatcher.EndGroups
52 | }
53 | supported, err := supportedMediaFilter(u.EffectiveMessage)
54 | if err != nil {
55 | return err
56 | }
57 | if !supported {
58 | ctx.Reply(u, "Sorry, this message type is unsupported.", nil)
59 | return dispatcher.EndGroups
60 | }
61 | update, err := utils.ForwardMessages(ctx, chatId, config.ValueOf.LogChannelID, u.EffectiveMessage.ID)
62 | if err != nil {
63 | utils.Logger.Sugar().Error(err)
64 | ctx.Reply(u, fmt.Sprintf("Error - %s", err.Error()), nil)
65 | return dispatcher.EndGroups
66 | }
67 | messageID := update.Updates[0].(*tg.UpdateMessageID).ID
68 | if err != nil {
69 | utils.Logger.Sugar().Error(err)
70 | ctx.Reply(u, fmt.Sprintf("Error - %s", err.Error()), nil)
71 | return dispatcher.EndGroups
72 | }
73 | doc := update.Updates[1].(*tg.UpdateNewChannelMessage).Message.(*tg.Message).Media
74 | file, err := utils.FileFromMedia(doc)
75 | if err != nil {
76 | ctx.Reply(u, fmt.Sprintf("Error - %s", err.Error()), nil)
77 | return dispatcher.EndGroups
78 | }
79 | fullHash := utils.PackFile(
80 | file.FileName,
81 | file.FileSize,
82 | file.MimeType,
83 | file.ID,
84 | )
85 | hash := utils.GetShortHash(fullHash)
86 | link := fmt.Sprintf("%s/stream/%d?hash=%s", config.ValueOf.Host, messageID, hash)
87 | text := []styling.StyledTextOption{styling.Code(link)}
88 | row := tg.KeyboardButtonRow{
89 | Buttons: []tg.KeyboardButtonClass{
90 | &tg.KeyboardButtonURL{
91 | Text: "Download",
92 | URL: link + "&d=true",
93 | },
94 | },
95 | }
96 | if strings.Contains(file.MimeType, "video") || strings.Contains(file.MimeType, "audio") || strings.Contains(file.MimeType, "pdf") {
97 | row.Buttons = append(row.Buttons, &tg.KeyboardButtonURL{
98 | Text: "Stream",
99 | URL: link,
100 | })
101 | }
102 | markup := &tg.ReplyInlineMarkup{
103 | Rows: []tg.KeyboardButtonRow{row},
104 | }
105 | if strings.Contains(link, "http://localhost") {
106 | _, err = ctx.Reply(u, text, &ext.ReplyOpts{
107 | NoWebpage: false,
108 | ReplyToMessageId: u.EffectiveMessage.ID,
109 | })
110 | } else {
111 | _, err = ctx.Reply(u, text, &ext.ReplyOpts{
112 | Markup: markup,
113 | NoWebpage: false,
114 | ReplyToMessageId: u.EffectiveMessage.ID,
115 | })
116 | }
117 | if err != nil {
118 | utils.Logger.Sugar().Error(err)
119 | ctx.Reply(u, fmt.Sprintf("Error - %s", err.Error()), nil)
120 | }
121 | return dispatcher.EndGroups
122 | }
123 |
--------------------------------------------------------------------------------
/pkg/qrlogin/qrcode.go:
--------------------------------------------------------------------------------
1 | // This file is a part of EverythingSuckz/TG-FileStreamBot
2 | // And is licenced under the Affero General Public License.
3 | // Any distributions of this code MUST be accompanied by a copy of the AGPL
4 | // with proper attribution to the original author(s).
5 |
6 | package qrlogin
7 |
8 | import (
9 | "bufio"
10 | "context"
11 | "encoding/json"
12 | "errors"
13 | "fmt"
14 | "os"
15 | "runtime"
16 | "strings"
17 | "time"
18 |
19 | "github.com/gotd/td/session"
20 | "github.com/gotd/td/telegram"
21 | "github.com/gotd/td/telegram/auth/qrlogin"
22 | "github.com/gotd/td/tg"
23 | "github.com/gotd/td/tgerr"
24 | "github.com/mdp/qrterminal"
25 | )
26 |
27 | type CustomWriter struct {
28 | LineLength int
29 | }
30 |
31 | func (w *CustomWriter) Write(p []byte) (n int, err error) {
32 | for _, c := range p {
33 | if c == '\n' {
34 | w.LineLength++
35 | }
36 | }
37 | return os.Stdout.Write(p)
38 | }
39 |
40 | func printQrCode(data string, writer *CustomWriter) {
41 | qrterminal.GenerateHalfBlock(data, qrterminal.L, writer)
42 | }
43 |
44 | func clearQrCode(writer *CustomWriter) {
45 | for i := 0; i < writer.LineLength; i++ {
46 | fmt.Printf("\033[F\033[K")
47 | }
48 | writer.LineLength = 0
49 | }
50 |
51 | func GenerateQRSession(apiId int, apiHash string) error {
52 | ctx, cancel := context.WithCancel(context.Background())
53 | defer cancel()
54 | fmt.Println("Generating QR session...")
55 | reader := bufio.NewReader(os.Stdin)
56 | dispatcher := tg.NewUpdateDispatcher()
57 | loggedIn := qrlogin.OnLoginToken(dispatcher)
58 | sessionStorage := &session.StorageMemory{}
59 | client := telegram.NewClient(apiId, apiHash, telegram.Options{
60 | UpdateHandler: dispatcher,
61 | SessionStorage: sessionStorage,
62 | Device: telegram.DeviceConfig{
63 | DeviceModel: "Pyrogram",
64 | SystemVersion: runtime.GOOS,
65 | AppVersion: "2.0",
66 | },
67 | })
68 | var stringSession string
69 | qrWriter := &CustomWriter{}
70 | tickerCtx, cancelTicker := context.WithCancel(context.Background())
71 | err := client.Run(ctx, func(ctx context.Context) error {
72 | authorization, err := client.QR().Auth(ctx, loggedIn, func(ctx context.Context, token qrlogin.Token) error {
73 | if qrWriter.LineLength == 0 {
74 | fmt.Printf("\033[F\033[K")
75 | }
76 | clearQrCode(qrWriter)
77 | printQrCode(token.URL(), qrWriter)
78 | qrWriter.Write([]byte("\nTo log in, Open your Telegram app and go to Settings > Devices > Scan QR and scan the QR code.\n"))
79 | go func(ctx context.Context) {
80 | ticker := time.NewTicker(1 * time.Second)
81 | defer ticker.Stop()
82 | for {
83 | select {
84 | case <-ctx.Done():
85 | return
86 | case <-ticker.C:
87 | expiresIn := time.Until(token.Expires())
88 | if expiresIn <= 0 {
89 | return
90 | }
91 | fmt.Printf("\rThis code expires in %s", expiresIn.Truncate(time.Second))
92 | }
93 | }
94 | }(tickerCtx)
95 | return nil
96 | })
97 | if err != nil {
98 | if tgerr.Is(err, "SESSION_PASSWORD_NEEDED") {
99 | cancelTicker()
100 | fmt.Println("\n2FA password is required, enter it below: ")
101 | passkey, _ := reader.ReadString('\n')
102 | strippedPasskey := strings.TrimSpace(passkey)
103 | authorization, err = client.Auth().Password(ctx, strippedPasskey)
104 | if err != nil {
105 | if err.Error() == "invalid password" {
106 | fmt.Println("Invalid password, please try again.")
107 | }
108 | fmt.Println("Error while logging in: ", err)
109 | return nil
110 | }
111 | }
112 | }
113 | if authorization == nil {
114 | cancel()
115 | return errors.New("authorization is nil")
116 | }
117 | user, err := client.Self(ctx)
118 | if err != nil {
119 | return err
120 | }
121 | if user.Username == "" {
122 | fmt.Println("Logged in as ", user.FirstName, user.LastName)
123 | } else {
124 | fmt.Println("Logged in as @", user.Username)
125 | }
126 | res, _ := sessionStorage.LoadSession(ctx)
127 | type jsonDataStruct struct {
128 | Version int
129 | Data session.Data
130 | }
131 | var jsonData jsonDataStruct
132 | json.Unmarshal(res, &jsonData)
133 | stringSession, err = EncodeToPyrogramSession(&jsonData.Data, int32(apiId))
134 | if err != nil {
135 | return err
136 | }
137 | fmt.Println("Your pyrogram session string:", stringSession)
138 | client.API().MessagesSendMessage(
139 | ctx,
140 | &tg.MessagesSendMessageRequest{
141 | NoWebpage: true,
142 | Peer: &tg.InputPeerSelf{},
143 | Message: "Your pyrogram session string: " + stringSession,
144 | },
145 | )
146 | return nil
147 | })
148 | if err != nil {
149 | return err
150 | }
151 | return nil
152 | }
153 |
--------------------------------------------------------------------------------
/internal/bot/workers.go:
--------------------------------------------------------------------------------
1 | package bot
2 |
3 | import (
4 | "EverythingSuckz/fsb/config"
5 | "context"
6 | "fmt"
7 | "os"
8 | "path/filepath"
9 | "sync"
10 | "sync/atomic"
11 | "time"
12 |
13 | "github.com/celestix/gotgproto"
14 | "github.com/celestix/gotgproto/sessionMaker"
15 | "github.com/glebarez/sqlite"
16 | "github.com/gotd/td/tg"
17 | "go.uber.org/zap"
18 | )
19 |
20 | type Worker struct {
21 | ID int
22 | Client *gotgproto.Client
23 | Self *tg.User
24 | log *zap.Logger
25 | }
26 |
27 | func (w *Worker) String() string {
28 | return fmt.Sprintf("{Worker (%d|@%s)}", w.ID, w.Self.Username)
29 | }
30 |
31 | type BotWorkers struct {
32 | Bots []*Worker
33 | starting int
34 | index int
35 | mut sync.Mutex
36 | log *zap.Logger
37 | }
38 |
39 | var Workers *BotWorkers = &BotWorkers{
40 | log: nil,
41 | Bots: make([]*Worker, 0),
42 | }
43 |
44 | func (w *BotWorkers) Init(log *zap.Logger) {
45 | w.log = log.Named("Workers")
46 | }
47 |
48 | func (w *BotWorkers) AddDefaultClient(client *gotgproto.Client, self *tg.User) {
49 | if w.Bots == nil {
50 | w.Bots = make([]*Worker, 0)
51 | }
52 | w.incStarting()
53 | w.Bots = append(w.Bots, &Worker{
54 | Client: client,
55 | ID: w.starting,
56 | Self: self,
57 | log: w.log,
58 | })
59 | w.log.Sugar().Info("Default bot loaded")
60 | }
61 |
62 | func (w *BotWorkers) incStarting() {
63 | w.mut.Lock()
64 | defer w.mut.Unlock()
65 | w.starting++
66 | }
67 |
68 | func (w *BotWorkers) Add(token string) (err error) {
69 | w.incStarting()
70 | var botID int = w.starting
71 | client, err := startWorker(w.log, token, botID)
72 | if err != nil {
73 | return err
74 | }
75 | w.log.Sugar().Infof("Bot @%s loaded with ID %d", client.Self.Username, botID)
76 | w.Bots = append(w.Bots, &Worker{
77 | Client: client,
78 | ID: botID,
79 | Self: client.Self,
80 | log: w.log,
81 | })
82 | return nil
83 | }
84 |
85 | func GetNextWorker() *Worker {
86 | Workers.mut.Lock()
87 | defer Workers.mut.Unlock()
88 | index := (Workers.index + 1) % len(Workers.Bots)
89 | Workers.index = index
90 | worker := Workers.Bots[index]
91 | Workers.log.Sugar().Debugf("Using worker %d", worker.ID)
92 | return worker
93 | }
94 |
95 | func StartWorkers(log *zap.Logger) (*BotWorkers, error) {
96 | Workers.Init(log)
97 |
98 | if len(config.ValueOf.MultiTokens) == 0 {
99 | Workers.log.Sugar().Info("No worker bot tokens provided, skipping worker initialization")
100 | return Workers, nil
101 | }
102 | Workers.log.Sugar().Info("Starting")
103 | if config.ValueOf.UseSessionFile {
104 | Workers.log.Sugar().Info("Using session file for workers")
105 | newpath := filepath.Join(".", "sessions")
106 | if err := os.MkdirAll(newpath, os.ModePerm); err != nil {
107 | Workers.log.Error("Failed to create sessions directory", zap.Error(err))
108 | return nil, err
109 | }
110 | }
111 |
112 | var wg sync.WaitGroup
113 | var successfulStarts int32
114 | totalBots := len(config.ValueOf.MultiTokens)
115 |
116 | for i := 0; i < totalBots; i++ {
117 | wg.Add(1)
118 | go func(i int) {
119 | defer wg.Done()
120 |
121 | ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
122 | defer cancel()
123 |
124 | done := make(chan error, 1)
125 | go func() {
126 | err := Workers.Add(config.ValueOf.MultiTokens[i])
127 | done <- err
128 | }()
129 |
130 | select {
131 | case err := <-done:
132 | if err != nil {
133 | Workers.log.Error("Failed to start worker", zap.Int("index", i), zap.Error(err))
134 | } else {
135 | atomic.AddInt32(&successfulStarts, 1)
136 | }
137 | case <-ctx.Done():
138 | Workers.log.Error("Timed out starting worker", zap.Int("index", i))
139 | }
140 | }(i)
141 | }
142 |
143 | wg.Wait() // Wait for all goroutines to finish
144 | Workers.log.Sugar().Infof("Successfully started %d/%d bots", successfulStarts, totalBots)
145 | return Workers, nil
146 | }
147 |
148 | func startWorker(l *zap.Logger, botToken string, index int) (*gotgproto.Client, error) {
149 | log := l.Named("Worker").Sugar()
150 | log.Infof("Starting worker with index - %d", index)
151 | var sessionType sessionMaker.SessionConstructor
152 | if config.ValueOf.UseSessionFile {
153 | sessionType = sessionMaker.SqlSession(sqlite.Open(fmt.Sprintf("sessions/worker-%d.session", index)))
154 | } else {
155 | sessionType = sessionMaker.SimpleSession()
156 | }
157 | client, err := gotgproto.NewClient(
158 | int(config.ValueOf.ApiID),
159 | config.ValueOf.ApiHash,
160 | gotgproto.ClientTypeBot(botToken),
161 | &gotgproto.ClientOpts{
162 | Session: sessionType,
163 | DisableCopyright: true,
164 | Middlewares: GetFloodMiddleware(log.Desugar()),
165 | },
166 | )
167 | if err != nil {
168 | return nil, err
169 | }
170 | return client, nil
171 | }
172 |
--------------------------------------------------------------------------------
/internal/utils/helpers.go:
--------------------------------------------------------------------------------
1 | package utils
2 |
3 | import (
4 | "EverythingSuckz/fsb/config"
5 | "EverythingSuckz/fsb/internal/cache"
6 | "EverythingSuckz/fsb/internal/types"
7 | "context"
8 | "errors"
9 | "fmt"
10 | "math/rand"
11 |
12 | "github.com/celestix/gotgproto"
13 | "github.com/celestix/gotgproto/ext"
14 | "github.com/celestix/gotgproto/storage"
15 | "github.com/gotd/td/tg"
16 | "go.uber.org/zap"
17 | )
18 |
19 | // https://stackoverflow.com/a/70802740/15807350
20 | func Contains[T comparable](s []T, e T) bool {
21 | for _, v := range s {
22 | if v == e {
23 | return true
24 | }
25 | }
26 | return false
27 | }
28 |
29 | func GetTGMessage(ctx context.Context, client *gotgproto.Client, messageID int) (*tg.Message, error) {
30 | inputMessageID := tg.InputMessageClass(&tg.InputMessageID{ID: messageID})
31 | channel, err := GetLogChannelPeer(ctx, client.API(), client.PeerStorage)
32 | if err != nil {
33 | return nil, err
34 | }
35 | messageRequest := tg.ChannelsGetMessagesRequest{Channel: channel, ID: []tg.InputMessageClass{inputMessageID}}
36 | res, err := client.API().ChannelsGetMessages(ctx, &messageRequest)
37 | if err != nil {
38 | return nil, err
39 | }
40 | messages := res.(*tg.MessagesChannelMessages)
41 | message := messages.Messages[0]
42 | if _, ok := message.(*tg.Message); ok {
43 | return message.(*tg.Message), nil
44 | } else {
45 | return nil, fmt.Errorf("this file was deleted")
46 | }
47 | }
48 |
49 | func FileFromMedia(media tg.MessageMediaClass) (*types.File, error) {
50 | switch media := media.(type) {
51 | case *tg.MessageMediaDocument:
52 | document, ok := media.Document.AsNotEmpty()
53 | if !ok {
54 | return nil, fmt.Errorf("unexpected type %T", media)
55 | }
56 | var fileName string
57 | for _, attribute := range document.Attributes {
58 | if name, ok := attribute.(*tg.DocumentAttributeFilename); ok {
59 | fileName = name.FileName
60 | break
61 | }
62 | }
63 | return &types.File{
64 | Location: document.AsInputDocumentFileLocation(),
65 | FileSize: document.Size,
66 | FileName: fileName,
67 | MimeType: document.MimeType,
68 | ID: document.ID,
69 | }, nil
70 | // TODO: add photo support
71 | }
72 | return nil, fmt.Errorf("unexpected type %T", media)
73 | }
74 |
75 | func FileFromMessage(ctx context.Context, client *gotgproto.Client, messageID int) (*types.File, error) {
76 | key := fmt.Sprintf("file:%d:%d", messageID, client.Self.ID)
77 | log := Logger.Named("GetMessageMedia")
78 | var cachedMedia types.File
79 | err := cache.GetCache().Get(key, &cachedMedia)
80 | if err == nil {
81 | log.Debug("Using cached media message properties", zap.Int("messageID", messageID), zap.Int64("clientID", client.Self.ID))
82 | return &cachedMedia, nil
83 | }
84 | log.Debug("Fetching file properties from message ID", zap.Int("messageID", messageID), zap.Int64("clientID", client.Self.ID))
85 | message, err := GetTGMessage(ctx, client, messageID)
86 | if err != nil {
87 | return nil, err
88 | }
89 | file, err := FileFromMedia(message.Media)
90 | if err != nil {
91 | return nil, err
92 | }
93 | err = cache.GetCache().Set(
94 | key,
95 | file,
96 | 3600,
97 | )
98 | if err != nil {
99 | return nil, err
100 | }
101 | return file, nil
102 | // TODO: add photo support
103 | }
104 |
105 | func GetLogChannelPeer(ctx context.Context, api *tg.Client, peerStorage *storage.PeerStorage) (*tg.InputChannel, error) {
106 | cachedInputPeer := peerStorage.GetInputPeerById(config.ValueOf.LogChannelID)
107 |
108 | switch peer := cachedInputPeer.(type) {
109 | case *tg.InputPeerEmpty:
110 | break
111 | case *tg.InputPeerChannel:
112 | return &tg.InputChannel{
113 | ChannelID: peer.ChannelID,
114 | AccessHash: peer.AccessHash,
115 | }, nil
116 | default:
117 | return nil, errors.New("unexpected type of input peer")
118 | }
119 | inputChannel := &tg.InputChannel{
120 | ChannelID: config.ValueOf.LogChannelID,
121 | }
122 | channels, err := api.ChannelsGetChannels(ctx, []tg.InputChannelClass{inputChannel})
123 | if err != nil {
124 | return nil, err
125 | }
126 | if len(channels.GetChats()) == 0 {
127 | return nil, errors.New("no channels found")
128 | }
129 | channel, ok := channels.GetChats()[0].(*tg.Channel)
130 | if !ok {
131 | return nil, errors.New("type assertion to *tg.Channel failed")
132 | }
133 | // Bruh, I literally have to call library internal functions at this point
134 | peerStorage.AddPeer(channel.GetID(), channel.AccessHash, storage.TypeChannel, "")
135 | return channel.AsInput(), nil
136 | }
137 |
138 | func ForwardMessages(ctx *ext.Context, fromChatId, toChatId int64, messageID int) (*tg.Updates, error) {
139 | fromPeer := ctx.PeerStorage.GetInputPeerById(fromChatId)
140 | if fromPeer.Zero() {
141 | return nil, fmt.Errorf("fromChatId: %d is not a valid peer", fromChatId)
142 | }
143 | toPeer, err := GetLogChannelPeer(ctx, ctx.Raw, ctx.PeerStorage)
144 | if err != nil {
145 | return nil, err
146 | }
147 | update, err := ctx.Raw.MessagesForwardMessages(ctx, &tg.MessagesForwardMessagesRequest{
148 | RandomID: []int64{rand.Int63()},
149 | FromPeer: fromPeer,
150 | ID: []int{messageID},
151 | ToPeer: &tg.InputPeerChannel{ChannelID: toPeer.ChannelID, AccessHash: toPeer.AccessHash},
152 | })
153 | if err != nil {
154 | return nil, err
155 | }
156 | return update.(*tg.Updates), nil
157 | }
158 |
--------------------------------------------------------------------------------
/config/config.go:
--------------------------------------------------------------------------------
1 | package config
2 |
3 | import (
4 | "errors"
5 | "io"
6 | "net"
7 | "net/http"
8 | "os"
9 | "path/filepath"
10 | "reflect"
11 | "regexp"
12 | "strconv"
13 | "strings"
14 |
15 | "github.com/joho/godotenv"
16 | "github.com/kelseyhightower/envconfig"
17 | "github.com/spf13/cobra"
18 | "go.uber.org/zap"
19 | )
20 |
21 | var ValueOf = &config{}
22 |
23 | type allowedUsers []int64
24 |
25 | func (au *allowedUsers) Decode(value string) error {
26 | if value == "" {
27 | return nil
28 | }
29 | ids := strings.Split(string(value), ",")
30 | for _, id := range ids {
31 | idInt, err := strconv.ParseInt(id, 10, 64)
32 | if err != nil {
33 | return err
34 | }
35 | *au = append(*au, idInt)
36 | }
37 | return nil
38 | }
39 |
40 | type config struct {
41 | ApiID int32 `envconfig:"API_ID" required:"true"`
42 | ApiHash string `envconfig:"API_HASH" required:"true"`
43 | BotToken string `envconfig:"BOT_TOKEN" required:"true"`
44 | LogChannelID int64 `envconfig:"LOG_CHANNEL" required:"true"`
45 | Dev bool `envconfig:"DEV" default:"false"`
46 | Port int `envconfig:"PORT" default:"8080"`
47 | Host string `envconfig:"HOST" default:""`
48 | HashLength int `envconfig:"HASH_LENGTH" default:"6"`
49 | UseSessionFile bool `envconfig:"USE_SESSION_FILE" default:"true"`
50 | UserSession string `envconfig:"USER_SESSION"`
51 | UsePublicIP bool `envconfig:"USE_PUBLIC_IP" default:"false"`
52 | AllowedUsers allowedUsers `envconfig:"ALLOWED_USERS"`
53 | MultiTokens []string
54 | }
55 |
56 | var botTokenRegex = regexp.MustCompile(`MULTI\_TOKEN\d+=(.*)`)
57 |
58 | func (c *config) loadFromEnvFile(log *zap.Logger) {
59 | envPath := filepath.Clean("fsb.env")
60 | log.Sugar().Infof("Trying to load ENV vars from %s", envPath)
61 | err := godotenv.Load(envPath)
62 | if err != nil {
63 | if os.IsNotExist(err) {
64 | log.Sugar().Errorf("ENV file not found: %s", envPath)
65 | log.Sugar().Info("Please create fsb.env file")
66 | log.Sugar().Info("For more info, refer: https://github.com/EverythingSuckz/TG-FileStreamBot/tree/golang#setting-up-things")
67 | log.Sugar().Info("Please ignore this message if you are hosting it in a service like Heroku or other alternatives.")
68 | } else {
69 | log.Fatal("Unknown error while parsing env file.", zap.Error(err))
70 | }
71 | }
72 | }
73 |
74 | func SetFlagsFromConfig(cmd *cobra.Command) {
75 | cmd.Flags().Int32("api-id", ValueOf.ApiID, "Telegram API ID")
76 | cmd.Flags().String("api-hash", ValueOf.ApiHash, "Telegram API Hash")
77 | cmd.Flags().String("bot-token", ValueOf.BotToken, "Telegram Bot Token")
78 | cmd.Flags().Int64("log-channel", ValueOf.LogChannelID, "Telegram Log Channel ID")
79 | cmd.Flags().Bool("dev", ValueOf.Dev, "Enable development mode")
80 | cmd.Flags().IntP("port", "p", ValueOf.Port, "Server port")
81 | cmd.Flags().String("host", ValueOf.Host, "Server host that will be included in links")
82 | cmd.Flags().Int("hash-length", ValueOf.HashLength, "Hash length in links")
83 | cmd.Flags().Bool("use-session-file", ValueOf.UseSessionFile, "Use session files")
84 | cmd.Flags().String("user-session", ValueOf.UserSession, "Pyrogram user session")
85 | cmd.Flags().Bool("use-public-ip", ValueOf.UsePublicIP, "Use public IP instead of local IP")
86 | cmd.Flags().String("multi-token-txt-file", "", "Multi token txt file (Not implemented)")
87 | }
88 |
89 | func (c *config) loadConfigFromArgs(log *zap.Logger, cmd *cobra.Command) {
90 | apiID, _ := cmd.Flags().GetInt32("api-id")
91 | if apiID != 0 {
92 | os.Setenv("API_ID", strconv.Itoa(int(apiID)))
93 | }
94 | apiHash, _ := cmd.Flags().GetString("api-hash")
95 | if apiHash != "" {
96 | os.Setenv("API_HASH", apiHash)
97 | }
98 | botToken, _ := cmd.Flags().GetString("bot-token")
99 | if botToken != "" {
100 | os.Setenv("BOT_TOKEN", botToken)
101 | }
102 | logChannelID, _ := cmd.Flags().GetString("log-channel")
103 | if logChannelID != "" {
104 | os.Setenv("LOG_CHANNEL", logChannelID)
105 | }
106 | dev, _ := cmd.Flags().GetBool("dev")
107 | if dev {
108 | os.Setenv("DEV", strconv.FormatBool(dev))
109 | }
110 | port, _ := cmd.Flags().GetInt("port")
111 | if port != 0 {
112 | os.Setenv("PORT", strconv.Itoa(port))
113 | }
114 | host, _ := cmd.Flags().GetString("host")
115 | if host != "" {
116 | os.Setenv("HOST", host)
117 | }
118 | hashLength, _ := cmd.Flags().GetInt("hash-length")
119 | if hashLength != 0 {
120 | os.Setenv("HASH_LENGTH", strconv.Itoa(hashLength))
121 | }
122 | useSessionFile, _ := cmd.Flags().GetBool("use-session-file")
123 | if useSessionFile {
124 | os.Setenv("USE_SESSION_FILE", strconv.FormatBool(useSessionFile))
125 | }
126 | userSession, _ := cmd.Flags().GetString("user-session")
127 | if userSession != "" {
128 | os.Setenv("USER_SESSION", userSession)
129 | }
130 | usePublicIP, _ := cmd.Flags().GetBool("use-public-ip")
131 | if usePublicIP {
132 | os.Setenv("USE_PUBLIC_IP", strconv.FormatBool(usePublicIP))
133 | }
134 | multiTokens, _ := cmd.Flags().GetString("multi-token-txt-file")
135 | if multiTokens != "" {
136 | os.Setenv("MULTI_TOKEN_TXT_FILE", multiTokens)
137 | // TODO: Add support for importing tokens from a separate file
138 | }
139 | }
140 |
141 | func (c *config) setupEnvVars(log *zap.Logger, cmd *cobra.Command) {
142 | c.loadFromEnvFile(log)
143 | c.loadConfigFromArgs(log, cmd)
144 | err := envconfig.Process("", c)
145 | if err != nil {
146 | log.Fatal("Error while parsing env variables", zap.Error(err))
147 | }
148 | var ipBlocked bool
149 | ip, err := getIP(c.UsePublicIP)
150 | if err != nil {
151 | log.Error("Error while getting IP", zap.Error(err))
152 | ipBlocked = true
153 | }
154 | if c.Host == "" {
155 | c.Host = "http://" + ip + ":" + strconv.Itoa(c.Port)
156 | if c.UsePublicIP {
157 | if ipBlocked {
158 | log.Sugar().Warn("Can't get public IP, using local IP")
159 | } else {
160 | log.Sugar().Warn("You are using a public IP, please be aware of the security risks while exposing your IP to the internet.")
161 | log.Sugar().Warn("Use 'HOST' variable to set a domain name")
162 | }
163 | }
164 | log.Sugar().Info("HOST not set, automatically set to " + c.Host)
165 | }
166 | val := reflect.ValueOf(c).Elem()
167 | for _, env := range os.Environ() {
168 | if strings.HasPrefix(env, "MULTI_TOKEN") {
169 | c.MultiTokens = append(c.MultiTokens, botTokenRegex.FindStringSubmatch(env)[1])
170 | }
171 | }
172 | val.FieldByName("MultiTokens").Set(reflect.ValueOf(c.MultiTokens))
173 | }
174 |
175 | func Load(log *zap.Logger, cmd *cobra.Command) {
176 | log = log.Named("Config")
177 | defer log.Info("Loaded config")
178 | ValueOf.setupEnvVars(log, cmd)
179 | ValueOf.LogChannelID = int64(stripInt(log, int(ValueOf.LogChannelID)))
180 | if ValueOf.HashLength == 0 {
181 | log.Sugar().Info("HASH_LENGTH can't be 0, defaulting to 6")
182 | ValueOf.HashLength = 6
183 | }
184 | if ValueOf.HashLength > 32 {
185 | log.Sugar().Info("HASH_LENGTH can't be more than 32, changing to 32")
186 | ValueOf.HashLength = 32
187 | }
188 | if ValueOf.HashLength < 5 {
189 | log.Sugar().Info("HASH_LENGTH can't be less than 5, defaulting to 6")
190 | ValueOf.HashLength = 6
191 | }
192 | }
193 |
194 | func getIP(public bool) (string, error) {
195 | var ip string
196 | var err error
197 | if public {
198 | ip, err = GetPublicIP()
199 | } else {
200 | ip, err = getInternalIP()
201 | }
202 | if ip == "" {
203 | ip = "localhost"
204 | }
205 | if err != nil {
206 | return "localhost", err
207 | }
208 | return ip, nil
209 | }
210 |
211 | // https://stackoverflow.com/a/23558495/15807350
212 | func getInternalIP() (string, error) {
213 | conn, err := net.Dial("udp", "8.8.8.8:80")
214 | if err != nil {
215 | return "", errors.New("no internet connection")
216 | }
217 | defer conn.Close()
218 | localAddr := conn.LocalAddr().(*net.UDPAddr)
219 | return localAddr.IP.String(), nil
220 | }
221 |
222 | func GetPublicIP() (string, error) {
223 | resp, err := http.Get("https://api.ipify.org?format=text")
224 | if err != nil {
225 | return "", err
226 | }
227 | defer resp.Body.Close()
228 | ip, err := io.ReadAll(resp.Body)
229 | if err != nil {
230 | return "", err
231 | }
232 | if !checkIfIpAccessible(string(ip)) {
233 | return string(ip), errors.New("PORT is blocked by firewall")
234 | }
235 | return string(ip), nil
236 | }
237 |
238 | func checkIfIpAccessible(ip string) bool {
239 | conn, err := net.Dial("tcp", ip+":80")
240 | if err != nil {
241 | return false
242 | }
243 | defer conn.Close()
244 | return true
245 | }
246 |
247 | func stripInt(log *zap.Logger, a int) int {
248 | strA := strconv.Itoa(abs(a))
249 | lastDigits := strings.Replace(strA, "100", "", 1)
250 | result, err := strconv.Atoi(lastDigits)
251 | if err != nil {
252 | log.Sugar().Fatalln(err)
253 | return 0
254 | }
255 | return result
256 | }
257 |
258 | func abs(x int) int {
259 | if x < 0 {
260 | return -x
261 | }
262 | return x
263 | }
264 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Telegram File Stream Bot
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | A Telegram bot to generate direct link for your Telegram files.
11 |
12 |
13 |
14 |
15 |
16 |
17 | > [!NOTE]
18 | > Checkout [python branch](https://github.com/EverythingSuckz/TG-FileStreamBot/tree/python) if you are interested in that.
19 |
20 |
21 |
22 |
23 | Table of Contents
24 |
25 | -
26 | How to make your own
27 |
30 |
41 |
42 | -
43 | Setting up Things
44 |
55 |
56 | - Contributing
57 | - Contact me
58 | - Credits
59 |
60 |
61 |
62 |
63 |
64 | ## How to make your own
65 |
66 | ### Deploy to Heroku
67 |
68 | > [!NOTE]
69 | > You'll have to [fork](https://github.com/EverythingSuckz/TG-FileStreamBot/fork) this repository to deploy to Heroku.
70 |
71 | Press the below button to fast deploy to Heroku
72 |
73 | [](https://heroku.com/deploy)
74 |
75 | [Click Here](https://devcenter.heroku.com/articles/config-vars#using-the-heroku-dashboard) to know how to add / edit [environment variables](#required-vars) in Heroku.
76 |
77 |
78 |
79 | ### Download from releases
80 | - Head over to [releases](https://github.com/EverythingSuckz/TG-FileStreamBot/releases) tab, from the *pre release* section, download the one for your platform and architecture.
81 | - Extract the zip file to a folder.
82 | - Create an a file named `fsb.env` and add all the variables there (see `fsb.sample.env` file for reference).
83 | - Give the executable file permission to execute using the command `chmod +x fsb` (Not required for windows).
84 | - Run the bot using `./fsb run` command. ( `./fsb.exe run` for windows)
85 |
86 |
87 |
88 | ### Run using docker-compose
89 |
90 | - Clone the repository
91 | ```sh
92 | git clone https://github.com/EverythingSuckz/TG-FileStreamBot
93 | cd TG-FileStreamBot
94 | ```
95 |
96 | - Create an a file named `fsb.env` and add all the variables there (see `fsb.sample.env` file for reference).
97 |
98 | ```sh
99 | nano fsb.env
100 | ```
101 |
102 | - Build and run the docker-compose file
103 |
104 | ```sh
105 | docker-compose up -d
106 | ```
107 | OR
108 |
109 | ```sh
110 | docker compose up -d
111 | ```
112 |
113 |
114 |
115 | ### Run using docker
116 |
117 | ```sh
118 | docker run --env-file fsb.env ghcr.io/everythingsuckz/fsb:latest
119 | ```
120 | Where `fsb.env` is the environment file containing all the variables.
121 |
122 |
123 |
124 | ### Build from source
125 |
126 | #### Ubuntu
127 |
128 | > [!NOTE]
129 | > Make sure to install go 1.21 or above.
130 | > Refer https://stackoverflow.com/a/17566846/15807350
131 |
132 | ```sh
133 | git clone https://github.com/EverythingSuckz/TG-FileStreamBot
134 | cd TG-FileStreamBot
135 | go build ./cmd/fsb/
136 | chmod +x fsb
137 | mv fsb.sample.env fsb.env
138 | nano fsb.env
139 | # (add your environment variables, see the next section for more info)
140 | ./fsb run
141 | ```
142 |
143 | and to stop the program,
144 | do CTRL+C
145 |
146 | #### Windows
147 |
148 | > [!NOTE]
149 | > Make sure to install go 1.21 or above.
150 |
151 | ```powershell
152 | git clone https://github.com/EverythingSuckz/TG-FileStreamBot
153 | cd TG-FileStreamBot
154 | go build ./cmd/fsb/
155 | Rename-Item -LiteralPath ".\fsb.sample.env" -NewName ".\fsb.env"
156 | notepad fsb.env
157 | # (add your environment variables, see the next section for more info)
158 | .\fsb run
159 | ```
160 |
161 | and to stop the program,
162 | do CTRL+C
163 |
164 | ## Setting up things
165 |
166 | If you're locally hosting, create a file named `fsb.env` in the root directory and add all the variables there.
167 | You may check the `fsb.sample.env`.
168 | An example of `fsb.env` file:
169 |
170 | ```sh
171 | API_ID=452525
172 | API_HASH=esx576f8738x883f3sfzx83
173 | BOT_TOKEN=55838383:yourbottokenhere
174 | LOG_CHANNEL=-10045145224562
175 | PORT=8080
176 | HOST=http://yourserverip
177 | # (if you want to set up multiple bots)
178 | MULTI_TOKEN1=55838373:yourworkerbottokenhere
179 | MULTI_TOKEN2=55838355:yourworkerbottokenhere
180 | ```
181 |
182 | ### Required Vars
183 | Before running the bot, you will need to set up the following mandatory variables:
184 |
185 | - `API_ID` : This is the API ID for your Telegram account, which can be obtained from my.telegram.org.
186 |
187 | - `API_HASH` : This is the API hash for your Telegram account, which can also be obtained from my.telegram.org.
188 |
189 | - `BOT_TOKEN` : This is the bot token for the Telegram Media Streamer Bot, which can be obtained from [@BotFather](https://telegram.dog/BotFather).
190 |
191 | - `LOG_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.
192 |
193 | ### Optional Vars
194 | In addition to the mandatory variables, you can also set the following optional variables:
195 |
196 | - `PORT` : This sets the port that your webapp will listen to. The default value is 8080.
197 |
198 | - `HOST` : A Fully Qualified Domain Name if present or use your server IP. (eg. `https://example.com` or `http://14.1.154.2:8080`)
199 |
200 | - `HASH_LENGTH` : Custom hash length for generated URLs. The hash length must be greater than 5 and less than or equal to 32. The default value is 6.
201 |
202 | - `USE_SESSION_FILE` : Use session files for worker client(s). This speeds up the worker bot startups. (default: `false`)
203 |
204 | - `USER_SESSION` : A pyrogram session string for a user bot. Used for auto adding the bots to `LOG_CHANNEL`. (default: `null`)
205 |
206 | - `ALLOWED_USERS` : A list of user IDs separated by comma (`,`). If this is set, only the users in this list will be able to use the bot. (default: `null`)
207 |
208 |
209 |
210 | ### Use Multiple Bots to speed up
211 |
212 | > [!NOTE]
213 | > **What it multi-client feature and what it does?**
214 | > This feature shares the Telegram API requests between worker bots to speed up download speed when many users are using the server and to avoid the flood limits that are set by Telegram.
215 |
216 | > [!NOTE]
217 | > You can add up to 50 bots since 50 is the max amount of bot admins you can set in a Telegram Channel.
218 |
219 | To enable multi-client, generate new bot tokens and add it as your `fsb.env` with the following key names.
220 |
221 | `MULTI_TOKEN1`: Add your first bot token here.
222 |
223 | `MULTI_TOKEN2`: Add your second bot token here.
224 |
225 | you may also add as many as bots you want. (max limit is 50)
226 | `MULTI_TOKEN3`, `MULTI_TOKEN4`, etc.
227 |
228 | > [!WARNING]
229 | > Don't forget to add all these worker bots to the `LOG_CHANNEL` for the proper functioning
230 |
231 | ### Using user session to auto add bots
232 |
233 | > [!WARNING]
234 | > This might sometimes result in your account getting resticted or banned.
235 | > **Only newly created accounts are prone to this.**
236 |
237 | To use this feature, you need to generate a pyrogram session string for the user account and add it to the `USER_SESSION` variable in the `fsb.env` file.
238 |
239 | #### What it does?
240 |
241 | This feature is used to auto add the worker bots to the `LOG_CHANNEL` when they are started. This is useful when you have a lot of worker bots and you don't want to add them manually to the `LOG_CHANNEL`.
242 |
243 | #### How to generate a session string?
244 |
245 | The easiest way to generate a session string is by running
246 |
247 | ```sh
248 | ./fsb session --api-id --api-hash
249 | ```
250 |
251 |
252 |
253 |
254 |
255 | This will generate a session string for your user account using QR code authentication. Authentication via phone number is not supported yet and will be added in the future.
256 |
257 | ## Contributing
258 |
259 | Feel free to contribute to this project if you have any further ideas
260 |
261 | ## Contact me
262 |
263 | [](https://xn--r1a.click/wrench_labs)
264 | [](https://xn--r1a.click/AlteredVoid)
265 |
266 | You can contact either via my [Telegram Group](https://xn--r1a.click/AlteredVoid) or you can message me on [@EverythingSuckz](https://xn--r1a.click/EverythingSuckz)
267 |
268 |
269 | ## Credits
270 |
271 | - [@celestix](https://github.com/celestix) for [gotgproto](https://github.com/celestix/gotgproto)
272 | - [@divyam234](https://github.com/divyam234/teldrive) for his [Teldrive](https://github.com/divyam234/teldrive) Project
273 |
274 | ## Copyright
275 |
276 | Copyright (C) 2023 [EverythingSuckz](https://github.com/EverythingSuckz) under [GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.en.html).
277 |
278 | TG-FileStreamBot is Free Software: You can use, study share and improve it at your
279 | will. Specifically you can redistribute and/or modify it under the terms of the
280 | [GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.en.html) as
281 | published by the Free Software Foundation, either version 3 of the License, or
282 | (at your option) any later version. Also keep in mind that all the forks of this repository MUST BE OPEN-SOURCE and MUST BE UNDER THE SAME LICENSE.
283 |
--------------------------------------------------------------------------------
/go.sum:
--------------------------------------------------------------------------------
1 | github.com/AnimeKaizoku/cacher v1.0.1 h1:rDjeDphztR4h234mnUxlOQWyYAB63WdzJB9zBg9HVPg=
2 | github.com/AnimeKaizoku/cacher v1.0.1/go.mod h1:jw0de/b0K6W7Y3T9rHCMGVKUf6oG7hENNcssxYcZTCc=
3 | github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
4 | github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM=
5 | github.com/bytedance/sonic v1.10.2 h1:GQebETVBxYB7JGWJtLBi07OVzWwt+8dWA00gEVW2ZFE=
6 | github.com/bytedance/sonic v1.10.2/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4=
7 | github.com/celestix/gotgproto v1.0.0-beta16 h1:xV0h7L1V3DFWJe+wcY7KAtHFuN1RkP07vANHO5fjq9Q=
8 | github.com/celestix/gotgproto v1.0.0-beta16/go.mod h1:Ey7AMTGRCXpG2iWR/eSFWwRrLCrmZ+l7HZq52NLEo7c=
9 | github.com/celestix/gotgproto v1.0.0-beta18 h1:7884H/il+mzNreOQ4SqoMa4S5njt3UmGPKZTxPu38fU=
10 | github.com/celestix/gotgproto v1.0.0-beta18/go.mod h1:osZOlN5irPByA0+3IPsZOH+Ibs0tOMSKmIdgGYEBRgE=
11 | github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM=
12 | github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
13 | github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
14 | github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
15 | github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
16 | github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
17 | github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
18 | github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
19 | github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
20 | github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d h1:77cEq6EriyTZ0g/qfRdp61a3Uu/AWrgIq2s0ClJV1g0=
21 | github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d/go.mod h1:8EPpVsBuRksnlj1mLy4AWzRNQYxauNi62uWcE3to6eA=
22 | github.com/chenzhuoyu/iasm v0.9.0/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog=
23 | github.com/chenzhuoyu/iasm v0.9.1 h1:tUHQJXo3NhBqw6s33wkGn9SP3bvrWLdlVIJ3hQBL7P0=
24 | github.com/chenzhuoyu/iasm v0.9.1/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog=
25 | github.com/coocood/freecache v1.2.4 h1:UdR6Yz/X1HW4fZOuH0Z94KwG851GWOSknua5VUbb/5M=
26 | github.com/coocood/freecache v1.2.4/go.mod h1:RBUWa/Cy+OHdfTGFEhEuE1pMCMX51Ncizj7rthiQ3vk=
27 | github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
28 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
29 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
30 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
31 | github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
32 | github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
33 | github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
34 | github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
35 | github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
36 | github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
37 | github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg=
38 | github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU=
39 | github.com/glebarez/go-sqlite v1.22.0 h1:uAcMJhaA6r3LHMTFgP0SifzgXg46yJkgxqyuyec+ruQ=
40 | github.com/glebarez/go-sqlite v1.22.0/go.mod h1:PlBIdHe0+aUEFn+r2/uthrWq4FxbzugL0L8Li6yQJbc=
41 | github.com/glebarez/sqlite v1.10.0 h1:u4gt8y7OND/cCei/NMHmfbLxF6xP2wgKcT/BJf2pYkc=
42 | github.com/glebarez/sqlite v1.10.0/go.mod h1:IJ+lfSOmiekhQsFTJRx/lHtGYmCdtAiTaf5wI9u5uHA=
43 | github.com/glebarez/sqlite v1.11.0 h1:wSG0irqzP6VurnMEpFGer5Li19RpIRi2qvQz++w0GMw=
44 | github.com/glebarez/sqlite v1.11.0/go.mod h1:h8/o8j5wiAsqSPoWELDUdJXhjAhsVliSn7bWZjOhrgQ=
45 | github.com/go-faster/errors v0.7.1 h1:MkJTnDoEdi9pDabt1dpWf7AA8/BaSYZqibYyhZ20AYg=
46 | github.com/go-faster/errors v0.7.1/go.mod h1:5ySTjWFiphBs07IKuiL69nxdfd5+fzh1u7FPGZP2quo=
47 | github.com/go-faster/jx v1.1.0 h1:ZsW3wD+snOdmTDy9eIVgQdjUpXRRV4rqW8NS3t+20bg=
48 | github.com/go-faster/jx v1.1.0/go.mod h1:vKDNikrKoyUmpzaJ0OkIkRQClNHFX/nF3dnTJZb3skg=
49 | github.com/go-faster/xor v0.3.0/go.mod h1:x5CaDY9UKErKzqfRfFZdfu+OSTfoZny3w5Ak7UxcipQ=
50 | github.com/go-faster/xor v1.0.0 h1:2o8vTOgErSGHP3/7XwA5ib1FTtUsNtwCoLLBjl31X38=
51 | github.com/go-faster/xor v1.0.0/go.mod h1:x5CaDY9UKErKzqfRfFZdfu+OSTfoZny3w5Ak7UxcipQ=
52 | github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
53 | github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
54 | github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
55 | github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
56 | github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
57 | github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
58 | github.com/go-playground/validator/v10 v10.18.0 h1:BvolUXjp4zuvkZ5YN5t7ebzbhlUtPsPm2S9NAZ5nl9U=
59 | github.com/go-playground/validator/v10 v10.18.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
60 | github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
61 | github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
62 | github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
63 | github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
64 | github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
65 | github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26 h1:Xim43kblpZXfIBQsbuBVKCudVG457BR2GZFIz3uw3hQ=
66 | github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26/go.mod h1:dDKJzRmX4S37WGHujM7tX//fmj1uioxKzKxz3lo4HJo=
67 | github.com/google/pprof v0.0.0-20240409012703-83162a5b38cd h1:gbpYu9NMq8jhDVbvlGkMFWCjLFlqqEZjEmObmhUy6Vo=
68 | github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
69 | github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
70 | github.com/gotd/contrib v0.19.0 h1:O6GvMrRVeFslIHLUcpaHVzcl9/5PcgR2jQTIIeTyds0=
71 | github.com/gotd/contrib v0.19.0/go.mod h1:LzPxzRF0FvtpBt/WyODWQnPpk0tm/G9z6RHUoPqMakU=
72 | github.com/gotd/ige v0.2.2 h1:XQ9dJZwBfDnOGSTxKXBGP4gMud3Qku2ekScRjDWWfEk=
73 | github.com/gotd/ige v0.2.2/go.mod h1:tuCRb+Y5Y3eNTo3ypIfNpQ4MFjrnONiL2jN2AKZXmb0=
74 | github.com/gotd/neo v0.1.5 h1:oj0iQfMbGClP8xI59x7fE/uHoTJD7NZH9oV1WNuPukQ=
75 | github.com/gotd/neo v0.1.5/go.mod h1:9A2a4bn9zL6FADufBdt7tZt+WMhvZoc5gWXihOPoiBQ=
76 | github.com/gotd/td v0.97.0 h1:EplGV6M6xFISLktsRFJZKm1NPyPjxR0XK9vbys0i/Qk=
77 | github.com/gotd/td v0.97.0/go.mod h1:6SwTJiw/fkw81QU+WHqB2HZ+38s0UJJH1a2nqwezCfA=
78 | github.com/gotd/td v0.105.0 h1:FjU9pgmL5Qt10+cosPCz4agvQT/hMBz6QMi1fFH7ekY=
79 | github.com/gotd/td v0.105.0/go.mod h1:aVe5/LP/nNIyAqaW3CwB0Ckum+MkcfvazwMOLHV0bqQ=
80 | github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
81 | github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
82 | github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
83 | github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
84 | github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
85 | github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
86 | github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
87 | github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
88 | github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
89 | github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
90 | github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8=
91 | github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg=
92 | github.com/klauspost/compress v1.17.6 h1:60eq2E/jlfwQXtvZEeBUYADs+BwKBWURIY+Gj2eRGjI=
93 | github.com/klauspost/compress v1.17.6/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
94 | github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
95 | github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
96 | github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
97 | github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc=
98 | github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
99 | github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
100 | github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
101 | github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
102 | github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
103 | github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
104 | github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
105 | github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
106 | github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
107 | github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
108 | github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
109 | github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
110 | github.com/mdp/qrterminal v1.0.1 h1:07+fzVDlPuBlXS8tB0ktTAyf+Lp1j2+2zK3fBOL5b7c=
111 | github.com/mdp/qrterminal v1.0.1/go.mod h1:Z33WhxQe9B6CdW37HaVqcRKzP+kByF3q/qLxOGe12xQ=
112 | github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
113 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
114 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
115 | github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
116 | github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
117 | github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4=
118 | github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
119 | github.com/pelletier/go-toml/v2 v2.1.1 h1:LWAJwfNvjQZCFIDKWYQaM62NcYeYViCmWIwmOStowAI=
120 | github.com/pelletier/go-toml/v2 v2.1.1/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
121 | github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
122 | github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
123 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
124 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
125 | github.com/quantumsheep/range-parser v1.1.0 h1:k4f1F58f8FF54FBYc9dYBRM+8JkAxFo11gC3IeMH4rU=
126 | github.com/quantumsheep/range-parser v1.1.0/go.mod h1:acv4Vt2PvpGvRsvGju7Gk2ahKluZJsIUNR69W53J22I=
127 | github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
128 | github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
129 | github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
130 | github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
131 | github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
132 | github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys=
133 | github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs=
134 | github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
135 | github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
136 | github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
137 | github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
138 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
139 | github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
140 | github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
141 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
142 | github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
143 | github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
144 | github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
145 | github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
146 | github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
147 | github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
148 | github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
149 | github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
150 | github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
151 | github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
152 | github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
153 | go.opentelemetry.io/otel v1.23.1 h1:Za4UzOqJYS+MUczKI320AtqZHZb7EqxO00jAHE0jmQY=
154 | go.opentelemetry.io/otel v1.23.1/go.mod h1:Td0134eafDLcTS4y+zQ26GE8u3dEuRBiBCTUIRHaikA=
155 | go.opentelemetry.io/otel v1.28.0 h1:/SqNcYk+idO0CxKEUOtKQClMK/MimZihKYMruSMViUo=
156 | go.opentelemetry.io/otel v1.28.0/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4=
157 | go.opentelemetry.io/otel/trace v1.23.1 h1:4LrmmEd8AU2rFvU1zegmvqW7+kWarxtNOPyeL6HmYY8=
158 | go.opentelemetry.io/otel/trace v1.23.1/go.mod h1:4IpnpJFwr1mo/6HL8XIPJaE9y0+u1KcVmuW7dwFSVrI=
159 | go.opentelemetry.io/otel/trace v1.28.0 h1:GhQ9cUuQGmNDd5BTCP2dAvv75RdMxEfTmYejp+lkx9g=
160 | go.opentelemetry.io/otel/trace v1.28.0/go.mod h1:jPyXzNPg6da9+38HEwElrQiHlVMTnVfM3/yv2OlIHaI=
161 | go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
162 | go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
163 | go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
164 | go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
165 | go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
166 | go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
167 | go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo=
168 | go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so=
169 | go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
170 | go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
171 | golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
172 | golang.org/x/arch v0.7.0 h1:pskyeJh/3AmoQ8CPE95vxHLqp1G1GfGNXTmcl9NEKTc=
173 | golang.org/x/arch v0.7.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
174 | golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo=
175 | golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
176 | golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
177 | golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
178 | golang.org/x/exp v0.0.0-20230116083435-1de6713980de h1:DBWn//IJw30uYCgERoxCg84hWtA97F4wMiKOIh00Uf0=
179 | golang.org/x/exp v0.0.0-20230116083435-1de6713980de/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
180 | golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
181 | golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
182 | golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
183 | golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
184 | golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
185 | golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
186 | golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
187 | golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
188 | golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
189 | golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
190 | golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
191 | golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
192 | golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
193 | golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
194 | golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
195 | golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
196 | golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
197 | golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
198 | golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
199 | golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
200 | golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
201 | google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
202 | google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
203 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
204 | gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
205 | gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
206 | gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
207 | gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
208 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
209 | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
210 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
211 | gorm.io/gorm v1.25.7 h1:VsD6acwRjz2zFxGO50gPO6AkNs7KKnvfzUjHQhZDz/A=
212 | gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
213 | gorm.io/gorm v1.25.11 h1:/Wfyg1B/je1hnDx3sMkX+gAlxrlZpn6X0BXRlwXlvHg=
214 | gorm.io/gorm v1.25.11/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ=
215 | modernc.org/libc v1.41.0 h1:g9YAc6BkKlgORsUWj+JwqoB1wU3o4DE3bM3yvA3k+Gk=
216 | modernc.org/libc v1.41.0/go.mod h1:w0eszPsiXoOnoMJgrXjglgLuDy/bt5RR4y3QzUUeodY=
217 | modernc.org/libc v1.55.2 h1:UN5eoBYrKp1b+gPYx8nZj5H7uxeybvyoQJfvcg+Bqjc=
218 | modernc.org/libc v1.55.2/go.mod h1:qFXepLhz+JjFThQ4kzwzOjA/y/artDeg+pcYnY+Q83w=
219 | modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4=
220 | modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo=
221 | modernc.org/memory v1.7.2 h1:Klh90S215mmH8c9gO98QxQFsY+W451E8AnzjoE2ee1E=
222 | modernc.org/memory v1.7.2/go.mod h1:NO4NVCQy0N7ln+T9ngWqOQfi7ley4vpwvARR+Hjw95E=
223 | modernc.org/memory v1.8.0 h1:IqGTL6eFMaDZZhEWwcREgeMXYwmW83LYW8cROZYkg+E=
224 | modernc.org/memory v1.8.0/go.mod h1:XPZ936zp5OMKGWPqbD3JShgd/ZoQ7899TUuQqxY+peU=
225 | modernc.org/sqlite v1.28.0 h1:Zx+LyDDmXczNnEQdvPuEfcFVA2ZPyaD7UCZDjef3BHQ=
226 | modernc.org/sqlite v1.28.0/go.mod h1:Qxpazz0zH8Z1xCFyi5GSL3FzbtZ3fvbjmywNogldEW0=
227 | modernc.org/sqlite v1.30.2 h1:IPVVkhLu5mMVnS1dQgh3h0SAACRWcVk7aoLP9Us3UCk=
228 | modernc.org/sqlite v1.30.2/go.mod h1:DUmsiWQDaAvU4abhc/N+djlom/L2o8f7gZ95RCvyoLU=
229 | nhooyr.io/websocket v1.8.10 h1:mv4p+MnGrLDcPlBoWsvPP7XCzTYMXP9F9eIGoKbgx7Q=
230 | nhooyr.io/websocket v1.8.10/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c=
231 | nhooyr.io/websocket v1.8.11 h1:f/qXNc2/3DpoSZkHt1DQu6rj4zGC8JmkkLkWss0MgN0=
232 | nhooyr.io/websocket v1.8.11/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c=
233 | nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
234 | rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
235 | rsc.io/qr v0.2.0 h1:6vBLea5/NRMVTz8V66gipeLycZMl/+UlFmk8DvqQ6WY=
236 | rsc.io/qr v0.2.0/go.mod h1:IF+uZjkb9fqyeF/4tlBoynqmQxUoPfWEKh921coOuXs=
237 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU AFFERO GENERAL PUBLIC LICENSE
2 | Version 3, 19 November 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU Affero General Public License is a free, copyleft license for
11 | software and other kinds of works, specifically designed to ensure
12 | cooperation with the community in the case of network server software.
13 |
14 | The licenses for most software and other practical works are designed
15 | to take away your freedom to share and change the works. By contrast,
16 | our General Public Licenses are intended to guarantee your freedom to
17 | share and change all versions of a program--to make sure it remains free
18 | software for all its users.
19 |
20 | When we speak of free software, we are referring to freedom, not
21 | price. Our General Public Licenses are designed to make sure that you
22 | have the freedom to distribute copies of free software (and charge for
23 | them if you wish), that you receive source code or can get it if you
24 | want it, that you can change the software or use pieces of it in new
25 | free programs, and that you know you can do these things.
26 |
27 | Developers that use our General Public Licenses protect your rights
28 | with two steps: (1) assert copyright on the software, and (2) offer
29 | you this License which gives you legal permission to copy, distribute
30 | and/or modify the software.
31 |
32 | A secondary benefit of defending all users' freedom is that
33 | improvements made in alternate versions of the program, if they
34 | receive widespread use, become available for other developers to
35 | incorporate. Many developers of free software are heartened and
36 | encouraged by the resulting cooperation. However, in the case of
37 | software used on network servers, this result may fail to come about.
38 | The GNU General Public License permits making a modified version and
39 | letting the public access it on a server without ever releasing its
40 | source code to the public.
41 |
42 | The GNU Affero General Public License is designed specifically to
43 | ensure that, in such cases, the modified source code becomes available
44 | to the community. It requires the operator of a network server to
45 | provide the source code of the modified version running there to the
46 | users of that server. Therefore, public use of a modified version, on
47 | a publicly accessible server, gives the public access to the source
48 | code of the modified version.
49 |
50 | An older license, called the Affero General Public License and
51 | published by Affero, was designed to accomplish similar goals. This is
52 | a different license, not a version of the Affero GPL, but Affero has
53 | released a new version of the Affero GPL which permits relicensing under
54 | this license.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | TERMS AND CONDITIONS
60 |
61 | 0. Definitions.
62 |
63 | "This License" refers to version 3 of the GNU Affero General Public License.
64 |
65 | "Copyright" also means copyright-like laws that apply to other kinds of
66 | works, such as semiconductor masks.
67 |
68 | "The Program" refers to any copyrightable work licensed under this
69 | License. Each licensee is addressed as "you". "Licensees" and
70 | "recipients" may be individuals or organizations.
71 |
72 | To "modify" a work means to copy from or adapt all or part of the work
73 | in a fashion requiring copyright permission, other than the making of an
74 | exact copy. The resulting work is called a "modified version" of the
75 | earlier work or a work "based on" the earlier work.
76 |
77 | A "covered work" means either the unmodified Program or a work based
78 | on the Program.
79 |
80 | To "propagate" a work means to do anything with it that, without
81 | permission, would make you directly or secondarily liable for
82 | infringement under applicable copyright law, except executing it on a
83 | computer or modifying a private copy. Propagation includes copying,
84 | distribution (with or without modification), making available to the
85 | public, and in some countries other activities as well.
86 |
87 | To "convey" a work means any kind of propagation that enables other
88 | parties to make or receive copies. Mere interaction with a user through
89 | a computer network, with no transfer of a copy, is not conveying.
90 |
91 | An interactive user interface displays "Appropriate Legal Notices"
92 | to the extent that it includes a convenient and prominently visible
93 | feature that (1) displays an appropriate copyright notice, and (2)
94 | tells the user that there is no warranty for the work (except to the
95 | extent that warranties are provided), that licensees may convey the
96 | work under this License, and how to view a copy of this License. If
97 | the interface presents a list of user commands or options, such as a
98 | menu, a prominent item in the list meets this criterion.
99 |
100 | 1. Source Code.
101 |
102 | The "source code" for a work means the preferred form of the work
103 | for making modifications to it. "Object code" means any non-source
104 | form of a work.
105 |
106 | A "Standard Interface" means an interface that either is an official
107 | standard defined by a recognized standards body, or, in the case of
108 | interfaces specified for a particular programming language, one that
109 | is widely used among developers working in that language.
110 |
111 | The "System Libraries" of an executable work include anything, other
112 | than the work as a whole, that (a) is included in the normal form of
113 | packaging a Major Component, but which is not part of that Major
114 | Component, and (b) serves only to enable use of the work with that
115 | Major Component, or to implement a Standard Interface for which an
116 | implementation is available to the public in source code form. A
117 | "Major Component", in this context, means a major essential component
118 | (kernel, window system, and so on) of the specific operating system
119 | (if any) on which the executable work runs, or a compiler used to
120 | produce the work, or an object code interpreter used to run it.
121 |
122 | The "Corresponding Source" for a work in object code form means all
123 | the source code needed to generate, install, and (for an executable
124 | work) run the object code and to modify the work, including scripts to
125 | control those activities. However, it does not include the work's
126 | System Libraries, or general-purpose tools or generally available free
127 | programs which are used unmodified in performing those activities but
128 | which are not part of the work. For example, Corresponding Source
129 | includes interface definition files associated with source files for
130 | the work, and the source code for shared libraries and dynamically
131 | linked subprograms that the work is specifically designed to require,
132 | such as by intimate data communication or control flow between those
133 | subprograms and other parts of the work.
134 |
135 | The Corresponding Source need not include anything that users
136 | can regenerate automatically from other parts of the Corresponding
137 | Source.
138 |
139 | The Corresponding Source for a work in source code form is that
140 | same work.
141 |
142 | 2. Basic Permissions.
143 |
144 | All rights granted under this License are granted for the term of
145 | copyright on the Program, and are irrevocable provided the stated
146 | conditions are met. This License explicitly affirms your unlimited
147 | permission to run the unmodified Program. The output from running a
148 | covered work is covered by this License only if the output, given its
149 | content, constitutes a covered work. This License acknowledges your
150 | rights of fair use or other equivalent, as provided by copyright law.
151 |
152 | You may make, run and propagate covered works that you do not
153 | convey, without conditions so long as your license otherwise remains
154 | in force. You may convey covered works to others for the sole purpose
155 | of having them make modifications exclusively for you, or provide you
156 | with facilities for running those works, provided that you comply with
157 | the terms of this License in conveying all material for which you do
158 | not control copyright. Those thus making or running the covered works
159 | for you must do so exclusively on your behalf, under your direction
160 | and control, on terms that prohibit them from making any copies of
161 | your copyrighted material outside their relationship with you.
162 |
163 | Conveying under any other circumstances is permitted solely under
164 | the conditions stated below. Sublicensing is not allowed; section 10
165 | makes it unnecessary.
166 |
167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
168 |
169 | No covered work shall be deemed part of an effective technological
170 | measure under any applicable law fulfilling obligations under article
171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
172 | similar laws prohibiting or restricting circumvention of such
173 | measures.
174 |
175 | When you convey a covered work, you waive any legal power to forbid
176 | circumvention of technological measures to the extent such circumvention
177 | is effected by exercising rights under this License with respect to
178 | the covered work, and you disclaim any intention to limit operation or
179 | modification of the work as a means of enforcing, against the work's
180 | users, your or third parties' legal rights to forbid circumvention of
181 | technological measures.
182 |
183 | 4. Conveying Verbatim Copies.
184 |
185 | You may convey verbatim copies of the Program's source code as you
186 | receive it, in any medium, provided that you conspicuously and
187 | appropriately publish on each copy an appropriate copyright notice;
188 | keep intact all notices stating that this License and any
189 | non-permissive terms added in accord with section 7 apply to the code;
190 | keep intact all notices of the absence of any warranty; and give all
191 | recipients a copy of this License along with the Program.
192 |
193 | You may charge any price or no price for each copy that you convey,
194 | and you may offer support or warranty protection for a fee.
195 |
196 | 5. Conveying Modified Source Versions.
197 |
198 | You may convey a work based on the Program, or the modifications to
199 | produce it from the Program, in the form of source code under the
200 | terms of section 4, provided that you also meet all of these conditions:
201 |
202 | a) The work must carry prominent notices stating that you modified
203 | it, and giving a relevant date.
204 |
205 | b) The work must carry prominent notices stating that it is
206 | released under this License and any conditions added under section
207 | 7. This requirement modifies the requirement in section 4 to
208 | "keep intact all notices".
209 |
210 | c) You must license the entire work, as a whole, under this
211 | License to anyone who comes into possession of a copy. This
212 | License will therefore apply, along with any applicable section 7
213 | additional terms, to the whole of the work, and all its parts,
214 | regardless of how they are packaged. This License gives no
215 | permission to license the work in any other way, but it does not
216 | invalidate such permission if you have separately received it.
217 |
218 | d) If the work has interactive user interfaces, each must display
219 | Appropriate Legal Notices; however, if the Program has interactive
220 | interfaces that do not display Appropriate Legal Notices, your
221 | work need not make them do so.
222 |
223 | A compilation of a covered work with other separate and independent
224 | works, which are not by their nature extensions of the covered work,
225 | and which are not combined with it such as to form a larger program,
226 | in or on a volume of a storage or distribution medium, is called an
227 | "aggregate" if the compilation and its resulting copyright are not
228 | used to limit the access or legal rights of the compilation's users
229 | beyond what the individual works permit. Inclusion of a covered work
230 | in an aggregate does not cause this License to apply to the other
231 | parts of the aggregate.
232 |
233 | 6. Conveying Non-Source Forms.
234 |
235 | You may convey a covered work in object code form under the terms
236 | of sections 4 and 5, provided that you also convey the
237 | machine-readable Corresponding Source under the terms of this License,
238 | in one of these ways:
239 |
240 | a) Convey the object code in, or embodied in, a physical product
241 | (including a physical distribution medium), accompanied by the
242 | Corresponding Source fixed on a durable physical medium
243 | customarily used for software interchange.
244 |
245 | b) Convey the object code in, or embodied in, a physical product
246 | (including a physical distribution medium), accompanied by a
247 | written offer, valid for at least three years and valid for as
248 | long as you offer spare parts or customer support for that product
249 | model, to give anyone who possesses the object code either (1) a
250 | copy of the Corresponding Source for all the software in the
251 | product that is covered by this License, on a durable physical
252 | medium customarily used for software interchange, for a price no
253 | more than your reasonable cost of physically performing this
254 | conveying of source, or (2) access to copy the
255 | Corresponding Source from a network server at no charge.
256 |
257 | c) Convey individual copies of the object code with a copy of the
258 | written offer to provide the Corresponding Source. This
259 | alternative is allowed only occasionally and noncommercially, and
260 | only if you received the object code with such an offer, in accord
261 | with subsection 6b.
262 |
263 | d) Convey the object code by offering access from a designated
264 | place (gratis or for a charge), and offer equivalent access to the
265 | Corresponding Source in the same way through the same place at no
266 | further charge. You need not require recipients to copy the
267 | Corresponding Source along with the object code. If the place to
268 | copy the object code is a network server, the Corresponding Source
269 | may be on a different server (operated by you or a third party)
270 | that supports equivalent copying facilities, provided you maintain
271 | clear directions next to the object code saying where to find the
272 | Corresponding Source. Regardless of what server hosts the
273 | Corresponding Source, you remain obligated to ensure that it is
274 | available for as long as needed to satisfy these requirements.
275 |
276 | e) Convey the object code using peer-to-peer transmission, provided
277 | you inform other peers where the object code and Corresponding
278 | Source of the work are being offered to the general public at no
279 | charge under subsection 6d.
280 |
281 | A separable portion of the object code, whose source code is excluded
282 | from the Corresponding Source as a System Library, need not be
283 | included in conveying the object code work.
284 |
285 | A "User Product" is either (1) a "consumer product", which means any
286 | tangible personal property which is normally used for personal, family,
287 | or household purposes, or (2) anything designed or sold for incorporation
288 | into a dwelling. In determining whether a product is a consumer product,
289 | doubtful cases shall be resolved in favor of coverage. For a particular
290 | product received by a particular user, "normally used" refers to a
291 | typical or common use of that class of product, regardless of the status
292 | of the particular user or of the way in which the particular user
293 | actually uses, or expects or is expected to use, the product. A product
294 | is a consumer product regardless of whether the product has substantial
295 | commercial, industrial or non-consumer uses, unless such uses represent
296 | the only significant mode of use of the product.
297 |
298 | "Installation Information" for a User Product means any methods,
299 | procedures, authorization keys, or other information required to install
300 | and execute modified versions of a covered work in that User Product from
301 | a modified version of its Corresponding Source. The information must
302 | suffice to ensure that the continued functioning of the modified object
303 | code is in no case prevented or interfered with solely because
304 | modification has been made.
305 |
306 | If you convey an object code work under this section in, or with, or
307 | specifically for use in, a User Product, and the conveying occurs as
308 | part of a transaction in which the right of possession and use of the
309 | User Product is transferred to the recipient in perpetuity or for a
310 | fixed term (regardless of how the transaction is characterized), the
311 | Corresponding Source conveyed under this section must be accompanied
312 | by the Installation Information. But this requirement does not apply
313 | if neither you nor any third party retains the ability to install
314 | modified object code on the User Product (for example, the work has
315 | been installed in ROM).
316 |
317 | The requirement to provide Installation Information does not include a
318 | requirement to continue to provide support service, warranty, or updates
319 | for a work that has been modified or installed by the recipient, or for
320 | the User Product in which it has been modified or installed. Access to a
321 | network may be denied when the modification itself materially and
322 | adversely affects the operation of the network or violates the rules and
323 | protocols for communication across the network.
324 |
325 | Corresponding Source conveyed, and Installation Information provided,
326 | in accord with this section must be in a format that is publicly
327 | documented (and with an implementation available to the public in
328 | source code form), and must require no special password or key for
329 | unpacking, reading or copying.
330 |
331 | 7. Additional Terms.
332 |
333 | "Additional permissions" are terms that supplement the terms of this
334 | License by making exceptions from one or more of its conditions.
335 | Additional permissions that are applicable to the entire Program shall
336 | be treated as though they were included in this License, to the extent
337 | that they are valid under applicable law. If additional permissions
338 | apply only to part of the Program, that part may be used separately
339 | under those permissions, but the entire Program remains governed by
340 | this License without regard to the additional permissions.
341 |
342 | When you convey a copy of a covered work, you may at your option
343 | remove any additional permissions from that copy, or from any part of
344 | it. (Additional permissions may be written to require their own
345 | removal in certain cases when you modify the work.) You may place
346 | additional permissions on material, added by you to a covered work,
347 | for which you have or can give appropriate copyright permission.
348 |
349 | Notwithstanding any other provision of this License, for material you
350 | add to a covered work, you may (if authorized by the copyright holders of
351 | that material) supplement the terms of this License with terms:
352 |
353 | a) Disclaiming warranty or limiting liability differently from the
354 | terms of sections 15 and 16 of this License; or
355 |
356 | b) Requiring preservation of specified reasonable legal notices or
357 | author attributions in that material or in the Appropriate Legal
358 | Notices displayed by works containing it; or
359 |
360 | c) Prohibiting misrepresentation of the origin of that material, or
361 | requiring that modified versions of such material be marked in
362 | reasonable ways as different from the original version; or
363 |
364 | d) Limiting the use for publicity purposes of names of licensors or
365 | authors of the material; or
366 |
367 | e) Declining to grant rights under trademark law for use of some
368 | trade names, trademarks, or service marks; or
369 |
370 | f) Requiring indemnification of licensors and authors of that
371 | material by anyone who conveys the material (or modified versions of
372 | it) with contractual assumptions of liability to the recipient, for
373 | any liability that these contractual assumptions directly impose on
374 | those licensors and authors.
375 |
376 | All other non-permissive additional terms are considered "further
377 | restrictions" within the meaning of section 10. If the Program as you
378 | received it, or any part of it, contains a notice stating that it is
379 | governed by this License along with a term that is a further
380 | restriction, you may remove that term. If a license document contains
381 | a further restriction but permits relicensing or conveying under this
382 | License, you may add to a covered work material governed by the terms
383 | of that license document, provided that the further restriction does
384 | not survive such relicensing or conveying.
385 |
386 | If you add terms to a covered work in accord with this section, you
387 | must place, in the relevant source files, a statement of the
388 | additional terms that apply to those files, or a notice indicating
389 | where to find the applicable terms.
390 |
391 | Additional terms, permissive or non-permissive, may be stated in the
392 | form of a separately written license, or stated as exceptions;
393 | the above requirements apply either way.
394 |
395 | 8. Termination.
396 |
397 | You may not propagate or modify a covered work except as expressly
398 | provided under this License. Any attempt otherwise to propagate or
399 | modify it is void, and will automatically terminate your rights under
400 | this License (including any patent licenses granted under the third
401 | paragraph of section 11).
402 |
403 | However, if you cease all violation of this License, then your
404 | license from a particular copyright holder is reinstated (a)
405 | provisionally, unless and until the copyright holder explicitly and
406 | finally terminates your license, and (b) permanently, if the copyright
407 | holder fails to notify you of the violation by some reasonable means
408 | prior to 60 days after the cessation.
409 |
410 | Moreover, your license from a particular copyright holder is
411 | reinstated permanently if the copyright holder notifies you of the
412 | violation by some reasonable means, this is the first time you have
413 | received notice of violation of this License (for any work) from that
414 | copyright holder, and you cure the violation prior to 30 days after
415 | your receipt of the notice.
416 |
417 | Termination of your rights under this section does not terminate the
418 | licenses of parties who have received copies or rights from you under
419 | this License. If your rights have been terminated and not permanently
420 | reinstated, you do not qualify to receive new licenses for the same
421 | material under section 10.
422 |
423 | 9. Acceptance Not Required for Having Copies.
424 |
425 | You are not required to accept this License in order to receive or
426 | run a copy of the Program. Ancillary propagation of a covered work
427 | occurring solely as a consequence of using peer-to-peer transmission
428 | to receive a copy likewise does not require acceptance. However,
429 | nothing other than this License grants you permission to propagate or
430 | modify any covered work. These actions infringe copyright if you do
431 | not accept this License. Therefore, by modifying or propagating a
432 | covered work, you indicate your acceptance of this License to do so.
433 |
434 | 10. Automatic Licensing of Downstream Recipients.
435 |
436 | Each time you convey a covered work, the recipient automatically
437 | receives a license from the original licensors, to run, modify and
438 | propagate that work, subject to this License. You are not responsible
439 | for enforcing compliance by third parties with this License.
440 |
441 | An "entity transaction" is a transaction transferring control of an
442 | organization, or substantially all assets of one, or subdividing an
443 | organization, or merging organizations. If propagation of a covered
444 | work results from an entity transaction, each party to that
445 | transaction who receives a copy of the work also receives whatever
446 | licenses to the work the party's predecessor in interest had or could
447 | give under the previous paragraph, plus a right to possession of the
448 | Corresponding Source of the work from the predecessor in interest, if
449 | the predecessor has it or can get it with reasonable efforts.
450 |
451 | You may not impose any further restrictions on the exercise of the
452 | rights granted or affirmed under this License. For example, you may
453 | not impose a license fee, royalty, or other charge for exercise of
454 | rights granted under this License, and you may not initiate litigation
455 | (including a cross-claim or counterclaim in a lawsuit) alleging that
456 | any patent claim is infringed by making, using, selling, offering for
457 | sale, or importing the Program or any portion of it.
458 |
459 | 11. Patents.
460 |
461 | A "contributor" is a copyright holder who authorizes use under this
462 | License of the Program or a work on which the Program is based. The
463 | work thus licensed is called the contributor's "contributor version".
464 |
465 | A contributor's "essential patent claims" are all patent claims
466 | owned or controlled by the contributor, whether already acquired or
467 | hereafter acquired, that would be infringed by some manner, permitted
468 | by this License, of making, using, or selling its contributor version,
469 | but do not include claims that would be infringed only as a
470 | consequence of further modification of the contributor version. For
471 | purposes of this definition, "control" includes the right to grant
472 | patent sublicenses in a manner consistent with the requirements of
473 | this License.
474 |
475 | Each contributor grants you a non-exclusive, worldwide, royalty-free
476 | patent license under the contributor's essential patent claims, to
477 | make, use, sell, offer for sale, import and otherwise run, modify and
478 | propagate the contents of its contributor version.
479 |
480 | In the following three paragraphs, a "patent license" is any express
481 | agreement or commitment, however denominated, not to enforce a patent
482 | (such as an express permission to practice a patent or covenant not to
483 | sue for patent infringement). To "grant" such a patent license to a
484 | party means to make such an agreement or commitment not to enforce a
485 | patent against the party.
486 |
487 | If you convey a covered work, knowingly relying on a patent license,
488 | and the Corresponding Source of the work is not available for anyone
489 | to copy, free of charge and under the terms of this License, through a
490 | publicly available network server or other readily accessible means,
491 | then you must either (1) cause the Corresponding Source to be so
492 | available, or (2) arrange to deprive yourself of the benefit of the
493 | patent license for this particular work, or (3) arrange, in a manner
494 | consistent with the requirements of this License, to extend the patent
495 | license to downstream recipients. "Knowingly relying" means you have
496 | actual knowledge that, but for the patent license, your conveying the
497 | covered work in a country, or your recipient's use of the covered work
498 | in a country, would infringe one or more identifiable patents in that
499 | country that you have reason to believe are valid.
500 |
501 | If, pursuant to or in connection with a single transaction or
502 | arrangement, you convey, or propagate by procuring conveyance of, a
503 | covered work, and grant a patent license to some of the parties
504 | receiving the covered work authorizing them to use, propagate, modify
505 | or convey a specific copy of the covered work, then the patent license
506 | you grant is automatically extended to all recipients of the covered
507 | work and works based on it.
508 |
509 | A patent license is "discriminatory" if it does not include within
510 | the scope of its coverage, prohibits the exercise of, or is
511 | conditioned on the non-exercise of one or more of the rights that are
512 | specifically granted under this License. You may not convey a covered
513 | work if you are a party to an arrangement with a third party that is
514 | in the business of distributing software, under which you make payment
515 | to the third party based on the extent of your activity of conveying
516 | the work, and under which the third party grants, to any of the
517 | parties who would receive the covered work from you, a discriminatory
518 | patent license (a) in connection with copies of the covered work
519 | conveyed by you (or copies made from those copies), or (b) primarily
520 | for and in connection with specific products or compilations that
521 | contain the covered work, unless you entered into that arrangement,
522 | or that patent license was granted, prior to 28 March 2007.
523 |
524 | Nothing in this License shall be construed as excluding or limiting
525 | any implied license or other defenses to infringement that may
526 | otherwise be available to you under applicable patent law.
527 |
528 | 12. No Surrender of Others' Freedom.
529 |
530 | If conditions are imposed on you (whether by court order, agreement or
531 | otherwise) that contradict the conditions of this License, they do not
532 | excuse you from the conditions of this License. If you cannot convey a
533 | covered work so as to satisfy simultaneously your obligations under this
534 | License and any other pertinent obligations, then as a consequence you may
535 | not convey it at all. For example, if you agree to terms that obligate you
536 | to collect a royalty for further conveying from those to whom you convey
537 | the Program, the only way you could satisfy both those terms and this
538 | License would be to refrain entirely from conveying the Program.
539 |
540 | 13. Remote Network Interaction; Use with the GNU General Public License.
541 |
542 | Notwithstanding any other provision of this License, if you modify the
543 | Program, your modified version must prominently offer all users
544 | interacting with it remotely through a computer network (if your version
545 | supports such interaction) an opportunity to receive the Corresponding
546 | Source of your version by providing access to the Corresponding Source
547 | from a network server at no charge, through some standard or customary
548 | means of facilitating copying of software. This Corresponding Source
549 | shall include the Corresponding Source for any work covered by version 3
550 | of the GNU General Public License that is incorporated pursuant to the
551 | following paragraph.
552 |
553 | Notwithstanding any other provision of this License, you have
554 | permission to link or combine any covered work with a work licensed
555 | under version 3 of the GNU General Public License into a single
556 | combined work, and to convey the resulting work. The terms of this
557 | License will continue to apply to the part which is the covered work,
558 | but the work with which it is combined will remain governed by version
559 | 3 of the GNU General Public License.
560 |
561 | 14. Revised Versions of this License.
562 |
563 | The Free Software Foundation may publish revised and/or new versions of
564 | the GNU Affero General Public License from time to time. Such new versions
565 | will be similar in spirit to the present version, but may differ in detail to
566 | address new problems or concerns.
567 |
568 | Each version is given a distinguishing version number. If the
569 | Program specifies that a certain numbered version of the GNU Affero General
570 | Public License "or any later version" applies to it, you have the
571 | option of following the terms and conditions either of that numbered
572 | version or of any later version published by the Free Software
573 | Foundation. If the Program does not specify a version number of the
574 | GNU Affero General Public License, you may choose any version ever published
575 | by the Free Software Foundation.
576 |
577 | If the Program specifies that a proxy can decide which future
578 | versions of the GNU Affero General Public License can be used, that proxy's
579 | public statement of acceptance of a version permanently authorizes you
580 | to choose that version for the Program.
581 |
582 | Later license versions may give you additional or different
583 | permissions. However, no additional obligations are imposed on any
584 | author or copyright holder as a result of your choosing to follow a
585 | later version.
586 |
587 | 15. Disclaimer of Warranty.
588 |
589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
597 |
598 | 16. Limitation of Liability.
599 |
600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
608 | SUCH DAMAGES.
609 |
610 | 17. Interpretation of Sections 15 and 16.
611 |
612 | If the disclaimer of warranty and limitation of liability provided
613 | above cannot be given local legal effect according to their terms,
614 | reviewing courts shall apply local law that most closely approximates
615 | an absolute waiver of all civil liability in connection with the
616 | Program, unless a warranty or assumption of liability accompanies a
617 | copy of the Program in return for a fee.
618 |
619 | END OF TERMS AND CONDITIONS
620 |
621 | How to Apply These Terms to Your New Programs
622 |
623 | If you develop a new program, and you want it to be of the greatest
624 | possible use to the public, the best way to achieve this is to make it
625 | free software which everyone can redistribute and change under these terms.
626 |
627 | To do so, attach the following notices to the program. It is safest
628 | to attach them to the start of each source file to most effectively
629 | state the exclusion of warranty; and each file should have at least
630 | the "copyright" line and a pointer to where the full notice is found.
631 |
632 | Telegram File Stream Bot - A simple webserver to stream telegram files over HTTP.
633 | Copyright (C) <2023>
634 |
635 | This program is free software: you can redistribute it and/or modify
636 | it under the terms of the GNU Affero General Public License as published
637 | by the Free Software Foundation, either version 3 of the License, or
638 | (at your option) any later version.
639 |
640 | This program is distributed in the hope that it will be useful,
641 | but WITHOUT ANY WARRANTY; without even the implied warranty of
642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
643 | GNU Affero General Public License for more details.
644 |
645 | You should have received a copy of the GNU Affero General Public License
646 | along with this program. If not, see .
647 |
648 | Also add information on how to contact you by electronic and paper mail.
649 |
650 | If your software can interact with users remotely through a computer
651 | network, you should also make sure that it provides a way for users to
652 | get its source. For example, if your program is a web application, its
653 | interface could display a "Source" link that leads users to an archive
654 | of the code. There are many ways you could offer source, and different
655 | solutions will be better for different programs; see section 13 for the
656 | specific requirements.
657 |
658 | You should also get your employer (if you work as a programmer) or school,
659 | if any, to sign a "copyright disclaimer" for the program, if necessary.
660 | For more information on this, and how to apply and follow the GNU AGPL, see
661 | .
--------------------------------------------------------------------------------