codebydante commited on
Commit
3b42e05
·
verified ·
1 Parent(s): b091dda

Delete test-clone

Browse files
Files changed (48) hide show
  1. test-clone/.gitattributes +0 -3
  2. test-clone/.github/workflows/notify.yml +0 -27
  3. test-clone/.github/workflows/release.yml +0 -59
  4. test-clone/.gitignore +0 -33
  5. test-clone/.goreleaser.yaml +0 -89
  6. test-clone/.vscode/launch.json +0 -30
  7. test-clone/Dockerfile +0 -43
  8. test-clone/LICENSE +0 -661
  9. test-clone/Procfile +0 -1
  10. test-clone/README.md +0 -42
  11. test-clone/app.json +0 -55
  12. test-clone/cmd/fsb/main.go +0 -37
  13. test-clone/cmd/fsb/run.go +0 -80
  14. test-clone/cmd/fsb/session.go +0 -41
  15. test-clone/config/config.go +0 -305
  16. test-clone/docker-compose.yaml +0 -15
  17. test-clone/fsb.env +0 -60
  18. test-clone/fsb.sample.env +0 -60
  19. test-clone/fsb.session +0 -0
  20. test-clone/go.mod +0 -95
  21. test-clone/go.sum +0 -245
  22. test-clone/goreleaser.Dockerfile +0 -5
  23. test-clone/install.sh +0 -710
  24. test-clone/internal/bot/client.go +0 -55
  25. test-clone/internal/bot/middleware.go +0 -20
  26. test-clone/internal/bot/userbot.go +0 -119
  27. test-clone/internal/bot/workers.go +0 -171
  28. test-clone/internal/cache/cache.go +0 -68
  29. test-clone/internal/commands/commands.go +0 -22
  30. test-clone/internal/commands/start.go +0 -31
  31. test-clone/internal/commands/stream.go +0 -167
  32. test-clone/internal/routes/routes.go +0 -33
  33. test-clone/internal/routes/stream.go +0 -142
  34. test-clone/internal/routes/upload.go +0 -120
  35. test-clone/internal/stream/errors.go +0 -17
  36. test-clone/internal/stream/pipe.go +0 -314
  37. test-clone/internal/types/file.go +0 -44
  38. test-clone/internal/types/response.go +0 -8
  39. test-clone/internal/utils/hashing.go +0 -18
  40. test-clone/internal/utils/helpers.go +0 -198
  41. test-clone/internal/utils/logger.go +0 -52
  42. test-clone/internal/utils/time_format.go +0 -42
  43. test-clone/internal/utils/timing.go +0 -17
  44. test-clone/logs/app.log +0 -0
  45. test-clone/pkg/qrlogin/encoder.go +0 -52
  46. test-clone/pkg/qrlogin/qrcode.go +0 -152
  47. test-clone/run.bat +0 -4
  48. test-clone/start.bat +0 -17
test-clone/.gitattributes DELETED
@@ -1,3 +0,0 @@
1
- # Auto detect text files and perform LF normalization
2
- * text=auto
3
- fsb.exe filter=lfs diff=lfs merge=lfs -text
 
 
 
 
test-clone/.github/workflows/notify.yml DELETED
@@ -1,27 +0,0 @@
1
- name: Notify on Telegram
2
-
3
- on:
4
- push:
5
- release:
6
- types: published
7
- issue_comment:
8
- types: created
9
- watch:
10
- types: started
11
- pull_request_review_comment:
12
- types: created
13
- pull_request:
14
- types: [opened, closed, reopened]
15
- issues:
16
- types: [opened, pinned, closed, reopened]
17
- jobs:
18
- notify:
19
- runs-on: ubuntu-latest
20
- steps:
21
- - uses: actions/checkout@v6
22
- - name: Notify the commit on Telegram.
23
- uses: EverythingSuckz/github-telegram-notify@main
24
- with:
25
- bot_token: '${{ secrets.BOT_TOKEN }}'
26
- chat_id: '${{ secrets.CHAT_ID }}'
27
- topic_id: '${{ secrets.TOPIC_ID }}'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/.github/workflows/release.yml DELETED
@@ -1,59 +0,0 @@
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
- - "v*"
13
-
14
- permissions:
15
- contents: write
16
- packages: write
17
-
18
- jobs:
19
- goreleaser:
20
- runs-on: ubuntu-latest
21
- steps:
22
- - name: Checkout
23
- uses: actions/checkout@v6
24
- with:
25
- fetch-depth: 0
26
- - run: git fetch --force --tags
27
- - name: Set up QEMU
28
- uses: docker/setup-qemu-action@v3
29
- with:
30
- platforms: arm64
31
- - name: Set up Docker Buildx
32
- uses: docker/setup-buildx-action@v3
33
- with:
34
- driver: docker-container
35
- - name: Set up Go
36
- uses: actions/setup-go@v6
37
- with:
38
- go-version: 1.25
39
- - name: Import GPG key
40
- id: import_gpg
41
- uses: crazy-max/ghaction-import-gpg@v6
42
- with:
43
- gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
44
- passphrase: ${{ secrets.PASSPHRASE }}
45
- - name: Log in to GHCR
46
- uses: docker/login-action@v3
47
- with:
48
- registry: ghcr.io
49
- username: ${{ github.actor }}
50
- password: ${{ secrets.GITHUB_TOKEN }}
51
- - name: Run GoReleaser
52
- uses: goreleaser/goreleaser-action@v6
53
- with:
54
- distribution: goreleaser
55
- version: latest
56
- args: release ${{ github.event.inputs.goReleaserArgs }}
57
- env:
58
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59
- GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/.gitignore DELETED
@@ -1,33 +0,0 @@
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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/.goreleaser.yaml DELETED
@@ -1,89 +0,0 @@
1
- version: 2
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
- - id: fsb
12
- main: ./cmd/fsb
13
- env:
14
- - CGO_ENABLED=0
15
- flags: -tags=musl
16
- ldflags: "-extldflags -static -s -w"
17
- binary: fsb
18
- goos:
19
- - linux
20
- - windows
21
- - darwin
22
- goarch:
23
- - amd64
24
- - arm64
25
- mod_timestamp: '{{ .CommitTimestamp }}'
26
-
27
- dockers_v2:
28
- - images:
29
- - "ghcr.io/everythingsuckz/fsb"
30
- ids:
31
- - fsb
32
-
33
- tags:
34
- - "{{ .Tag }}"
35
- - "v{{ .Major }}.{{ .Minor }}"
36
- - "{{ if not .Prerelease }}latest{{ end }}"
37
-
38
- dockerfile: goreleaser.Dockerfile
39
-
40
- platforms:
41
- - linux/amd64
42
- - linux/arm64
43
- labels:
44
- "org.opencontainers.image.name": "{{.ProjectName}}"
45
- "org.opencontainers.image.created": "{{.Date}}"
46
- "org.opencontainers.image.revision": "{{.FullCommit}}"
47
- "org.opencontainers.image.version": "{{.Version}}"
48
- "org.opencontainers.image.description": "A high-performance Telegram File Streamer Bot written in Go. Stream files directly from Telegram to your download manager or media player with extreme efficiency."
49
- "org.opencontainers.image.source": "{{.GitURL}}"
50
-
51
- retry:
52
- attempts: 5
53
- delay: 10s
54
- max_delay: 10s
55
-
56
- archives:
57
- - formats: ["tar.gz"]
58
- name_template: "{{ .ProjectName }}-{{ .Tag }}-{{ .Os }}-{{ .Arch }}"
59
- format_overrides:
60
- - goos: windows
61
- formats: ["zip"]
62
-
63
- signs:
64
- - artifacts: checksum
65
- cmd: gpg2
66
- args:
67
- - "--batch"
68
- - "-u"
69
- - "{{ .Env.GPG_FINGERPRINT }}"
70
- - "--output"
71
- - "${signature}"
72
- - "--detach-sign"
73
- - "${artifact}"
74
-
75
- checksum:
76
- name_template: "{{ .ProjectName }}-{{ .Tag }}-checksums.txt"
77
-
78
- changelog:
79
- sort: asc
80
- filters:
81
- exclude:
82
- - "^docs:"
83
- - "^test:"
84
-
85
- release:
86
- github:
87
- owner: EverythingSuckz
88
- name: TG-FileStreamBot
89
- prerelease: auto
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/.vscode/launch.json DELETED
@@ -1,30 +0,0 @@
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
- "envFile": "${cwd}/fsb.env",
14
- "args": [
15
- "run"
16
- ]
17
- },
18
- {
19
- "name": "Generate Session",
20
- "type": "go",
21
- "request": "launch",
22
- "mode": "auto",
23
- "program": "./cmd/fsb/",
24
- "args": [
25
- "session"
26
- ],
27
- "console": "integratedTerminal"
28
- }
29
- ]
30
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/Dockerfile DELETED
@@ -1,43 +0,0 @@
1
- # Usar la imagen oficial de Go como base para compilación
2
- FROM golang:1.25-alpine AS builder
3
-
4
- # Configurar el directorio de trabajo dentro del contenedor
5
- WORKDIR /app
6
-
7
- # Instalar dependencias necesarias para compilar y para sqlite
8
- RUN apk add --no-cache gcc musl-dev linux-headers
9
-
10
- # Copiar los archivos de go.mod y descargar dependencias
11
- COPY go.mod go.sum ./
12
- RUN go mod download
13
-
14
- # Copiar el resto del código fuente del proyecto
15
- COPY . .
16
-
17
- # Compilar la aplicación
18
- RUN CGO_ENABLED=1 GOOS=linux go build -o /app/fsb -ldflags="-w -s" ./cmd/fsb
19
-
20
- # Crear una imagen final más ligera basada en alpine
21
- FROM alpine:latest
22
-
23
- # Instalar certificados (necesario para HTTPS/Telegram) y otras utilidades
24
- RUN apk add --no-cache ca-certificates tzdata
25
-
26
- # Crear un usuario no root (Requisito de Hugging Face Spaces para seguridad)
27
- RUN adduser -D user
28
- USER user
29
- WORKDIR /home/user/app
30
-
31
- # Copiar el archivo compilado desde el builder
32
- COPY --from=builder --chown=user:user /app/fsb /home/user/app/fsb
33
- # Copiar el archivo .sample.env configurado a la carpeta del bot (que es el que viene por defecto)
34
- # O si el usuario ya tiene su fsb.env renombrado, copiamos todo
35
- COPY --chown=user:user *.env /home/user/app/
36
- RUN mv /home/user/app/fsb.sample.env /home/user/app/fsb.env || true
37
-
38
- # Configurar el puerto requerido por Hugging Face y la variable local
39
- ENV PORT=7860
40
- EXPOSE 7860
41
-
42
- # Comando para iniciar la aplicación
43
- CMD ["./fsb", "run"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/LICENSE DELETED
@@ -1,661 +0,0 @@
1
- GNU AFFERO GENERAL PUBLIC LICENSE
2
- Version 3, 19 November 2007
3
-
4
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
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> <EverythingSuckz>
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 <http://www.gnu.org/licenses/>.
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
- <http://www.gnu.org/licenses/>.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/Procfile DELETED
@@ -1 +0,0 @@
1
- web: fsb run
 
 
test-clone/README.md DELETED
@@ -1,42 +0,0 @@
1
- ---
2
- title: BrodyFileStreamBot
3
- emoji: 🚀
4
- colorFrom: blue
5
- colorTo: purple
6
- sdk: docker
7
- app_port: 8080
8
- pinned: false
9
- ---
10
- <h1 align="center">Telegram File Stream Bot</h1>
11
- <p align="center">
12
- </a>
13
- <p align="center">
14
- <a herf="https://github.com/EverythingSuckz/TG-FileStreamBot">
15
- <img src="https://filestream.bot/logo.svg" height="100" width="100" alt="File Stream Bot Logo">
16
- </a>
17
- </p>
18
- <p align="center">
19
- A Telegram bot to <b>generate direct link</b> for your Telegram files.
20
- <br />
21
- << <a href="https://filestream.bot/getting-started">Visit docs</a> | <a href="https://filestream.bot/support">Support</a> >>
22
- </p>
23
- </p>
24
-
25
-
26
-
27
-
28
- ## Credits
29
-
30
- - [@celestix](https://github.com/celestix) for [gotgproto](https://github.com/celestix/gotgproto)
31
- - [@divyam234](https://github.com/divyam234/teldrive) for his [Teldrive](https://github.com/divyam234/teldrive) Project
32
- - [@krau](https://github.com/krau) for adding image support
33
-
34
- ## Copyright
35
-
36
- Copyright (C) 2026 [EverythingSuckz](https://github.com/EverythingSuckz) under [GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.en.html).
37
-
38
- TG-FileStreamBot is Free Software: You can use, study share and improve it at your
39
- will. Specifically you can redistribute and/or modify it under the terms of the
40
- [GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.en.html) as
41
- published by the Free Software Foundation, either version 3 of the License, or
42
- (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.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/app.json DELETED
@@ -1,55 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/cmd/fsb/main.go DELETED
@@ -1,37 +0,0 @@
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.2.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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/cmd/fsb/run.go DELETED
@@ -1,80 +0,0 @@
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
- // initialize logger early so config loading is logged to file
31
- utils.InitLogger(false)
32
- config.Load(utils.Logger, cmd)
33
- // reinitialize with correct dev mode
34
- utils.InitLogger(config.ValueOf.Dev)
35
- log := utils.Logger
36
- mainLogger := log.Named("Main")
37
- mainLogger.Info("Starting server")
38
- router := getRouter(log)
39
-
40
- mainBot, err := bot.StartClient(log)
41
- if err != nil {
42
- log.Sugar().Fatalf("Failed to start main bot: %v", err)
43
- }
44
- cache.InitCache(log)
45
- workers, err := bot.StartWorkers(log)
46
- if err != nil {
47
- log.Sugar().Fatalf("Failed to start workers: %v", err)
48
- }
49
- workers.AddDefaultClient(mainBot, mainBot.Self)
50
- bot.StartUserBot(log)
51
- fmt.Println("\n✅ Bot Conectado y Listo.")
52
- fmt.Printf("🌍 Servidor Fantasma Aiohttp activo en puerto %d\n\n", config.ValueOf.Port)
53
- mainLogger.Info("Server started", zap.Int("port", config.ValueOf.Port))
54
- mainLogger.Info("File Stream Bot", zap.String("version", versionString))
55
- mainLogger.Sugar().Infof("Server is running at %s", config.ValueOf.Host)
56
- err = router.Run(fmt.Sprintf("0.0.0.0:%d", config.ValueOf.Port))
57
- if err != nil {
58
- mainLogger.Sugar().Fatalf("Server failed to start: %v", err)
59
- }
60
- }
61
-
62
- func getRouter(log *zap.Logger) *gin.Engine {
63
- if config.ValueOf.Dev {
64
- gin.SetMode(gin.DebugMode)
65
- } else {
66
- gin.SetMode(gin.ReleaseMode)
67
- }
68
- router := gin.Default()
69
- router.Use(gin.ErrorLogger())
70
- router.GET("/", func(ctx *gin.Context) {
71
- ctx.JSON(http.StatusOK, types.RootResponse{
72
- Message: "Server is running.",
73
- Ok: true,
74
- Uptime: utils.TimeFormat(uint64(time.Since(startTime).Seconds())),
75
- Version: versionString,
76
- })
77
- })
78
- routes.Load(log, router)
79
- return router
80
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/cmd/fsb/session.go DELETED
@@ -1,41 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/config/config.go DELETED
@@ -1,305 +0,0 @@
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
- // stream specific config
56
- StreamConcurrency int `envconfig:"STREAM_CONCURRENCY" default:"4"`
57
- StreamBufferCount int `envconfig:"STREAM_BUFFER_COUNT" default:"8"`
58
- StreamTimeoutSec int `envconfig:"STREAM_TIMEOUT_SEC" default:"30"`
59
- StreamMaxRetries int `envconfig:"STREAM_MAX_RETRIES" default:"3"`
60
- }
61
-
62
- var botTokenRegex = regexp.MustCompile(`MULTI\_TOKEN\d+=(.*)`)
63
-
64
- func (c *config) loadFromEnvFile(log *zap.Logger) {
65
- envPath := filepath.Clean("fsb.env")
66
- log.Sugar().Infof("Trying to load ENV vars from %s", envPath)
67
- err := godotenv.Load(envPath)
68
- if err != nil {
69
- if os.IsNotExist(err) {
70
- log.Sugar().Errorf("ENV file not found: %s", envPath)
71
- log.Sugar().Info("Please create fsb.env file")
72
- log.Sugar().Info("For more info, refer: https://github.com/EverythingSuckz/TG-FileStreamBot/tree/golang#setting-up-things")
73
- log.Sugar().Info("Please ignore this message if you are hosting it in a service like Heroku or other alternatives.")
74
- } else {
75
- log.Fatal("Unknown error while parsing env file.", zap.Error(err))
76
- }
77
- }
78
- }
79
-
80
- func SetFlagsFromConfig(cmd *cobra.Command) {
81
- cmd.Flags().Int32("api-id", ValueOf.ApiID, "Telegram API ID")
82
- cmd.Flags().String("api-hash", ValueOf.ApiHash, "Telegram API Hash")
83
- cmd.Flags().String("bot-token", ValueOf.BotToken, "Telegram Bot Token")
84
- cmd.Flags().Int64("log-channel", ValueOf.LogChannelID, "Telegram Log Channel ID")
85
- cmd.Flags().Bool("dev", ValueOf.Dev, "Enable development mode")
86
- cmd.Flags().IntP("port", "p", ValueOf.Port, "Server port")
87
- cmd.Flags().String("host", ValueOf.Host, "Server host that will be included in links")
88
- cmd.Flags().Int("hash-length", ValueOf.HashLength, "Hash length in links")
89
- cmd.Flags().Bool("use-session-file", ValueOf.UseSessionFile, "Use session files")
90
- cmd.Flags().String("user-session", ValueOf.UserSession, "Pyrogram user session")
91
- cmd.Flags().Bool("use-public-ip", ValueOf.UsePublicIP, "Use public IP instead of local IP")
92
- cmd.Flags().String("multi-token-txt-file", "", "Multi token txt file (Not implemented)")
93
- cmd.Flags().Int("stream-concurrency", ValueOf.StreamConcurrency, "Number of parallel block fetches")
94
- cmd.Flags().Int("stream-buffer-count", ValueOf.StreamBufferCount, "Number of blocks to prefetch")
95
- cmd.Flags().Int("stream-timeout-sec", ValueOf.StreamTimeoutSec, "Maximum time to wait for a single block (in seconds)")
96
- cmd.Flags().Int("stream-max-retries", ValueOf.StreamMaxRetries, "Number of retry attempts for failed fetches")
97
- }
98
-
99
- func (c *config) loadConfigFromArgs(log *zap.Logger, cmd *cobra.Command) {
100
- apiID, _ := cmd.Flags().GetInt32("api-id")
101
- if apiID != 0 {
102
- os.Setenv("API_ID", strconv.Itoa(int(apiID)))
103
- }
104
- apiHash, _ := cmd.Flags().GetString("api-hash")
105
- if apiHash != "" {
106
- os.Setenv("API_HASH", apiHash)
107
- }
108
- botToken, _ := cmd.Flags().GetString("bot-token")
109
- if botToken != "" {
110
- os.Setenv("BOT_TOKEN", botToken)
111
- }
112
- logChannelID, _ := cmd.Flags().GetString("log-channel")
113
- if logChannelID != "" {
114
- os.Setenv("LOG_CHANNEL", logChannelID)
115
- }
116
- dev, _ := cmd.Flags().GetBool("dev")
117
- if dev {
118
- os.Setenv("DEV", strconv.FormatBool(dev))
119
- }
120
- port, _ := cmd.Flags().GetInt("port")
121
- if port != 0 {
122
- os.Setenv("PORT", strconv.Itoa(port))
123
- }
124
- host, _ := cmd.Flags().GetString("host")
125
- if host != "" {
126
- os.Setenv("HOST", host)
127
- }
128
- hashLength, _ := cmd.Flags().GetInt("hash-length")
129
- if hashLength != 0 {
130
- os.Setenv("HASH_LENGTH", strconv.Itoa(hashLength))
131
- }
132
- useSessionFile, _ := cmd.Flags().GetBool("use-session-file")
133
- if useSessionFile {
134
- os.Setenv("USE_SESSION_FILE", strconv.FormatBool(useSessionFile))
135
- }
136
- userSession, _ := cmd.Flags().GetString("user-session")
137
- if userSession != "" {
138
- os.Setenv("USER_SESSION", userSession)
139
- }
140
- usePublicIP, _ := cmd.Flags().GetBool("use-public-ip")
141
- if usePublicIP {
142
- os.Setenv("USE_PUBLIC_IP", strconv.FormatBool(usePublicIP))
143
- }
144
- multiTokens, _ := cmd.Flags().GetString("multi-token-txt-file")
145
- if multiTokens != "" {
146
- os.Setenv("MULTI_TOKEN_TXT_FILE", multiTokens)
147
- // TODO: Add support for importing tokens from a separate file
148
- }
149
- streamConcurrency, _ := cmd.Flags().GetInt("stream-concurrency")
150
- if streamConcurrency != 0 {
151
- os.Setenv("STREAM_CONCURRENCY", strconv.Itoa(streamConcurrency))
152
- }
153
- streamBufferCount, _ := cmd.Flags().GetInt("stream-buffer-count")
154
- if streamBufferCount != 0 {
155
- os.Setenv("STREAM_BUFFER_COUNT", strconv.Itoa(streamBufferCount))
156
- }
157
- streamTimeoutSec, _ := cmd.Flags().GetInt("stream-timeout-sec")
158
- if streamTimeoutSec != 0 {
159
- os.Setenv("STREAM_TIMEOUT_SEC", strconv.Itoa(streamTimeoutSec))
160
- }
161
- streamMaxRetries, _ := cmd.Flags().GetInt("stream-max-retries")
162
- if streamMaxRetries != 0 {
163
- os.Setenv("STREAM_MAX_RETRIES", strconv.Itoa(streamMaxRetries))
164
- }
165
- }
166
-
167
- func (c *config) setupEnvVars(log *zap.Logger, cmd *cobra.Command) {
168
- c.loadFromEnvFile(log)
169
- c.loadConfigFromArgs(log, cmd)
170
- err := envconfig.Process("", c)
171
- if err != nil {
172
- log.Fatal("Error while parsing env variables", zap.Error(err))
173
- }
174
- var ipBlocked bool
175
- ip, err := getIP(c.UsePublicIP)
176
- if err != nil {
177
- log.Error("Error while getting IP", zap.Error(err))
178
- ipBlocked = true
179
- }
180
- if c.Host == "" {
181
- c.Host = "http://" + ip + ":" + strconv.Itoa(c.Port)
182
- if c.UsePublicIP {
183
- if ipBlocked {
184
- log.Sugar().Warn("Can't get public IP, using local IP")
185
- } else {
186
- log.Sugar().Warn("You are using a public IP, please be aware of the security risks while exposing your IP to the internet.")
187
- log.Sugar().Warn("Use 'HOST' variable to set a domain name")
188
- }
189
- }
190
- log.Sugar().Info("HOST not set, automatically set to " + c.Host)
191
- }
192
- val := reflect.ValueOf(c).Elem()
193
- for _, env := range os.Environ() {
194
- if strings.HasPrefix(env, "MULTI_TOKEN") {
195
- c.MultiTokens = append(c.MultiTokens, botTokenRegex.FindStringSubmatch(env)[1])
196
- }
197
- }
198
- val.FieldByName("MultiTokens").Set(reflect.ValueOf(c.MultiTokens))
199
- }
200
-
201
- func Load(log *zap.Logger, cmd *cobra.Command) {
202
- log = log.Named("Config")
203
- defer log.Info("Loaded config")
204
- ValueOf.setupEnvVars(log, cmd)
205
- ValueOf.LogChannelID = int64(stripInt(log, int(ValueOf.LogChannelID)))
206
- if ValueOf.HashLength == 0 {
207
- log.Sugar().Info("HASH_LENGTH can't be 0, defaulting to 6")
208
- ValueOf.HashLength = 6
209
- }
210
- if ValueOf.HashLength > 32 {
211
- log.Sugar().Info("HASH_LENGTH can't be more than 32, changing to 32")
212
- ValueOf.HashLength = 32
213
- }
214
- if ValueOf.HashLength < 5 {
215
- log.Sugar().Info("HASH_LENGTH can't be less than 5, defaulting to 6")
216
- ValueOf.HashLength = 6
217
- }
218
- if ValueOf.StreamConcurrency <= 0 {
219
- log.Sugar().Info("STREAM_CONCURRENCY must be greater than 0, defaulting to 4")
220
- ValueOf.StreamConcurrency = 4
221
- }
222
- if ValueOf.StreamBufferCount <= 0 {
223
- log.Sugar().Info("STREAM_BUFFER_COUNT must be greater than 0, defaulting to 8")
224
- ValueOf.StreamBufferCount = 8
225
- }
226
- if ValueOf.StreamTimeoutSec <= 0 {
227
- log.Sugar().Info("STREAM_TIMEOUT_SEC must be greater than 0, defaulting to 30 seconds")
228
- ValueOf.StreamTimeoutSec = 30
229
- }
230
- if ValueOf.StreamMaxRetries <= 0 {
231
- log.Sugar().Info("STREAM_MAX_RETRIES must be greater than 0, defaulting to 3")
232
- ValueOf.StreamMaxRetries = 3
233
- }
234
- }
235
-
236
- func getIP(public bool) (string, error) {
237
- var ip string
238
- var err error
239
- if public {
240
- ip, err = GetPublicIP()
241
- } else {
242
- ip, err = getInternalIP()
243
- }
244
- if ip == "" {
245
- ip = "localhost"
246
- }
247
- if err != nil {
248
- return "localhost", err
249
- }
250
- return ip, nil
251
- }
252
-
253
- // https://stackoverflow.com/a/23558495/15807350
254
- func getInternalIP() (string, error) {
255
- conn, err := net.Dial("udp", "8.8.8.8:80")
256
- if err != nil {
257
- return "", errors.New("no internet connection")
258
- }
259
- defer conn.Close()
260
- localAddr := conn.LocalAddr().(*net.UDPAddr)
261
- return localAddr.IP.String(), nil
262
- }
263
-
264
- func GetPublicIP() (string, error) {
265
- resp, err := http.Get("https://api.ipify.org?format=text")
266
- if err != nil {
267
- return "", err
268
- }
269
- defer resp.Body.Close()
270
- ip, err := io.ReadAll(resp.Body)
271
- if err != nil {
272
- return "", err
273
- }
274
- if !checkIfIpAccessible(string(ip)) {
275
- return string(ip), errors.New("PORT is blocked by firewall")
276
- }
277
- return string(ip), nil
278
- }
279
-
280
- func checkIfIpAccessible(ip string) bool {
281
- conn, err := net.Dial("tcp", ip+":80")
282
- if err != nil {
283
- return false
284
- }
285
- defer conn.Close()
286
- return true
287
- }
288
-
289
- func stripInt(log *zap.Logger, a int) int {
290
- strA := strconv.Itoa(abs(a))
291
- lastDigits := strings.Replace(strA, "100", "", 1)
292
- result, err := strconv.Atoi(lastDigits)
293
- if err != nil {
294
- log.Sugar().Fatalln(err)
295
- return 0
296
- }
297
- return result
298
- }
299
-
300
- func abs(x int) int {
301
- if x < 0 {
302
- return -x
303
- }
304
- return x
305
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/docker-compose.yaml DELETED
@@ -1,15 +0,0 @@
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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/fsb.env DELETED
@@ -1,60 +0,0 @@
1
- # Required Variables (DO NOT SKIP THESE)
2
-
3
- API_ID=33226415
4
- API_HASH=01999dae3e5348c7ab0dbcc6f7f4edc5
5
- BOT_TOKEN=8756843866:AAHzRAEvsHGDJ1-K4nQzyUlSLZN0UWbvohE
6
- LOG_CHANNEL=-1003824889674
7
-
8
- # Optional Variables
9
-
10
- DEV=false
11
- PORT=7860
12
-
13
- # The length of the hash in your URLs
14
- # https://domain.tld/1254?hash=asd45a
15
- # ^^^^^^
16
- # /
17
- # This is the hash
18
-
19
- HASH_LENGTH=6
20
-
21
- # you can use IP address
22
- # HOST=http://<ip address>:<PORT>
23
- # Or you can also use a domain name
24
- # HOST=https://example.com
25
-
26
- # Use public IP while auto-generating HOST (not recommended unless needed)
27
- USE_PUBLIC_IP=false
28
-
29
- # Reuse worker sessions from files (faster startup)
30
- USE_SESSION_FILE=true
31
-
32
- # Optional user session string for userbot features
33
- # USER_SESSION=
34
-
35
- # Optional allowlist of Telegram user IDs (comma-separated)
36
- # ALLOWED_USERS=12345,67890
37
-
38
- # Stream performance tuning
39
- # STREAM_CONCURRENCY = parallel Telegram chunk downloads per stream request
40
- # STREAM_BUFFER_COUNT = how many chunks to keep ready in memory
41
- # STREAM_TIMEOUT_SEC = per-chunk timeout (seconds)
42
- # STREAM_MAX_RETRIES = retries per failed chunk
43
- #
44
- # Good default:
45
- # STREAM_CONCURRENCY=4
46
- # STREAM_BUFFER_COUNT=8
47
- # STREAM_TIMEOUT_SEC=30
48
- # STREAM_MAX_RETRIES=3
49
- STREAM_CONCURRENCY=4
50
- STREAM_BUFFER_COUNT=8
51
- STREAM_TIMEOUT_SEC=30
52
- STREAM_MAX_RETRIES=3
53
-
54
- # For muti token support
55
- # Refer https://github.com/EverythingSuckz/TG-FileStreamBot/tree/golang#use-multiple-bots-to-speed-up
56
-
57
- # MULTI_TOKEN1=1857821156:AAEvrINCsduhjkjhahadvHRdk7oF46KZnc
58
- # MULTI_TOKEN2=1355359001:AAF4dgddVVxDCt51FZqy1unh9h0SOTw0gU
59
- # MULTI_TOKEN3=6941936497:AAGJzfoMHXshS8gVcsefUzpwyrbfU7gKRMM
60
- # MULTI_TOKEN4=6546079247:AAF2k3uvO9Hqadfhjaskjds8jnzOAfQYUzTZ
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/fsb.sample.env DELETED
@@ -1,60 +0,0 @@
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
- DEV=false
11
- PORT=8080
12
-
13
- # The length of the hash in your URLs
14
- # https://domain.tld/1254?hash=asd45a
15
- # ^^^^^^
16
- # /
17
- # This is the hash
18
-
19
- HASH_LENGTH=6
20
-
21
- # you can use IP address
22
- # HOST=http://<ip address>:<PORT>
23
- # Or you can also use a domain name
24
- # HOST=https://example.com
25
-
26
- # Use public IP while auto-generating HOST (not recommended unless needed)
27
- USE_PUBLIC_IP=false
28
-
29
- # Reuse worker sessions from files (faster startup)
30
- USE_SESSION_FILE=true
31
-
32
- # Optional user session string for userbot features
33
- # USER_SESSION=
34
-
35
- # Optional allowlist of Telegram user IDs (comma-separated)
36
- # ALLOWED_USERS=12345,67890
37
-
38
- # Stream performance tuning
39
- # STREAM_CONCURRENCY = parallel Telegram chunk downloads per stream request
40
- # STREAM_BUFFER_COUNT = how many chunks to keep ready in memory
41
- # STREAM_TIMEOUT_SEC = per-chunk timeout (seconds)
42
- # STREAM_MAX_RETRIES = retries per failed chunk
43
- #
44
- # Good default:
45
- # STREAM_CONCURRENCY=4
46
- # STREAM_BUFFER_COUNT=8
47
- # STREAM_TIMEOUT_SEC=30
48
- # STREAM_MAX_RETRIES=3
49
- STREAM_CONCURRENCY=4
50
- STREAM_BUFFER_COUNT=8
51
- STREAM_TIMEOUT_SEC=30
52
- STREAM_MAX_RETRIES=3
53
-
54
- # For muti token support
55
- # Refer https://github.com/EverythingSuckz/TG-FileStreamBot/tree/golang#use-multiple-bots-to-speed-up
56
-
57
- # MULTI_TOKEN1=1857821156:AAEvrINCsduhjkjhahadvHRdk7oF46KZnc
58
- # MULTI_TOKEN2=1355359001:AAF4dgddVVxDCt51FZqy1unh9h0SOTw0gU
59
- # MULTI_TOKEN3=6941936497:AAGJzfoMHXshS8gVcsefUzpwyrbfU7gKRMM
60
- # MULTI_TOKEN4=6546079247:AAF2k3uvO9Hqadfhjaskjds8jnzOAfQYUzTZ
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/fsb.session DELETED
Binary file (24.6 kB)
 
test-clone/go.mod DELETED
@@ -1,95 +0,0 @@
1
- module EverythingSuckz/fsb
2
-
3
- go 1.25.0
4
-
5
- require (
6
- github.com/celestix/gotgproto v1.0.0-beta21
7
- github.com/gin-gonic/gin v1.9.1
8
- github.com/glebarez/sqlite v1.11.0
9
- github.com/gotd/td v0.132.0
10
- github.com/joho/godotenv v1.5.1
11
- github.com/kelseyhightower/envconfig v1.4.0
12
- github.com/quantumsheep/range-parser v1.1.0
13
- github.com/spf13/cobra v1.8.0
14
- )
15
-
16
- require (
17
- github.com/AnimeKaizoku/cacher v1.0.3 // indirect
18
- github.com/cenkalti/backoff/v4 v4.3.0 // indirect
19
- github.com/cespare/xxhash/v2 v2.2.0 // indirect
20
- github.com/chenzhuoyu/iasm v0.9.1 // indirect
21
- github.com/coder/websocket v1.8.14 // indirect
22
- github.com/dlclark/regexp2 v1.11.5 // indirect
23
- github.com/dustin/go-humanize v1.0.1 // indirect
24
- github.com/fatih/color v1.18.0 // indirect
25
- github.com/ghodss/yaml v1.0.0 // indirect
26
- github.com/glebarez/go-sqlite v1.22.0 // indirect
27
- github.com/go-faster/errors v0.7.1 // indirect
28
- github.com/go-faster/jx v1.1.0 // indirect
29
- github.com/go-faster/xor v1.0.0 // indirect
30
- github.com/go-faster/yaml v0.4.6 // indirect
31
- github.com/google/uuid v1.6.0 // indirect
32
- github.com/gotd/ige v0.2.2 // indirect
33
- github.com/gotd/neo v0.1.5 // indirect
34
- github.com/inconshreveable/mousetrap v1.1.0 // indirect
35
- github.com/jinzhu/inflection v1.0.0 // indirect
36
- github.com/jinzhu/now v1.1.5 // indirect
37
- github.com/klauspost/compress v1.18.0 // indirect
38
- github.com/mattn/go-colorable v0.1.14 // indirect
39
- github.com/ncruces/go-strftime v1.0.0 // indirect
40
- github.com/ogen-go/ogen v1.16.0 // indirect
41
- github.com/pkg/errors v0.9.1 // indirect
42
- github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
43
- github.com/segmentio/asm v1.2.1 // indirect
44
- github.com/shopspring/decimal v1.4.0 // indirect
45
- github.com/spf13/pflag v1.0.5 // indirect
46
- go.opentelemetry.io/otel v1.38.0 // indirect
47
- go.opentelemetry.io/otel/metric v1.38.0 // indirect
48
- go.opentelemetry.io/otel/trace v1.38.0 // indirect
49
- go.uber.org/atomic v1.11.0 // indirect
50
- go.uber.org/multierr v1.11.0 // indirect
51
- golang.org/x/exp v0.0.0-20251009144603-d2f985daa21b // indirect
52
- golang.org/x/mod v0.29.0 // indirect
53
- golang.org/x/sync v0.17.0 // indirect
54
- golang.org/x/tools v0.38.0 // indirect
55
- gopkg.in/yaml.v2 v2.4.0 // indirect
56
- gorm.io/gorm v1.31.0 // indirect
57
- modernc.org/libc v1.66.10 // indirect
58
- modernc.org/mathutil v1.7.1 // indirect
59
- modernc.org/memory v1.11.0 // indirect
60
- modernc.org/sqlite v1.39.1 // indirect
61
- rsc.io/qr v0.2.0 // indirect
62
- )
63
-
64
- require (
65
- github.com/bytedance/sonic v1.10.2 // indirect
66
- github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
67
- github.com/coocood/freecache v1.2.4
68
- github.com/gabriel-vasile/mimetype v1.4.3 // indirect
69
- github.com/gin-contrib/sse v0.1.0 // indirect
70
- github.com/go-playground/locales v0.14.1 // indirect
71
- github.com/go-playground/universal-translator v0.18.1 // indirect
72
- github.com/go-playground/validator/v10 v10.18.0 // indirect
73
- github.com/goccy/go-json v0.10.2 // indirect
74
- github.com/gotd/contrib v0.19.0
75
- github.com/json-iterator/go v1.1.12 // indirect
76
- github.com/klauspost/cpuid/v2 v2.2.7 // indirect
77
- github.com/leodido/go-urn v1.4.0 // indirect
78
- github.com/mattn/go-isatty v0.0.20 // indirect
79
- github.com/mdp/qrterminal v1.0.1
80
- github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
81
- github.com/modern-go/reflect2 v1.0.2 // indirect
82
- github.com/pelletier/go-toml/v2 v2.1.1 // indirect
83
- github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
84
- github.com/ugorji/go/codec v1.2.12 // indirect
85
- go.uber.org/zap v1.27.0
86
- golang.org/x/arch v0.7.0 // indirect
87
- golang.org/x/crypto v0.43.0 // indirect
88
- golang.org/x/net v0.46.0 // indirect
89
- golang.org/x/sys v0.37.0 // indirect
90
- golang.org/x/text v0.30.0 // indirect
91
- golang.org/x/time v0.5.0
92
- google.golang.org/protobuf v1.32.0 // indirect
93
- gopkg.in/natefinch/lumberjack.v2 v2.2.1
94
- gopkg.in/yaml.v3 v3.0.1 // indirect
95
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/go.sum DELETED
@@ -1,245 +0,0 @@
1
- github.com/AnimeKaizoku/cacher v1.0.3 h1:foNAmLfY/DXfA4yEy4uP6WK2Ni7JC+s3QhZv72Dn6zs=
2
- github.com/AnimeKaizoku/cacher v1.0.3/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-beta21 h1:VUuAC/Kj5Sdu/WZan3ZUb0GFNAavFxMYxmHAhCBX0J8=
8
- github.com/celestix/gotgproto v1.0.0-beta21/go.mod h1:viDkHe9rBegJoEE/jNuFfbBM0XZ3pSx/ugjaNaVnbvU=
9
- github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
10
- github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
11
- github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
12
- github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
13
- github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
14
- github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
15
- github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
16
- github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d h1:77cEq6EriyTZ0g/qfRdp61a3Uu/AWrgIq2s0ClJV1g0=
17
- github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d/go.mod h1:8EPpVsBuRksnlj1mLy4AWzRNQYxauNi62uWcE3to6eA=
18
- github.com/chenzhuoyu/iasm v0.9.0/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog=
19
- github.com/chenzhuoyu/iasm v0.9.1 h1:tUHQJXo3NhBqw6s33wkGn9SP3bvrWLdlVIJ3hQBL7P0=
20
- github.com/chenzhuoyu/iasm v0.9.1/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog=
21
- github.com/coder/websocket v1.8.14 h1:9L0p0iKiNOibykf283eHkKUHHrpG7f65OE3BhhO7v9g=
22
- github.com/coder/websocket v1.8.14/go.mod h1:NX3SzP+inril6yawo5CQXx8+fk145lPDC6pumgx0mVg=
23
- github.com/coocood/freecache v1.2.4 h1:UdR6Yz/X1HW4fZOuH0Z94KwG851GWOSknua5VUbb/5M=
24
- github.com/coocood/freecache v1.2.4/go.mod h1:RBUWa/Cy+OHdfTGFEhEuE1pMCMX51Ncizj7rthiQ3vk=
25
- github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
26
- github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
27
- github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
28
- github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
29
- github.com/dlclark/regexp2 v1.11.5 h1:Q/sSnsKerHeCkc/jSTNq1oCm7KiVgUMZRDUoRu0JQZQ=
30
- github.com/dlclark/regexp2 v1.11.5/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
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/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
34
- github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
35
- github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
36
- github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
37
- github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
38
- github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
39
- github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
40
- github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
41
- github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg=
42
- github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU=
43
- github.com/glebarez/go-sqlite v1.22.0 h1:uAcMJhaA6r3LHMTFgP0SifzgXg46yJkgxqyuyec+ruQ=
44
- github.com/glebarez/go-sqlite v1.22.0/go.mod h1:PlBIdHe0+aUEFn+r2/uthrWq4FxbzugL0L8Li6yQJbc=
45
- github.com/glebarez/sqlite v1.11.0 h1:wSG0irqzP6VurnMEpFGer5Li19RpIRi2qvQz++w0GMw=
46
- github.com/glebarez/sqlite v1.11.0/go.mod h1:h8/o8j5wiAsqSPoWELDUdJXhjAhsVliSn7bWZjOhrgQ=
47
- github.com/go-faster/errors v0.7.1 h1:MkJTnDoEdi9pDabt1dpWf7AA8/BaSYZqibYyhZ20AYg=
48
- github.com/go-faster/errors v0.7.1/go.mod h1:5ySTjWFiphBs07IKuiL69nxdfd5+fzh1u7FPGZP2quo=
49
- github.com/go-faster/jx v1.1.0 h1:ZsW3wD+snOdmTDy9eIVgQdjUpXRRV4rqW8NS3t+20bg=
50
- github.com/go-faster/jx v1.1.0/go.mod h1:vKDNikrKoyUmpzaJ0OkIkRQClNHFX/nF3dnTJZb3skg=
51
- github.com/go-faster/xor v0.3.0/go.mod h1:x5CaDY9UKErKzqfRfFZdfu+OSTfoZny3w5Ak7UxcipQ=
52
- github.com/go-faster/xor v1.0.0 h1:2o8vTOgErSGHP3/7XwA5ib1FTtUsNtwCoLLBjl31X38=
53
- github.com/go-faster/xor v1.0.0/go.mod h1:x5CaDY9UKErKzqfRfFZdfu+OSTfoZny3w5Ak7UxcipQ=
54
- github.com/go-faster/yaml v0.4.6 h1:lOK/EhI04gCpPgPhgt0bChS6bvw7G3WwI8xxVe0sw9I=
55
- github.com/go-faster/yaml v0.4.6/go.mod h1:390dRIvV4zbnO7qC9FGo6YYutc+wyyUSHBgbXL52eXk=
56
- github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
57
- github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
58
- github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
59
- github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
60
- github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
61
- github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
62
- github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
63
- github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
64
- github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
65
- github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
66
- github.com/go-playground/validator/v10 v10.18.0 h1:BvolUXjp4zuvkZ5YN5t7ebzbhlUtPsPm2S9NAZ5nl9U=
67
- github.com/go-playground/validator/v10 v10.18.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
68
- github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
69
- github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
70
- github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
71
- github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
72
- github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
73
- github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e h1:ijClszYn+mADRFY17kjQEVQ1XRhq2/JR1M3sGqeJoxs=
74
- github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA=
75
- github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
76
- github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
77
- github.com/gotd/contrib v0.19.0 h1:O6GvMrRVeFslIHLUcpaHVzcl9/5PcgR2jQTIIeTyds0=
78
- github.com/gotd/contrib v0.19.0/go.mod h1:LzPxzRF0FvtpBt/WyODWQnPpk0tm/G9z6RHUoPqMakU=
79
- github.com/gotd/ige v0.2.2 h1:XQ9dJZwBfDnOGSTxKXBGP4gMud3Qku2ekScRjDWWfEk=
80
- github.com/gotd/ige v0.2.2/go.mod h1:tuCRb+Y5Y3eNTo3ypIfNpQ4MFjrnONiL2jN2AKZXmb0=
81
- github.com/gotd/neo v0.1.5 h1:oj0iQfMbGClP8xI59x7fE/uHoTJD7NZH9oV1WNuPukQ=
82
- github.com/gotd/neo v0.1.5/go.mod h1:9A2a4bn9zL6FADufBdt7tZt+WMhvZoc5gWXihOPoiBQ=
83
- github.com/gotd/td v0.132.0 h1:Iqm3S2b+8kDgA9237IDXRxj7sryUpvy+4Cr50/0tpx4=
84
- github.com/gotd/td v0.132.0/go.mod h1:4CDGYS+rDtOqotRheGaF9MS5g6jaUewvSXqBNJnx8SQ=
85
- github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
86
- github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
87
- github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
88
- github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
89
- github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
90
- github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
91
- github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
92
- github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
93
- github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
94
- github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
95
- github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8=
96
- github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg=
97
- github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
98
- github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
99
- github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
100
- github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
101
- github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
102
- github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
103
- github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
104
- github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
105
- github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
106
- github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
107
- github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
108
- github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
109
- github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
110
- github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
111
- github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
112
- github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
113
- github.com/mdp/qrterminal v1.0.1 h1:07+fzVDlPuBlXS8tB0ktTAyf+Lp1j2+2zK3fBOL5b7c=
114
- github.com/mdp/qrterminal v1.0.1/go.mod h1:Z33WhxQe9B6CdW37HaVqcRKzP+kByF3q/qLxOGe12xQ=
115
- github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
116
- github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
117
- github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
118
- github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
119
- github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
120
- github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFAw7w=
121
- github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
122
- github.com/ogen-go/ogen v1.16.0 h1:fKHEYokW/QrMzVNXId74/6RObRIUs9T2oroGKtR25Iw=
123
- github.com/ogen-go/ogen v1.16.0/go.mod h1:s3nWiMzybSf8fhxckyO+wtto92+QHpEL8FmkPnhL3jI=
124
- github.com/pelletier/go-toml/v2 v2.1.1 h1:LWAJwfNvjQZCFIDKWYQaM62NcYeYViCmWIwmOStowAI=
125
- github.com/pelletier/go-toml/v2 v2.1.1/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
126
- github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
127
- github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
128
- github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
129
- github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
130
- github.com/quantumsheep/range-parser v1.1.0 h1:k4f1F58f8FF54FBYc9dYBRM+8JkAxFo11gC3IeMH4rU=
131
- github.com/quantumsheep/range-parser v1.1.0/go.mod h1:acv4Vt2PvpGvRsvGju7Gk2ahKluZJsIUNR69W53J22I=
132
- github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
133
- github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
134
- github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
135
- github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
136
- github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
137
- github.com/segmentio/asm v1.2.1 h1:DTNbBqs57ioxAD4PrArqftgypG4/qNpXoJx8TVXxPR0=
138
- github.com/segmentio/asm v1.2.1/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs=
139
- github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
140
- github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
141
- github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
142
- github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
143
- github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
144
- github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
145
- github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
146
- github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
147
- github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
148
- github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
149
- github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
150
- github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
151
- github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
152
- github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
153
- github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
154
- github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
155
- github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
156
- github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
157
- github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
158
- github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
159
- github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
160
- go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
161
- go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
162
- go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8=
163
- go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM=
164
- go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA=
165
- go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI=
166
- go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE=
167
- go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs=
168
- go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
169
- go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
170
- go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
171
- go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
172
- go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
173
- go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
174
- go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
175
- go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
176
- golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
177
- golang.org/x/arch v0.7.0 h1:pskyeJh/3AmoQ8CPE95vxHLqp1G1GfGNXTmcl9NEKTc=
178
- golang.org/x/arch v0.7.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
179
- golang.org/x/crypto v0.43.0 h1:dduJYIi3A3KOfdGOHX8AVZ/jGiyPa3IbBozJ5kNuE04=
180
- golang.org/x/crypto v0.43.0/go.mod h1:BFbav4mRNlXJL4wNeejLpWxB7wMbc79PdRGhWKncxR0=
181
- golang.org/x/exp v0.0.0-20251009144603-d2f985daa21b h1:18qgiDvlvH7kk8Ioa8Ov+K6xCi0GMvmGfGW0sgd/SYA=
182
- golang.org/x/exp v0.0.0-20251009144603-d2f985daa21b/go.mod h1:j/pmGrbnkbPtQfxEe5D0VQhZC6qKbfKifgD0oM7sR70=
183
- golang.org/x/mod v0.29.0 h1:HV8lRxZC4l2cr3Zq1LvtOsi/ThTgWnUk/y64QSs8GwA=
184
- golang.org/x/mod v0.29.0/go.mod h1:NyhrlYXJ2H4eJiRy/WDBO6HMqZQ6q9nk4JzS3NuCK+w=
185
- golang.org/x/net v0.46.0 h1:giFlY12I07fugqwPuWJi68oOnpfqFnJIJzaIIm2JVV4=
186
- golang.org/x/net v0.46.0/go.mod h1:Q9BGdFy1y4nkUwiLvT5qtyhAnEHgnQ/zd8PfU6nc210=
187
- golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
188
- golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
189
- golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
190
- golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
191
- golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
192
- golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ=
193
- golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
194
- golang.org/x/text v0.30.0 h1:yznKA/E9zq54KzlzBEAWn1NXSQ8DIp/NYMy88xJjl4k=
195
- golang.org/x/text v0.30.0/go.mod h1:yDdHFIX9t+tORqspjENWgzaCVXgk0yYnYuSZ8UzzBVM=
196
- golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
197
- golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
198
- golang.org/x/tools v0.38.0 h1:Hx2Xv8hISq8Lm16jvBZ2VQf+RLmbd7wVUsALibYI/IQ=
199
- golang.org/x/tools v0.38.0/go.mod h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs=
200
- google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
201
- google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
202
- gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
203
- gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
204
- gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
205
- gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
206
- gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
207
- gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
208
- gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
209
- gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
210
- gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
211
- gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
212
- gorm.io/gorm v1.31.0 h1:0VlycGreVhK7RF/Bwt51Fk8v0xLiiiFdbGDPIZQ7mJY=
213
- gorm.io/gorm v1.31.0/go.mod h1:XyQVbO2k6YkOis7C2437jSit3SsDK72s7n7rsSHd+Gs=
214
- modernc.org/cc/v4 v4.26.5 h1:xM3bX7Mve6G8K8b+T11ReenJOT+BmVqQj0FY5T4+5Y4=
215
- modernc.org/cc/v4 v4.26.5/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0=
216
- modernc.org/ccgo/v4 v4.28.1 h1:wPKYn5EC/mYTqBO373jKjvX2n+3+aK7+sICCv4Fjy1A=
217
- modernc.org/ccgo/v4 v4.28.1/go.mod h1:uD+4RnfrVgE6ec9NGguUNdhqzNIeeomeXf6CL0GTE5Q=
218
- modernc.org/fileutil v1.3.40 h1:ZGMswMNc9JOCrcrakF1HrvmergNLAmxOPjizirpfqBA=
219
- modernc.org/fileutil v1.3.40/go.mod h1:HxmghZSZVAz/LXcMNwZPA/DRrQZEVP9VX0V4LQGQFOc=
220
- modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI=
221
- modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito=
222
- modernc.org/goabi0 v0.2.0 h1:HvEowk7LxcPd0eq6mVOAEMai46V+i7Jrj13t4AzuNks=
223
- modernc.org/goabi0 v0.2.0/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI=
224
- modernc.org/libc v1.66.10 h1:yZkb3YeLx4oynyR+iUsXsybsX4Ubx7MQlSYEw4yj59A=
225
- modernc.org/libc v1.66.10/go.mod h1:8vGSEwvoUoltr4dlywvHqjtAqHBaw0j1jI7iFBTAr2I=
226
- modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
227
- modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
228
- modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI=
229
- modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
230
- modernc.org/opt v0.1.4 h1:2kNGMRiUjrp4LcaPuLY2PzUfqM/w9N23quVwhKt5Qm8=
231
- modernc.org/opt v0.1.4/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns=
232
- modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=
233
- modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=
234
- modernc.org/sqlite v1.39.1 h1:H+/wGFzuSCIEVCvXYVHX5RQglwhMOvtHSv+VtidL2r4=
235
- modernc.org/sqlite v1.39.1/go.mod h1:9fjQZ0mB1LLP0GYrp39oOJXx/I2sxEnZtzCmEQIKvGE=
236
- modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
237
- modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
238
- modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
239
- modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
240
- nhooyr.io/websocket v1.8.17 h1:KEVeLJkUywCKVsnLIDlD/5gtayKp8VoCkksHCGGfT9Y=
241
- nhooyr.io/websocket v1.8.17/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c=
242
- nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
243
- rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
244
- rsc.io/qr v0.2.0 h1:6vBLea5/NRMVTz8V66gipeLycZMl/+UlFmk8DvqQ6WY=
245
- rsc.io/qr v0.2.0/go.mod h1:IF+uZjkb9fqyeF/4tlBoynqmQxUoPfWEKh921coOuXs=
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/goreleaser.Dockerfile DELETED
@@ -1,5 +0,0 @@
1
- FROM scratch
2
- ARG TARGETOS
3
- ARG TARGETARCH
4
- COPY ${TARGETOS}/${TARGETARCH}/fsb /app/fsb
5
- ENTRYPOINT ["/app/fsb", "run"]
 
 
 
 
 
 
test-clone/install.sh DELETED
@@ -1,710 +0,0 @@
1
- #!/bin/bash
2
- set -euo pipefail
3
-
4
- # TG-FileStreamBot Installer for macOS and Linux
5
- # Usage: curl -sL https://filestream.bot/install | bash
6
-
7
- # --------------- COLORS & STYLING ---------------
8
- BOLD='\033[1m'
9
- FSB_GREEN='\033[38;2;0;255;133m' # #00FF85
10
- FSB_DIM='\033[38;2;0;204;106m' # #00cc6a
11
- INFO='\033[38;2;136;146;176m' # text-secondary
12
- SUCCESS='\033[38;2;0;229;204m' # cyan-bright
13
- WARN='\033[38;2;255;176;32m' # amber
14
- ERROR='\033[38;2;230;57;70m' # coral-mid
15
- MUTED='\033[38;2;90;100;128m' # text-muted
16
- NC='\033[0m' # No Color
17
-
18
- REPO="EverythingSuckz/TG-FileStreamBot"
19
- GUM_VERSION="0.13.0"
20
- TMPFILES=()
21
- HAS_TTY="false"
22
-
23
- if [[ -r /dev/tty ]]; then
24
- HAS_TTY="true"
25
- fi
26
-
27
- can_use_tui() {
28
- [[ -n "${GUM:-}" && "$HAS_TTY" == "true" ]]
29
- }
30
-
31
- prompt_read() {
32
- local __var_name="$1"
33
- local __prompt="$2"
34
- local __default="${3-}"
35
- local __input=""
36
-
37
- if [[ "$HAS_TTY" == "true" ]]; then
38
- read -r -p "$__prompt" __input < /dev/tty || __input=""
39
- else
40
- read -r -p "$__prompt" __input || __input=""
41
- fi
42
-
43
- if [[ -z "$__input" && -n "$__default" ]]; then
44
- __input="$__default"
45
- fi
46
-
47
- printf -v "$__var_name" '%s' "$__input"
48
- }
49
-
50
- gum_choose() {
51
- if [[ "$HAS_TTY" == "true" ]]; then
52
- "$GUM" choose "$@" < /dev/tty
53
- else
54
- "$GUM" choose "$@"
55
- fi
56
- }
57
-
58
- gum_confirm() {
59
- if [[ "$HAS_TTY" == "true" ]]; then
60
- "$GUM" confirm "$@" < /dev/tty
61
- else
62
- "$GUM" confirm "$@"
63
- fi
64
- }
65
-
66
- gum_input() {
67
- if [[ "$HAS_TTY" == "true" ]]; then
68
- "$GUM" input "$@" < /dev/tty
69
- else
70
- "$GUM" input "$@"
71
- fi
72
- }
73
-
74
- # --------------- TEMP RUNTIME ---------------
75
- cleanup() {
76
- for f in "${TMPFILES[@]:-}"; do
77
- rm -rf "$f" 2>/dev/null || true
78
- done
79
- }
80
- trap cleanup EXIT
81
-
82
- mktempdir() {
83
- local d
84
- d="$(mktemp -d)"
85
- TMPFILES+=("$d")
86
- echo "$d"
87
- }
88
-
89
- # --------------- LOGGING UI ---------------
90
- ui_info() { echo -e "${MUTED}·${NC} $*"; }
91
- ui_warn() { echo -e "${WARN}!${NC} $*"; }
92
- ui_success() { echo -e "${SUCCESS}✓${NC} $*"; }
93
- ui_error() { echo -e "${ERROR}✗${NC} $*" >&2; }
94
-
95
- # --------------- DEPENDENCIES ---------------
96
- DOWNLOADER=""
97
- detect_downloader() {
98
- if command -v curl &> /dev/null; then
99
- DOWNLOADER="curl"
100
- return 0
101
- fi
102
- if command -v wget &> /dev/null; then
103
- DOWNLOADER="wget"
104
- return 0
105
- fi
106
- ui_error "Missing downloader. curl or wget required."
107
- exit 1
108
- }
109
-
110
- download_file() {
111
- local url="$1" output="$2"
112
- if [[ -z "$DOWNLOADER" ]]; then detect_downloader; fi
113
- if [[ "$DOWNLOADER" == "curl" ]]; then
114
- curl -fsSL --retry 3 -o "$output" "$url"
115
- else
116
- wget -q --tries=3 -O "$output" "$url"
117
- fi
118
- }
119
-
120
- download_github_api() {
121
- local url="$1" output="$2"
122
- if [[ -z "$DOWNLOADER" ]]; then detect_downloader; fi
123
- if [[ "$DOWNLOADER" == "curl" ]]; then
124
- curl -fsSL -H "Accept: application/vnd.github.v3+json" --retry 3 -o "$output" "$url"
125
- else
126
- wget -q --header="Accept: application/vnd.github.v3+json" --tries=3 -O "$output" "$url"
127
- fi
128
- }
129
-
130
- # --------------- GUM TUI BOOTSTRAP ---------------
131
- GUM=""
132
- bootstrap_gum() {
133
- if command -v gum &> /dev/null; then
134
- GUM="gum"
135
- return 0
136
- fi
137
-
138
- local os arch asset base gum_tmpdir
139
- os="$(uname -s | tr '[:upper:]' '[:lower:]')"
140
- case "$(uname -m)" in
141
- x86_64|amd64) arch="x86_64" ;;
142
- arm64|aarch64) arch="arm64" ;;
143
- i386|i686) arch="i386" ;;
144
- *) return 1 ;;
145
- esac
146
-
147
- asset="gum_${GUM_VERSION}_${os}_${arch}.tar.gz"
148
- base="https://github.com/charmbracelet/gum/releases/download/v${GUM_VERSION}"
149
- gum_tmpdir="$(mktempdir)"
150
-
151
- if download_file "${base}/${asset}" "$gum_tmpdir/$asset"; then
152
- tar -xzf "$gum_tmpdir/$asset" -C "$gum_tmpdir" >/dev/null 2>&1
153
- local gum_path
154
- gum_path="$(find "$gum_tmpdir" -type f -name gum | head -n1)"
155
- if [[ -n "$gum_path" ]]; then
156
- chmod +x "$gum_path"
157
- GUM="$gum_path"
158
- return 0
159
- fi
160
- fi
161
- return 1
162
- }
163
-
164
- # --------------- DETECTION ---------------
165
- detect_system() {
166
- OS="unknown"
167
- ARCH="unknown"
168
-
169
- case "$(uname -s)" in
170
- Darwin) OS="darwin" ;;
171
- Linux) OS="linux" ;;
172
- MINGW*|MSYS*|CYGWIN*) OS="windows" ;;
173
- esac
174
-
175
- case "$(uname -m)" in
176
- x86_64|amd64) ARCH="amd64" ;;
177
- arm64|aarch64) ARCH="arm64" ;;
178
- *)
179
- ui_error "Unsupported architecture: $(uname -m)"
180
- exit 1
181
- ;;
182
- esac
183
-
184
- if [[ "$OS" == "unknown" ]]; then
185
- ui_error "Unsupported operating system."
186
- exit 1
187
- fi
188
- }
189
-
190
- # --------------- API LOGIC ---------------
191
- get_latest_version() {
192
- local include_prerelease="$1"
193
- local api_resp
194
- api_resp="$(mktempdir)/api.json"
195
-
196
- ui_info "Fetching latest releases from GitHub..." >&2
197
- download_github_api "https://api.github.com/repos/${REPO}/releases" "$api_resp"
198
-
199
- # We parse manually using robust grep/sed combos since jq might not be installed
200
- local latest_tag=""
201
- if [[ "$include_prerelease" == "yes" ]]; then
202
- latest_tag=$(grep -m 1 '"tag_name":' "$api_resp" | sed -E 's/.*"([^"]+)".*/\1/')
203
- else
204
- # Find first non-prerelease
205
- # This basic parsing finds the first release block where "prerelease": false
206
- # We use awk to grab the tag_name of the first object where prerelease is false
207
- latest_tag=$(awk '
208
- /"tag_name":/ { tag=$2; gsub(/["|,]/, "", tag) }
209
- /"prerelease": false/ { print tag; exit }
210
- ' "$api_resp")
211
- fi
212
-
213
- if [[ -z "$latest_tag" || "$latest_tag" == "null" ]]; then
214
- ui_error "Could not determine latest version from GitHub API."
215
- exit 1
216
- fi
217
- echo "$latest_tag"
218
- }
219
-
220
- # --------------- MAIN INSTALLER ---------------
221
- main() {
222
- echo -e "${FSB_GREEN}${BOLD}"
223
- echo " TG-FileStreamBot Installer"
224
- echo -e "${NC}${INFO} Stream Telegram files with direct HTTP links.${NC}"
225
- echo ""
226
-
227
- detect_system
228
- bootstrap_gum || true
229
-
230
- # Existing Detection
231
- local EXISTING_FSB=""
232
- if command -v fsb &> /dev/null; then
233
- EXISTING_FSB="$(command -v fsb)"
234
- elif [[ -x "$PWD/fsb" ]]; then
235
- EXISTING_FSB="$PWD/fsb"
236
- elif [[ -x "$PWD/FSB/fsb" ]]; then
237
- EXISTING_FSB="$PWD/FSB/fsb"
238
- fi
239
-
240
- local SKIP_DIR_PROMPT="no"
241
- if [[ -n "$EXISTING_FSB" ]]; then
242
- local raw_ver
243
- raw_ver=$("$EXISTING_FSB" -v 2>/dev/null | grep -i 'version' | awk '{print $NF}' || true)
244
- local current_ver="unknown"
245
- if [[ -n "$raw_ver" && "$raw_ver" != "unknown" ]]; then
246
- if [[ "$raw_ver" != v* ]]; then
247
- current_ver="v${raw_ver}"
248
- else
249
- current_ver="$raw_ver"
250
- fi
251
- fi
252
-
253
- echo ""
254
- ui_info "Found existing installation at ${BOLD}$EXISTING_FSB${NC} (version: $current_ver)"
255
-
256
- local latest_stable
257
- latest_stable=$(get_latest_version "no")
258
-
259
- echo ""
260
- local ACTION
261
- if [[ "$current_ver" == "$latest_stable" ]]; then
262
- if can_use_tui; then
263
- ACTION=$(gum_choose "Keep installed version" "Reinstall $latest_stable" "Update to Pre-release" "Uninstall")
264
- else
265
- echo "1) Keep installed version"
266
- echo "2) Reinstall $latest_stable"
267
- echo "3) Update to Pre-release"
268
- echo "4) Uninstall"
269
- prompt_read act "Select action [1]: " "1"
270
- case "${act:-1}" in
271
- 2) ACTION="Reinstall $latest_stable" ;;
272
- 3) ACTION="Update to Pre-release" ;;
273
- 4) ACTION="Uninstall" ;;
274
- *) ACTION="Keep installed version" ;;
275
- esac
276
- fi
277
- else
278
- ui_info "New version available: ${BOLD}$latest_stable${NC}"
279
- if can_use_tui; then
280
- ACTION=$(gum_choose "Update to latest stable ($latest_stable)" "Update to Pre-release" "Uninstall" "Cancel")
281
- else
282
- echo "1) Update to latest stable ($latest_stable)"
283
- echo "2) Update to Pre-release"
284
- echo "3) Uninstall"
285
- echo "4) Cancel"
286
- prompt_read act "Select action [1]: " "1"
287
- case "${act:-1}" in
288
- 2) ACTION="Update to Pre-release" ;;
289
- 3) ACTION="Uninstall" ;;
290
- 4) ACTION="Cancel" ;;
291
- *) ACTION="Update to latest stable ($latest_stable)" ;;
292
- esac
293
- fi
294
- fi
295
-
296
- case "$ACTION" in
297
- "Keep installed version"|"Cancel")
298
- ui_info "Exiting."
299
- exit 0
300
- ;;
301
- "Uninstall")
302
- local target_dir
303
- target_dir=$(dirname "$EXISTING_FSB")
304
- local env_file="$target_dir/fsb.env"
305
-
306
- echo ""
307
- if [[ "$(basename "$target_dir")" == "FSB" ]]; then
308
- ui_warn "The following directory and all its contents will be deleted:"
309
- echo -e " ${ERROR}$target_dir${NC}"
310
- else
311
- ui_warn "The following files will be deleted:"
312
- echo -e " ${ERROR}$EXISTING_FSB${NC}"
313
- if [[ -f "$env_file" ]]; then
314
- echo -e " ${ERROR}$env_file${NC}"
315
- fi
316
- fi
317
- echo ""
318
-
319
- if can_use_tui; then
320
- if ! gum_confirm "Proceed with uninstallation?" --default=false; then
321
- ui_info "Uninstallation cancelled."
322
- exit 0
323
- fi
324
- else
325
- prompt_read uninst_resp "Proceed with uninstallation? [y/N] " "N"
326
- case "$uninst_resp" in
327
- [yY][eE][sS]|[yY]) ;;
328
- *)
329
- ui_info "Uninstallation cancelled."
330
- exit 0
331
- ;;
332
- esac
333
- fi
334
-
335
- ui_info "Uninstalling..."
336
- if [[ "$(basename "$target_dir")" == "FSB" ]]; then
337
- rm -rf "$target_dir" 2>/dev/null || sudo rm -rf "$target_dir"
338
- else
339
- rm -f "$EXISTING_FSB" 2>/dev/null || sudo rm -f "$EXISTING_FSB"
340
- if [[ -f "$env_file" ]]; then
341
- rm -f "$env_file" 2>/dev/null || sudo rm -f "$env_file"
342
- fi
343
- fi
344
- ui_success "Uninstalled successfully."
345
- exit 0
346
- ;;
347
- "Update to Pre-release")
348
- WANT_PRERELEASE="yes"
349
- TARGET_VER=$(get_latest_version "yes")
350
- INSTALL_DIR=$(dirname "$EXISTING_FSB")
351
- SKIP_DIR_PROMPT="yes"
352
- WANT_ENV="no"
353
- ;;
354
- *)
355
- WANT_PRERELEASE="no"
356
- TARGET_VER="$latest_stable"
357
- INSTALL_DIR=$(dirname "$EXISTING_FSB")
358
- SKIP_DIR_PROMPT="yes"
359
- WANT_ENV="no"
360
- ;;
361
- esac
362
- fi
363
-
364
- # Defaults
365
- if [[ "$SKIP_DIR_PROMPT" != "yes" ]]; then
366
- WANT_PRERELEASE="No"
367
- INSTALL_DIR="$PWD/FSB"
368
- WANT_ENV="no"
369
- ENV_DIR=""
370
-
371
- # Interactive flow if TUI is available
372
- if can_use_tui; then
373
- echo -e "${BOLD}Do you want to install the latest pre-release version?${NC}"
374
- if gum_confirm "Include pre-releases? (Recommended: No)" --default=false; then
375
- WANT_PRERELEASE="yes"
376
- else
377
- WANT_PRERELEASE="no"
378
- fi
379
-
380
- echo ""
381
- echo -e "${BOLD}Where should we install the binary?${NC}"
382
- INSTALL_DIR=$(gum_choose \
383
- "Current Directory/FSB (Recommended)" \
384
- "Current Directory ($PWD)" \
385
- "$HOME/.local/bin" \
386
- "/usr/local/bin (Requires sudo/root)" \
387
- "Custom Path" | sed 's/ (.*//')
388
-
389
- if [[ "$INSTALL_DIR" == "Custom Path" ]]; then
390
- INSTALL_DIR=$(gum_input --placeholder "/path/to/install/dir")
391
- elif [[ "$INSTALL_DIR" == "Current Directory/FSB" ]]; then
392
- INSTALL_DIR="$PWD/FSB"
393
- elif [[ "$INSTALL_DIR" == "Current Directory" ]]; then
394
- INSTALL_DIR="$PWD"
395
- fi
396
-
397
- echo ""
398
- echo -e "${BOLD}Do you want to download a sample 'fsb.env' configuration file?${NC}"
399
- if gum_confirm "Download sample env?" --default=true; then
400
- WANT_ENV="yes"
401
- fi
402
-
403
- if [[ "$WANT_ENV" == "yes" ]]; then
404
- if [[ "$INSTALL_DIR" == "$PWD/FSB" || "$INSTALL_DIR" == "$PWD" ]]; then
405
- ENV_DIR="$INSTALL_DIR"
406
- else
407
- echo ""
408
- echo -e "${BOLD}Where should we save the 'fsb.env' file?${NC}"
409
- ENV_DIR=$(gum_choose \
410
- "Current Directory ($PWD) (Recommended)" \
411
- "Installation Folder ($INSTALL_DIR)" \
412
- "Custom Path" | sed 's/ (.*//')
413
-
414
- if [[ "$ENV_DIR" == "Custom Path" ]]; then
415
- ENV_DIR=$(gum_input --placeholder "/path/to/save/env")
416
- elif [[ "$ENV_DIR" == "Current Directory" ]]; then
417
- ENV_DIR="$PWD"
418
- elif [[ "$ENV_DIR" == "Installation Folder" ]]; then
419
- ENV_DIR="$INSTALL_DIR"
420
- fi
421
- fi
422
- fi
423
- else
424
- # Fallback text mode prompts
425
- prompt_read response "Install pre-release version? [y/N] " "N"
426
- case "$response" in
427
- [yY][eE][sS]|[yY]) WANT_PRERELEASE="yes" ;;
428
- *) WANT_PRERELEASE="no" ;;
429
- esac
430
-
431
- echo ""
432
- echo "Select installation directory:"
433
- echo "1) Current Directory/FSB (Recommended)"
434
- echo "2) Current Directory ($PWD)"
435
- echo "3) $HOME/.local/bin"
436
- echo "4) /usr/local/bin (Requires sudo)"
437
- prompt_read dir_resp "Selection [1]: " "1"
438
- case "${dir_resp:-1}" in
439
- 2) INSTALL_DIR="$PWD" ;;
440
- 3) INSTALL_DIR="$HOME/.local/bin" ;;
441
- 4) INSTALL_DIR="/usr/local/bin" ;;
442
- *) INSTALL_DIR="$PWD/FSB" ;;
443
- esac
444
-
445
- echo ""
446
- prompt_read env_response "Download sample 'fsb.env' configuration file? [Y/n] " "Y"
447
- case "$env_response" in
448
- [nN][oO]|[nN]) WANT_ENV="no" ;;
449
- *) WANT_ENV="yes" ;;
450
- esac
451
-
452
- if [[ "$WANT_ENV" == "yes" ]]; then
453
- if [[ "$INSTALL_DIR" == "$PWD/FSB" || "$INSTALL_DIR" == "$PWD" ]]; then
454
- ENV_DIR="$INSTALL_DIR"
455
- else
456
- echo ""
457
- echo "Select where to save 'fsb.env':"
458
- echo "1) Current Directory ($PWD) (Recommended)"
459
- echo "2) Installation Folder ($INSTALL_DIR)"
460
- prompt_read env_dir_resp "Selection [1]: " "1"
461
- case "${env_dir_resp:-1}" in
462
- 2) ENV_DIR="$INSTALL_DIR" ;;
463
- *) ENV_DIR="$PWD" ;;
464
- esac
465
- fi
466
- fi
467
- fi
468
-
469
- # Prep path
470
- case "$INSTALL_DIR" in
471
- ~*) INSTALL_DIR="${INSTALL_DIR/#\~/$HOME}" ;;
472
- esac
473
- if [[ "$WANT_ENV" == "yes" ]]; then
474
- case "$ENV_DIR" in
475
- ~*) ENV_DIR="${ENV_DIR/#\~/$HOME}" ;;
476
- esac
477
- fi
478
-
479
- TARGET_VER=$(get_latest_version "$WANT_PRERELEASE")
480
- fi
481
-
482
- local file_ext=".tar.gz"
483
- if [[ "$OS" == "windows" ]]; then
484
- file_ext=".zip"
485
- fi
486
-
487
- ASSET_NAME="TG-FileStreamBot-${TARGET_VER}-${OS}-${ARCH}${file_ext}"
488
- ASSET_URL="https://github.com/${REPO}/releases/download/${TARGET_VER}/${ASSET_NAME}"
489
- CHECKSUM_URL="https://github.com/${REPO}/releases/download/${TARGET_VER}/TG-FileStreamBot-${TARGET_VER}-checksums.txt"
490
- SIG_URL="${CHECKSUM_URL}.sig"
491
-
492
- echo ""
493
- ui_info "Target Version : ${BOLD}${TARGET_VER}${NC}"
494
- ui_info "OS / Arch : ${BOLD}${OS} / ${ARCH}${NC}"
495
- ui_info "Binary Location : ${BOLD}${INSTALL_DIR}${NC}"
496
- if [[ "$WANT_ENV" == "yes" ]]; then
497
- ui_info "Env File Location : ${BOLD}${ENV_DIR}/fsb.env${NC}"
498
- fi
499
- echo ""
500
-
501
- # Confirmation
502
- if can_use_tui; then
503
- if ! gum_confirm "Proceed with installation?" --default=true; then
504
- ui_info "Installation cancelled."
505
- exit 0
506
- fi
507
- else
508
- prompt_read proceed_resp "Proceed with installation? [Y/n] " "Y"
509
- case "$proceed_resp" in
510
- [nN][oO]|[nN])
511
- ui_info "Installation cancelled."
512
- exit 0
513
- ;;
514
- esac
515
- fi
516
-
517
- if [[ -n "$GUM" ]]; then
518
- "$GUM" spin --spinner dot --title "Downloading components..." -- sleep 0.1
519
- fi
520
-
521
- local dl_dir
522
- dl_dir="$(mktempdir)"
523
-
524
- ui_info "Downloading ${ASSET_NAME}..."
525
- if ! download_file "$ASSET_URL" "$dl_dir/$ASSET_NAME"; then
526
- ui_error "Failed to download the binary archive. Is the release available for this architecture?"
527
- exit 1
528
- fi
529
-
530
- ui_info "Downloading checksums..."
531
- download_file "$CHECKSUM_URL" "$dl_dir/checksums.txt"
532
-
533
- # Verify checksum if sha256sum or shasum exists
534
- ui_info "Verifying SHA256 checksum..."
535
- pushd "$dl_dir" >/dev/null
536
- local checksum_matched=false
537
- if command -v sha256sum &> /dev/null; then
538
- if grep "$ASSET_NAME" checksums.txt | sha256sum -c - >/dev/null 2>&1; then
539
- checksum_matched=true
540
- fi
541
- elif command -v shasum &> /dev/null; then
542
- if grep "$ASSET_NAME" checksums.txt | shasum -a 256 -c - >/dev/null 2>&1; then
543
- checksum_matched=true
544
- fi
545
- else
546
- ui_warn "No sha256sum or shasum found; skipping checksum verification."
547
- checksum_matched=true
548
- fi
549
- popd >/dev/null
550
-
551
- if [[ "$checksum_matched" != "true" ]]; then
552
- ui_error "Checksum verification failed! The file may be corrupted or compromised."
553
- exit 1
554
- fi
555
- ui_success "Checksum matched."
556
-
557
- # Verify Signature if tools exist
558
- ui_info "Downloading signature..."
559
- download_file "$SIG_URL" "$dl_dir/checksums.txt.sig"
560
-
561
- ui_info "Verifying signature..."
562
- pushd "$dl_dir" >/dev/null
563
- local sig_verified=false
564
-
565
- if command -v gpg &> /dev/null; then
566
- ui_info "gpg detected. Fetching developer's public key..."
567
- download_file "https://github.com/EverythingSuckz.gpg" "dev_key.asc"
568
-
569
- # Create a temporary keyring to avoid polluting the user's keychain
570
- local keyring="--no-default-keyring --keyring ./temp_keyring.gpg"
571
- gpg $keyring --import dev_key.asc >/dev/null 2>&1
572
-
573
- if gpg $keyring --verify checksums.txt.sig checksums.txt >/dev/null 2>&1; then
574
- sig_verified=true
575
- ui_success "Signature verified successfully."
576
- else
577
- ui_warn "Signature verification failed. The release might be compromised."
578
- sig_verified=false
579
- fi
580
- else
581
- ui_warn "No gpg executable found; skipping signature validation."
582
- sig_verified=true
583
- fi
584
- popd >/dev/null
585
-
586
- if [[ "$sig_verified" != "true" ]]; then
587
- ui_error "Signature verification failed!"
588
- exit 1
589
- fi
590
-
591
- ui_info "Extracting binary..."
592
- if [[ "$ASSET_NAME" == *.zip ]]; then
593
- if ! command -v unzip &> /dev/null; then
594
- ui_error "unzip is required to extract Windows binaries."
595
- exit 1
596
- fi
597
- unzip -q "$dl_dir/$ASSET_NAME" -d "$dl_dir"
598
- else
599
- tar -xzf "$dl_dir/$ASSET_NAME" -C "$dl_dir"
600
- fi
601
-
602
- # The tarball contains the binary, possibly named `fsb` or inside a folder.
603
- # Usually it extracts right out as `fsb`.
604
- local bin_file
605
- bin_file="$(find "$dl_dir" -type f \( -name "fsb" -o -name "TG-FileStreamBot" \) | head -n1)"
606
-
607
- if [[ -z "$bin_file" ]]; then
608
- ui_error "Could not find the executable inside the extracted archive."
609
- exit 1
610
- fi
611
-
612
- chmod +x "$bin_file"
613
-
614
- if [[ ! -d "$INSTALL_DIR" ]]; then
615
- ui_info "Creating directory $INSTALL_DIR..."
616
- mkdir -p "$INSTALL_DIR" 2>/dev/null || sudo mkdir -p "$INSTALL_DIR"
617
- fi
618
-
619
- ui_info "Installing to $INSTALL_DIR..."
620
- if mv "$bin_file" "$INSTALL_DIR/fsb" 2>/dev/null; then
621
- ui_success "Installed successfully!"
622
- else
623
- ui_info "Elevated permissions required to write to $INSTALL_DIR"
624
- # Use sudo on unix, but check if we are on windows first
625
- if command -v sudo &> /dev/null; then
626
- if sudo mv "$bin_file" "$INSTALL_DIR/fsb"; then
627
- ui_success "Installed successfully!"
628
- else
629
- ui_error "Installation failed due to permissions."
630
- exit 1
631
- fi
632
- else
633
- ui_error "Insufficient permissions and sudo not found. Please run script as Admin/Root."
634
- exit 1
635
- fi
636
- fi
637
-
638
- echo ""
639
- echo -e "${FSB_GREEN}${BOLD}✓ Setup Complete!${NC}"
640
-
641
- # Path logic checking
642
- local in_path=false
643
- if builtin type -p fsb &>/dev/null; then
644
- in_path=true
645
- elif [[ ":$PATH:" == *":$INSTALL_DIR:"* ]]; then
646
- in_path=true
647
- fi
648
-
649
- local is_portable=false
650
- if [[ "$INSTALL_DIR" != "/usr/local/bin" && "$INSTALL_DIR" != "/usr/bin" && "$INSTALL_DIR" != "$HOME/.local/bin" ]]; then
651
- is_portable=true
652
- fi
653
-
654
- echo ""
655
- if [[ "$in_path" == false && "$is_portable" == false ]]; then
656
- ui_warn "The directory $INSTALL_DIR is not in your PATH."
657
- echo -e "You may need to add it to your shell configuration file (e.g. ~/.bashrc or ~/.zshrc):"
658
- echo -e " ${BOLD}export PATH=\"\$PATH:$INSTALL_DIR\"${NC}"
659
- echo ""
660
- fi
661
-
662
- local bin_cmd="fsb"
663
- if [[ "$in_path" == false ]]; then
664
- bin_cmd="./fsb"
665
- fi
666
-
667
- # Download Env if requested
668
- if [[ "$WANT_ENV" == "yes" ]]; then
669
- ui_info "Downloading sample configuration to $ENV_DIR/fsb.env..."
670
- if [[ ! -d "$ENV_DIR" ]]; then
671
- mkdir -p "$ENV_DIR" 2>/dev/null || sudo mkdir -p "$ENV_DIR"
672
- fi
673
-
674
- local env_branch="main"
675
- if [[ "$WANT_PRERELEASE" == "yes" ]]; then
676
- env_branch="dev"
677
- fi
678
-
679
- local env_url="https://raw.githubusercontent.com/${REPO}/refs/heads/${env_branch}/fsb.sample.env"
680
- local dl_env
681
- dl_env="$(mktempdir)/fsb.sample.env"
682
-
683
- if download_file "$env_url" "$dl_env"; then
684
- if mv "$dl_env" "$ENV_DIR/fsb.env" 2>/dev/null; then
685
- ui_success "Saved fsb.env"
686
- else
687
- sudo mv "$dl_env" "$ENV_DIR/fsb.env" 2>/dev/null || ui_warn "Failed to move fsb.env to $ENV_DIR"
688
- fi
689
- else
690
- ui_warn "Failed to download sample fsb.env configuration."
691
- fi
692
- fi
693
-
694
- echo ""
695
- echo -e "${BOLD}Next Steps:${NC}"
696
- if [[ "$INSTALL_DIR" != "$PWD" && "$is_portable" == true ]]; then
697
- # If it's a sub-directory, e.g. PWD/FSB or custom folder
698
- echo -e " cd $INSTALL_DIR"
699
- fi
700
-
701
- if [[ "$WANT_ENV" == "yes" ]]; then
702
- echo -e " ${INFO}# Edit fsb.env to configure your bot variables${NC}"
703
- else
704
- echo -e " ${INFO}# Supply your environmental variables (e.g. in fsb.env) before running${NC}"
705
- fi
706
- echo -e " ${bin_cmd} run"
707
- echo ""
708
- }
709
-
710
- main "$@"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/internal/bot/client.go DELETED
@@ -1,55 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/internal/bot/middleware.go DELETED
@@ -1,20 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/internal/bot/userbot.go DELETED
@@ -1,119 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/internal/bot/workers.go DELETED
@@ -1,171 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/internal/cache/cache.go DELETED
@@ -1,68 +0,0 @@
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
- gob.Register(tg.InputPhotoFileLocation{})
27
- defer log.Sugar().Info("Initialized")
28
- cache = &Cache{cache: freecache.NewCache(10 * 1024 * 1024), log: log}
29
- }
30
-
31
- func GetCache() *Cache {
32
- return cache
33
- }
34
-
35
- func (c *Cache) Get(key string, value *types.File) error {
36
- c.mu.RLock()
37
- defer c.mu.RUnlock()
38
- data, err := cache.cache.Get([]byte(key))
39
- if err != nil {
40
- return err
41
- }
42
- dec := gob.NewDecoder(bytes.NewReader(data))
43
- err = dec.Decode(&value)
44
- if err != nil {
45
- return err
46
- }
47
- return nil
48
- }
49
-
50
- func (c *Cache) Set(key string, value *types.File, expireSeconds int) error {
51
- c.mu.Lock()
52
- defer c.mu.Unlock()
53
- var buf bytes.Buffer
54
- enc := gob.NewEncoder(&buf)
55
- err := enc.Encode(value)
56
- if err != nil {
57
- return err
58
- }
59
- cache.cache.Set([]byte(key), buf.Bytes(), expireSeconds)
60
- return nil
61
- }
62
-
63
- func (c *Cache) Delete(key string) error {
64
- c.mu.Lock()
65
- defer c.mu.Unlock()
66
- cache.cache.Del([]byte(key))
67
- return nil
68
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/internal/commands/commands.go DELETED
@@ -1,22 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/internal/commands/start.go DELETED
@@ -1,31 +0,0 @@
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, ext.ReplyTextString("No tienes permiso para usar este bot."), nil)
27
- return dispatcher.EndGroups
28
- }
29
- ctx.Reply(u, ext.ReplyTextString("Hola, envíame cualquier archivo para obtener un enlace directo a ese archivo."), nil)
30
- return dispatcher.EndGroups
31
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/internal/commands/stream.go DELETED
@@ -1,167 +0,0 @@
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/tg"
16
- )
17
-
18
- func (m *command) LoadStream(dispatcher dispatcher.Dispatcher) {
19
- log := m.log.Named("start")
20
- defer log.Sugar().Info("Loaded")
21
- dispatcher.AddHandler(
22
- handlers.NewMessage(nil, sendLink),
23
- )
24
- }
25
-
26
- func supportedMediaFilter(m *types.Message) (bool, error) {
27
- if not := m.Media == nil; not {
28
- return false, dispatcher.EndGroups
29
- }
30
- switch m.Media.(type) {
31
- case *tg.MessageMediaDocument:
32
- return true, nil
33
- case *tg.MessageMediaPhoto:
34
- return true, nil
35
- case tg.MessageMediaClass:
36
- return false, dispatcher.EndGroups
37
- default:
38
- return false, nil
39
- }
40
- }
41
-
42
- func sendLink(ctx *ext.Context, u *ext.Update) error {
43
- chatId := u.EffectiveChat().GetID()
44
- peerChatId := ctx.PeerStorage.GetPeerById(chatId)
45
- if peerChatId.Type != int(storage.TypeUser) {
46
- return dispatcher.EndGroups
47
- }
48
- if len(config.ValueOf.AllowedUsers) != 0 && !utils.Contains(config.ValueOf.AllowedUsers, chatId) {
49
- ctx.Reply(u, ext.ReplyTextString("No tienes permiso para usar este bot."), nil)
50
- return dispatcher.EndGroups
51
- }
52
- supported, err := supportedMediaFilter(u.EffectiveMessage)
53
- if err != nil {
54
- return err
55
- }
56
- if !supported {
57
- ctx.Reply(u, ext.ReplyTextString("Lo siento, este tipo de archivo no es compatible."), nil)
58
- return dispatcher.EndGroups
59
- }
60
- update, err := utils.ForwardMessages(ctx, chatId, config.ValueOf.LogChannelID, u.EffectiveMessage.ID)
61
- if err != nil {
62
- utils.Logger.Sugar().Error(err)
63
- ctx.Reply(u, ext.ReplyTextString(fmt.Sprintf("Error - %s", err.Error())), nil)
64
- return dispatcher.EndGroups
65
- }
66
- if len(update.Updates) < 2 {
67
- ctx.Reply(u, ext.ReplyTextString("Error - estructura de actualización de Telegram inesperada"), nil)
68
- return dispatcher.EndGroups
69
- }
70
- msgIDUpdate, ok := update.Updates[0].(*tg.UpdateMessageID)
71
- if !ok {
72
- ctx.Reply(u, ext.ReplyTextString("Error - tipo de actualización inesperado"), nil)
73
- return dispatcher.EndGroups
74
- }
75
- messageID := msgIDUpdate.ID
76
- newMsg, ok := update.Updates[1].(*tg.UpdateNewChannelMessage)
77
- if !ok {
78
- ctx.Reply(u, ext.ReplyTextString("Error - mensaje de canal inesperado"), nil)
79
- return dispatcher.EndGroups
80
- }
81
- msg, ok := newMsg.Message.(*tg.Message)
82
- if !ok {
83
- ctx.Reply(u, ext.ReplyTextString("Error - tipo de mensaje inesperado"), nil)
84
- return dispatcher.EndGroups
85
- }
86
- doc := msg.Media
87
- file, err := utils.FileFromMedia(doc)
88
- if err != nil {
89
- ctx.Reply(u, ext.ReplyTextString(fmt.Sprintf("Error - %s", err.Error())), nil)
90
- return dispatcher.EndGroups
91
- }
92
- fullHash := utils.PackFile(
93
- file.FileName,
94
- file.FileSize,
95
- file.MimeType,
96
- file.ID,
97
- )
98
- hash := utils.GetShortHash(fullHash)
99
-
100
- localLink := fmt.Sprintf("http://127.0.0.1:%d/stream/%d?hash=%s", config.ValueOf.Port, messageID, hash)
101
- hfLink := fmt.Sprintf("https://codebydante-brodyfilestreambot.hf.space/stream/%d?hash=%s", messageID, hash)
102
-
103
- localDownloadText := localLink + "&d=true"
104
- hfDownloadText := hfLink + "&d=true"
105
-
106
- var textLines []string
107
- textLines = append(textLines, "🖥 Para tu PC Local (Pruebas):")
108
- textLines = append(textLines, "📁 Descargar:")
109
- textLines = append(textLines, localDownloadText)
110
- textLines = append(textLines, "📁 Reproducir / Ver:")
111
- textLines = append(textLines, localLink)
112
-
113
- textLines = append(textLines, "\n🚀 Para Hugging Face (Público):")
114
- textLines = append(textLines, "📁 Descargar:")
115
- textLines = append(textLines, hfDownloadText)
116
- textLines = append(textLines, "📁 Reproducir / Ver:")
117
- textLines = append(textLines, hfLink)
118
-
119
- textPlain := strings.Join(textLines, "\n")
120
-
121
- var rows []tg.KeyboardButtonRow
122
-
123
- // Fila Local
124
- localRow := tg.KeyboardButtonRow{
125
- Buttons: []tg.KeyboardButtonClass{
126
- &tg.KeyboardButtonURL{
127
- Text: "🖥 Descargar",
128
- URL: localDownloadText,
129
- },
130
- &tg.KeyboardButtonURL{
131
- Text: "🖥 Ver / Reproducir",
132
- URL: localLink,
133
- },
134
- },
135
- }
136
- rows = append(rows, localRow)
137
-
138
- // Fila Hugging Face
139
- hfRow := tg.KeyboardButtonRow{
140
- Buttons: []tg.KeyboardButtonClass{
141
- &tg.KeyboardButtonURL{
142
- Text: "🚀 Descargar",
143
- URL: hfDownloadText,
144
- },
145
- &tg.KeyboardButtonURL{
146
- Text: "🚀 Ver / Reproducir",
147
- URL: hfLink,
148
- },
149
- },
150
- }
151
- rows = append(rows, hfRow)
152
-
153
- markup := &tg.ReplyInlineMarkup{
154
- Rows: rows,
155
- }
156
-
157
- _, err = ctx.Reply(u, ext.ReplyTextString(textPlain), &ext.ReplyOpts{
158
- Markup: markup,
159
- NoWebpage: true,
160
- ReplyToMessageId: u.EffectiveMessage.ID,
161
- })
162
- if err != nil {
163
- utils.Logger.Sugar().Error(err)
164
- ctx.Reply(u, ext.ReplyTextString(fmt.Sprintf("Error - %s", err.Error())), nil)
165
- }
166
- return dispatcher.EndGroups
167
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/internal/routes/routes.go DELETED
@@ -1,33 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/internal/routes/stream.go DELETED
@@ -1,142 +0,0 @@
1
- package routes
2
-
3
- import (
4
- "EverythingSuckz/fsb/internal/bot"
5
- "EverythingSuckz/fsb/internal/stream"
6
- "EverythingSuckz/fsb/internal/types"
7
- "EverythingSuckz/fsb/internal/utils"
8
- "fmt"
9
- "io"
10
- "net/http"
11
- "strconv"
12
-
13
- "github.com/gotd/td/tg"
14
- range_parser "github.com/quantumsheep/range-parser"
15
- "go.uber.org/zap"
16
-
17
- "github.com/gin-gonic/gin"
18
- )
19
-
20
- var log *zap.Logger
21
-
22
- func (e *allRoutes) LoadHome(r *Route) {
23
- log = e.log.Named("Stream")
24
- defer log.Info("Loaded stream route")
25
- r.Engine.GET("/stream/:messageID", getStreamRoute)
26
- }
27
-
28
- func getStreamRoute(ctx *gin.Context) {
29
- w := ctx.Writer
30
- r := ctx.Request
31
-
32
- messageIDParm := ctx.Param("messageID")
33
- messageID, err := strconv.Atoi(messageIDParm)
34
- if err != nil {
35
- http.Error(w, err.Error(), http.StatusBadRequest)
36
- return
37
- }
38
-
39
- authHash := ctx.Query("hash")
40
- if authHash == "" {
41
- http.Error(w, "missing hash param", http.StatusBadRequest)
42
- return
43
- }
44
-
45
- worker := bot.GetNextWorker()
46
-
47
- file, err := utils.TimeFuncWithResult(log, "FileFromMessage", func() (*types.File, error) {
48
- return utils.FileFromMessage(ctx, worker.Client, messageID)
49
- })
50
- if err != nil {
51
- http.Error(w, err.Error(), http.StatusBadRequest)
52
- return
53
- }
54
-
55
- expectedHash := utils.PackFile(
56
- file.FileName,
57
- file.FileSize,
58
- file.MimeType,
59
- file.ID,
60
- )
61
- if !utils.CheckHash(authHash, expectedHash) {
62
- http.Error(w, "invalid hash", http.StatusBadRequest)
63
- return
64
- }
65
-
66
- // for photo messages
67
- if file.FileSize == 0 {
68
- res, err := worker.Client.API().UploadGetFile(ctx, &tg.UploadGetFileRequest{
69
- Location: file.Location,
70
- Offset: 0,
71
- Limit: 1024 * 1024,
72
- })
73
- if err != nil {
74
- http.Error(w, err.Error(), http.StatusInternalServerError)
75
- return
76
- }
77
- result, ok := res.(*tg.UploadFile)
78
- if !ok {
79
- http.Error(w, "unexpected response", http.StatusInternalServerError)
80
- return
81
- }
82
- fileBytes := result.GetBytes()
83
- ctx.Header("Content-Disposition", fmt.Sprintf("inline; filename=\"%s\"", file.FileName))
84
- if r.Method != "HEAD" {
85
- ctx.Data(http.StatusOK, file.MimeType, fileBytes)
86
- }
87
- return
88
- }
89
-
90
- ctx.Header("Accept-Ranges", "bytes")
91
- var start, end int64
92
- rangeHeader := r.Header.Get("Range")
93
-
94
- if rangeHeader == "" {
95
- start = 0
96
- end = file.FileSize - 1
97
- w.WriteHeader(http.StatusOK)
98
- } else {
99
- ranges, err := range_parser.Parse(file.FileSize, r.Header.Get("Range"))
100
- if err != nil {
101
- http.Error(w, err.Error(), http.StatusBadRequest)
102
- return
103
- }
104
- start = ranges[0].Start
105
- end = ranges[0].End
106
- ctx.Header("Content-Range", fmt.Sprintf("bytes %d-%d/%d", start, end, file.FileSize))
107
- log.Info("Content-Range", zap.Int64("start", start), zap.Int64("end", end), zap.Int64("fileSize", file.FileSize))
108
- w.WriteHeader(http.StatusPartialContent)
109
- }
110
-
111
- contentLength := end - start + 1
112
- mimeType := file.MimeType
113
-
114
- if mimeType == "" {
115
- mimeType = "application/octet-stream"
116
- }
117
-
118
- ctx.Header("Content-Type", mimeType)
119
- ctx.Header("Content-Length", strconv.FormatInt(contentLength, 10))
120
-
121
- disposition := "inline"
122
-
123
- if ctx.Query("d") == "true" {
124
- disposition = "attachment"
125
- }
126
-
127
- ctx.Header("Content-Disposition", fmt.Sprintf("%s; filename=\"%s\"", disposition, file.FileName))
128
-
129
- if r.Method != "HEAD" {
130
- pipe, err := stream.NewStreamPipe(ctx, worker.Client, file.Location, start, end, log)
131
- if err != nil {
132
- log.Error("Failed to create stream pipe", zap.Error(err))
133
- return
134
- }
135
- defer pipe.Close()
136
- if _, err := io.CopyN(w, pipe, contentLength); err != nil {
137
- if !utils.IsClientDisconnectError(err) {
138
- log.Error("Error while copying stream", zap.Error(err))
139
- }
140
- }
141
- }
142
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/internal/routes/upload.go DELETED
@@ -1,120 +0,0 @@
1
- package routes
2
-
3
- import (
4
- "bytes"
5
- "encoding/json"
6
- "fmt"
7
- "io"
8
- "mime/multipart"
9
- "net/http"
10
- "strconv"
11
-
12
- "EverythingSuckz/fsb/config"
13
- "EverythingSuckz/fsb/internal/bot"
14
- "EverythingSuckz/fsb/internal/utils"
15
-
16
- "github.com/gin-gonic/gin"
17
- "go.uber.org/zap"
18
- )
19
-
20
- type tgResponse struct {
21
- Ok bool `json:"ok"`
22
- Result struct {
23
- MessageID int `json:"message_id"`
24
- } `json:"result"`
25
- }
26
-
27
- func (e *allRoutes) LoadUpload(r *Route) {
28
- log = e.log.Named("Upload")
29
- r.Engine.POST("/upload", uploadStreamRoute)
30
- }
31
-
32
- func uploadStreamRoute(ctx *gin.Context) {
33
- file, header, err := ctx.Request.FormFile("file")
34
- if err != nil {
35
- ctx.JSON(http.StatusBadRequest, gin.H{"success": false, "error": "Falta el archivo en el campo 'file'"})
36
- return
37
- }
38
- defer file.Close()
39
-
40
- body := &bytes.Buffer{}
41
- writer := multipart.NewWriter(body)
42
-
43
- err = writer.WriteField("chat_id", strconv.FormatInt(config.ValueOf.LogChannelID, 10))
44
- if err != nil {
45
- ctx.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": "Error interno"})
46
- return
47
- }
48
-
49
- part, err := writer.CreateFormFile("document", header.Filename)
50
- if err != nil {
51
- ctx.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": "Error interno creando documento"})
52
- return
53
- }
54
-
55
- _, err = io.Copy(part, file)
56
- if err != nil {
57
- ctx.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": "Error leyendo archivo"})
58
- return
59
- }
60
- writer.Close()
61
-
62
- url := fmt.Sprintf("https://api.telegram.org/bot%s/sendDocument", config.ValueOf.BotToken)
63
- req, err := http.NewRequest("POST", url, body)
64
- if err != nil {
65
- ctx.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": "Error preparando petici\u00f3n a Telegram"})
66
- return
67
- }
68
- req.Header.Set("Content-Type", writer.FormDataContentType())
69
-
70
- client := &http.Client{}
71
- resp, err := client.Do(req)
72
- if err != nil {
73
- log.Error("Error enviando a Telegram", zap.Error(err))
74
- ctx.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": "Error enviando a Telegram"})
75
- return
76
- }
77
- defer resp.Body.Close()
78
-
79
- var tgRes tgResponse
80
- if err := json.NewDecoder(resp.Body).Decode(&tgRes); err != nil {
81
- log.Error("Error decoding Telegram response", zap.Error(err))
82
- ctx.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": "Error decodificando respuesta de Telegram"})
83
- return
84
- }
85
-
86
- if !tgRes.Ok || tgRes.Result.MessageID == 0 {
87
- log.Error("Telegram rejected the file or upload failed", zap.Any("response", tgRes))
88
- ctx.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": "Telegram rechaz\u00f3 el archivo o subida fallida"})
89
- return
90
- }
91
-
92
- messageID := tgRes.Result.MessageID
93
- worker := bot.GetNextWorker()
94
-
95
- tgFile, err := utils.FileFromMessage(ctx.Request.Context(), worker.Client, messageID)
96
- if err != nil {
97
- log.Error("Failed to get file properties", zap.Error(err))
98
- ctx.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": "Error obteniendo propiedades de Telegram. " + err.Error()})
99
- return
100
- }
101
-
102
- expectedHash := utils.PackFile(
103
- tgFile.FileName,
104
- tgFile.FileSize,
105
- tgFile.MimeType,
106
- tgFile.ID,
107
- )
108
- hash := utils.GetShortHash(expectedHash)
109
-
110
- localLink := fmt.Sprintf("http://127.0.0.1:%d/stream/%d?hash=%s", config.ValueOf.Port, messageID, hash)
111
- hfLink := fmt.Sprintf("https://codebydante-brodyfilestreambot.hf.space/stream/%d?hash=%s", messageID, hash)
112
-
113
- ctx.JSON(http.StatusOK, gin.H{
114
- "success": true,
115
- "message_id": messageID,
116
- "hash": hash,
117
- "url": hfLink,
118
- "local_url": localLink,
119
- })
120
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/internal/stream/errors.go DELETED
@@ -1,17 +0,0 @@
1
- package stream
2
-
3
- import "errors"
4
-
5
- var (
6
- // the client disconnected before the stream completed.
7
- ErrStreamClosed = errors.New("stream closed by client")
8
-
9
- // a block fetch exceeded the timeout.
10
- ErrBlockTimeout = errors.New("block fetch timed out")
11
-
12
- // all retry attempts failed.
13
- ErrMaxRetriesExceeded = errors.New("max retries exceeded")
14
-
15
- // the pipe was closed and all data was consumed.
16
- ErrPipeDrained = errors.New("pipe drained")
17
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/internal/stream/pipe.go DELETED
@@ -1,314 +0,0 @@
1
- package stream
2
-
3
- import (
4
- "EverythingSuckz/fsb/config"
5
- "EverythingSuckz/fsb/internal/utils"
6
- "context"
7
- "fmt"
8
- "io"
9
- "sync"
10
- "time"
11
-
12
- "github.com/celestix/gotgproto"
13
- "github.com/gotd/td/tg"
14
- "go.uber.org/zap"
15
- )
16
-
17
- // calculateBlockSize func determines optimal block size based on the range requested.
18
- // Smaller ranges use smaller blocks to reduce wasted bandwidth during seeks.
19
- func calculateBlockSize(start, end int64) int64 {
20
- size := end - start + 1
21
-
22
- switch {
23
- case size < 512*1024: // < 512KB
24
- return 64 * 1024 // 64KB blocks
25
- case size < 4*1024*1024: // < 4MB
26
- return 256 * 1024 // 256KB blocks
27
- case size < 32*1024*1024: // < 32MB
28
- return 512 * 1024 // 512KB blocks
29
- default:
30
- return 1024 * 1024 // 1MB blocks by default
31
- }
32
- }
33
-
34
- // StreamPipe reads data from Telegram with concurrent prefetching. implements `io.ReadCloser`.
35
- // credits: [teldrive](https://github.com/tgdrive/teldrive/blob/1071a6e8b5a4076cacc5a0989ef245fae517d837/internal/reader/tg_reader.go)
36
- type StreamPipe struct {
37
- ctx context.Context
38
- cancel context.CancelFunc
39
- log *zap.Logger
40
-
41
- // tg connection
42
- client *gotgproto.Client
43
- location tg.InputFileLocationClass
44
-
45
- // range stuff
46
- start int64
47
- end int64
48
- blockSize int64
49
- totalBytes int64
50
-
51
- // prefetch pipeline
52
- blockQueue chan []byte
53
-
54
- // current read state
55
- currentBlock []byte
56
- blockOffset int64
57
- bytesRead int64
58
-
59
- // lifecycle
60
- closeOnce sync.Once
61
- }
62
-
63
- // class function which creates a StreamPipe with default configuration.
64
- func NewStreamPipe(
65
- ctx context.Context,
66
- client *gotgproto.Client,
67
- location tg.InputFileLocationClass,
68
- start, end int64,
69
- log *zap.Logger,
70
- ) (io.ReadCloser, error) {
71
-
72
- if start > end {
73
- return nil, fmt.Errorf("invalid range: start (%d) > end (%d)", start, end)
74
- }
75
-
76
- ctx, cancel := context.WithCancel(ctx)
77
-
78
- totalBytes := end - start + 1
79
- blockSize := calculateBlockSize(start, end)
80
-
81
- p := &StreamPipe{
82
- ctx: ctx,
83
- cancel: cancel,
84
- log: log.Named("StreamPipe"),
85
- client: client,
86
- location: location,
87
- start: start,
88
- end: end,
89
- blockSize: blockSize,
90
- totalBytes: totalBytes,
91
- blockQueue: make(chan []byte, config.ValueOf.StreamBufferCount),
92
- }
93
-
94
- // start prefetching in background
95
- go p.prefetch()
96
-
97
- return p, nil
98
- }
99
-
100
- // Read implements io.Reader
101
- func (p *StreamPipe) Read(buf []byte) (n int, err error) {
102
- if p.bytesRead >= p.totalBytes {
103
- p.log.Sugar().Debug("EOF (bytesread == contentLength)")
104
- return 0, io.EOF
105
- }
106
-
107
- // need a new block?
108
- if p.blockOffset >= int64(len(p.currentBlock)) {
109
- select {
110
- case block, ok := <-p.blockQueue:
111
- if !ok {
112
- if p.bytesRead >= p.totalBytes {
113
- return 0, io.EOF
114
- }
115
- return 0, ErrPipeDrained
116
- }
117
- p.currentBlock = block
118
- p.blockOffset = 0
119
- case <-p.ctx.Done():
120
- return 0, p.ctx.Err()
121
- }
122
- }
123
-
124
- // copy available data
125
- n = copy(buf, p.currentBlock[p.blockOffset:])
126
- p.blockOffset += int64(n)
127
- p.bytesRead += int64(n)
128
-
129
- return n, nil
130
- }
131
-
132
- // Close implements io.Closer.
133
- // it cancels prefetching and releases resources.
134
- func (p *StreamPipe) Close() error {
135
- p.closeOnce.Do(func() {
136
- p.cancel()
137
- })
138
- return nil
139
- }
140
-
141
- // prefetch runs in a goroutine, fetching blocks concurrently and sending to blockQueue.
142
- func (p *StreamPipe) prefetch() {
143
- defer close(p.blockQueue)
144
-
145
- // calc block boundaries
146
- alignedStart := p.start - (p.start % p.blockSize)
147
- leftTrim := p.start - alignedStart
148
- rightTrim := (p.end % p.blockSize) + 1
149
- totalBlocks := int((p.end - alignedStart + p.blockSize) / p.blockSize)
150
-
151
- currentBlock := 0
152
- offset := alignedStart
153
-
154
- for currentBlock < totalBlocks {
155
- // check for cancellation
156
- select {
157
- case <-p.ctx.Done():
158
- return
159
- default:
160
- }
161
-
162
- // fetch a batch of blocks concurrently
163
- batchSize := min(config.ValueOf.StreamConcurrency, totalBlocks-currentBlock)
164
- blocks := make([][]byte, batchSize)
165
-
166
- var wg sync.WaitGroup
167
- var fetchErr error
168
- var errMu sync.Mutex
169
-
170
- for i := range batchSize {
171
- wg.Add(1)
172
- go func(idx int) {
173
- defer wg.Done()
174
-
175
- blockNum := currentBlock + idx
176
- blockOffset := offset + int64(idx)*p.blockSize
177
-
178
- data, err := p.downloadBlockWithRetry(blockOffset)
179
- dataLen := int64(len(data))
180
-
181
- if err != nil {
182
- errMu.Lock()
183
- if fetchErr == nil {
184
- fetchErr = err
185
- }
186
- errMu.Unlock()
187
- return
188
- }
189
-
190
- // trim first/last block to exact range
191
- if totalBlocks == 1 {
192
- if dataLen < rightTrim {
193
- rightTrim = dataLen
194
- }
195
- if leftTrim > dataLen {
196
- leftTrim = dataLen
197
- }
198
- data = data[leftTrim:rightTrim]
199
- } else if blockNum == 0 {
200
- if leftTrim > dataLen {
201
- leftTrim = dataLen
202
- }
203
- data = data[leftTrim:]
204
- } else if blockNum == totalBlocks-1 {
205
- if dataLen > rightTrim {
206
- data = data[:rightTrim]
207
- }
208
- }
209
-
210
- blocks[idx] = data
211
- }(i)
212
- }
213
-
214
- wg.Wait()
215
-
216
- // handle errors
217
- // ignore context cancellation cuz it's expected on disconnect
218
- if fetchErr != nil {
219
- if p.ctx.Err() == nil {
220
- p.log.Error("block download failed", zap.Error(fetchErr))
221
- }
222
- return
223
- }
224
-
225
- // send blocks to queue in order
226
- for _, block := range blocks {
227
- if block == nil {
228
- // a fetch failure that wasn't captured, should not happen but just in case.
229
- p.log.Error("unexpected nil block in batch, aborting prefetch")
230
- return
231
- }
232
- select {
233
- case p.blockQueue <- block:
234
- case <-p.ctx.Done():
235
- return
236
- }
237
- }
238
-
239
- currentBlock += batchSize
240
- offset += p.blockSize * int64(batchSize)
241
- }
242
- }
243
-
244
- // downloadBlockWithRetry fetches a block with exponential backoff retry.
245
- func (p *StreamPipe) downloadBlockWithRetry(offset int64) ([]byte, error) {
246
- var lastErr error
247
-
248
- // TODO: make configurable later
249
- backoff := 100 * time.Millisecond // initial backoff = 100ms
250
- const maxBackoff = 15 * time.Second // max backoff = 15s
251
-
252
- for attempt := 0; attempt < config.ValueOf.StreamMaxRetries; attempt++ {
253
- // check context before each attempt
254
- if p.ctx.Err() != nil {
255
- return nil, p.ctx.Err()
256
- }
257
-
258
- ctx, cancel := context.WithTimeout(p.ctx, time.Duration(config.ValueOf.StreamTimeoutSec)*time.Second)
259
- data, err := utils.TimeFuncWithResult(p.log, "downloadBlock", func() ([]byte, error) {
260
- return p.downloadBlock(ctx, offset)
261
- })
262
- cancel()
263
-
264
- if err == nil {
265
- return data, nil
266
- }
267
-
268
- lastErr = err
269
-
270
- // don't retry on context cancellation
271
- if p.ctx.Err() != nil {
272
- return nil, p.ctx.Err()
273
- }
274
-
275
- // exponential backoff
276
- select {
277
- case <-time.After(backoff):
278
- backoff *= 2
279
- // making sure backoff doesn't grow indefinitely in case of persistent failures
280
- if backoff > maxBackoff {
281
- backoff = maxBackoff
282
- }
283
- case <-p.ctx.Done():
284
- return nil, p.ctx.Err()
285
- }
286
- }
287
-
288
- return nil, fmt.Errorf("%w: %v", ErrMaxRetriesExceeded, lastErr)
289
- }
290
-
291
- // downloadBlock fetches a single block from Telegram.
292
- func (p *StreamPipe) downloadBlock(ctx context.Context, offset int64) ([]byte, error) {
293
- p.log.Sugar().Debugf("Downloading block at offset %d (block size: %d)", offset, p.blockSize)
294
- res, err := p.client.API().UploadGetFile(ctx, &tg.UploadGetFileRequest{
295
- Offset: offset,
296
- Limit: int(p.blockSize),
297
- Location: p.location,
298
- })
299
-
300
- if err != nil {
301
- return nil, err
302
- }
303
-
304
- switch result := res.(type) {
305
- case *tg.UploadFile:
306
- return result.Bytes, nil
307
- case *tg.UploadFileCDNRedirect:
308
- // handle CDN redirect if needed (not implemented here, but could be added)
309
- // https://core.telegram.org/cdn
310
- return nil, fmt.Errorf("CDN redirect not supported in this implementation (redirect to DC %d)", result.DCID)
311
- default:
312
- return nil, fmt.Errorf("unexpected response type: %T", res)
313
- }
314
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/internal/types/file.go DELETED
@@ -1,44 +0,0 @@
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.InputFileLocationClass
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/internal/types/response.go DELETED
@@ -1,8 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
test-clone/internal/utils/hashing.go DELETED
@@ -1,18 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/internal/utils/helpers.go DELETED
@@ -1,198 +0,0 @@
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
- "strings"
12
-
13
- "github.com/celestix/gotgproto"
14
- "github.com/celestix/gotgproto/ext"
15
- "github.com/celestix/gotgproto/storage"
16
- "github.com/gotd/td/tg"
17
- "go.uber.org/zap"
18
- )
19
-
20
- // https://stackoverflow.com/a/70802740/15807350
21
- func Contains[T comparable](s []T, e T) bool {
22
- for _, v := range s {
23
- if v == e {
24
- return true
25
- }
26
- }
27
- return false
28
- }
29
-
30
- // IsClientDisconnectError checks if the error is due to client disconnecting
31
- // e.g. user seeking in video, stopping playback, or network issues on client side
32
- func IsClientDisconnectError(err error) bool {
33
- if err == nil {
34
- return false
35
- }
36
- errStr := err.Error()
37
- return strings.Contains(errStr, "connection was aborted") ||
38
- strings.Contains(errStr, "connection reset by peer") ||
39
- strings.Contains(errStr, "broken pipe") ||
40
- strings.Contains(errStr, "forcibly closed")
41
- }
42
-
43
- // telegram helper functions
44
- // TODO: move these to a separate package if they grow too large
45
-
46
- func GetTGMessage(ctx context.Context, client *gotgproto.Client, messageID int) (*tg.Message, error) {
47
- inputMessageID := tg.InputMessageClass(&tg.InputMessageID{ID: messageID})
48
- channel, err := GetLogChannelPeer(ctx, client.API(), client.PeerStorage)
49
- if err != nil {
50
- return nil, err
51
- }
52
- messageRequest := tg.ChannelsGetMessagesRequest{Channel: channel, ID: []tg.InputMessageClass{inputMessageID}}
53
- res, err := client.API().ChannelsGetMessages(ctx, &messageRequest)
54
- if err != nil {
55
- return nil, err
56
- }
57
- messages := res.(*tg.MessagesChannelMessages)
58
- message := messages.Messages[0]
59
- if _, ok := message.(*tg.Message); ok {
60
- return message.(*tg.Message), nil
61
- } else {
62
- return nil, fmt.Errorf("this file was deleted")
63
- }
64
- }
65
-
66
- func FileFromMedia(media tg.MessageMediaClass) (*types.File, error) {
67
- switch media := media.(type) {
68
- case *tg.MessageMediaDocument:
69
- document, ok := media.Document.AsNotEmpty()
70
- if !ok {
71
- return nil, fmt.Errorf("unexpected type %T", media)
72
- }
73
- var fileName string
74
- for _, attribute := range document.Attributes {
75
- if name, ok := attribute.(*tg.DocumentAttributeFilename); ok {
76
- fileName = name.FileName
77
- break
78
- }
79
- }
80
- return &types.File{
81
- Location: document.AsInputDocumentFileLocation(),
82
- FileSize: document.Size,
83
- FileName: fileName,
84
- MimeType: document.MimeType,
85
- ID: document.ID,
86
- }, nil
87
- case *tg.MessageMediaPhoto:
88
- photo, ok := media.Photo.AsNotEmpty()
89
- if !ok {
90
- return nil, fmt.Errorf("unexpected type %T", media)
91
- }
92
- sizes := photo.Sizes
93
- if len(sizes) == 0 {
94
- return nil, errors.New("photo has no sizes")
95
- }
96
- photoSize := sizes[len(sizes)-1]
97
- size, ok := photoSize.AsNotEmpty()
98
- if !ok {
99
- return nil, errors.New("photo size is empty")
100
- }
101
- location := new(tg.InputPhotoFileLocation)
102
- location.ID = photo.GetID()
103
- location.AccessHash = photo.GetAccessHash()
104
- location.FileReference = photo.GetFileReference()
105
- location.ThumbSize = size.GetType()
106
- return &types.File{
107
- Location: location,
108
- FileSize: 0, // caller should judge if this is a photo or not
109
- FileName: fmt.Sprintf("photo_%d.jpg", photo.GetID()),
110
- MimeType: "image/jpeg",
111
- ID: photo.GetID(),
112
- }, nil
113
- }
114
- return nil, fmt.Errorf("unexpected type %T", media)
115
- }
116
-
117
- func FileFromMessage(ctx context.Context, client *gotgproto.Client, messageID int) (*types.File, error) {
118
- key := fmt.Sprintf("file:%d:%d", messageID, client.Self.ID)
119
- log := Logger.Named("GetMessageMedia")
120
- var cachedMedia types.File
121
- err := cache.GetCache().Get(key, &cachedMedia)
122
- if err == nil {
123
- log.Debug("Using cached media message properties", zap.Int("messageID", messageID), zap.Int64("clientID", client.Self.ID))
124
- return &cachedMedia, nil
125
- }
126
- log.Debug("Fetching file properties from message ID", zap.Int("messageID", messageID), zap.Int64("clientID", client.Self.ID))
127
- message, err := GetTGMessage(ctx, client, messageID)
128
- if err != nil {
129
- return nil, err
130
- }
131
- file, err := FileFromMedia(message.Media)
132
- if err != nil {
133
- return nil, err
134
- }
135
- err = cache.GetCache().Set(
136
- key,
137
- file,
138
- 3600,
139
- )
140
- if err != nil {
141
- return nil, err
142
- }
143
- return file, nil
144
- }
145
-
146
- func GetLogChannelPeer(ctx context.Context, api *tg.Client, peerStorage *storage.PeerStorage) (*tg.InputChannel, error) {
147
- cachedInputPeer := peerStorage.GetInputPeerById(config.ValueOf.LogChannelID)
148
-
149
- switch peer := cachedInputPeer.(type) {
150
- case *tg.InputPeerEmpty:
151
- break
152
- case *tg.InputPeerChannel:
153
- return &tg.InputChannel{
154
- ChannelID: peer.ChannelID,
155
- AccessHash: peer.AccessHash,
156
- }, nil
157
- default:
158
- return nil, errors.New("unexpected type of input peer")
159
- }
160
- inputChannel := &tg.InputChannel{
161
- ChannelID: config.ValueOf.LogChannelID,
162
- }
163
- channels, err := api.ChannelsGetChannels(ctx, []tg.InputChannelClass{inputChannel})
164
- if err != nil {
165
- return nil, err
166
- }
167
- if len(channels.GetChats()) == 0 {
168
- return nil, errors.New("no channels found")
169
- }
170
- channel, ok := channels.GetChats()[0].(*tg.Channel)
171
- if !ok {
172
- return nil, errors.New("type assertion to *tg.Channel failed")
173
- }
174
- // Bruh, I literally have to call library internal functions at this point
175
- peerStorage.AddPeer(channel.GetID(), channel.AccessHash, storage.TypeChannel, "")
176
- return channel.AsInput(), nil
177
- }
178
-
179
- func ForwardMessages(ctx *ext.Context, fromChatId, toChatId int64, messageID int) (*tg.Updates, error) {
180
- fromPeer := ctx.PeerStorage.GetInputPeerById(fromChatId)
181
- if fromPeer.Zero() {
182
- return nil, fmt.Errorf("fromChatId: %d is not a valid peer", fromChatId)
183
- }
184
- toPeer, err := GetLogChannelPeer(ctx, ctx.Raw, ctx.PeerStorage)
185
- if err != nil {
186
- return nil, err
187
- }
188
- update, err := ctx.Raw.MessagesForwardMessages(ctx, &tg.MessagesForwardMessagesRequest{
189
- RandomID: []int64{rand.Int63()},
190
- FromPeer: fromPeer,
191
- ID: []int{messageID},
192
- ToPeer: &tg.InputPeerChannel{ChannelID: toPeer.ChannelID, AccessHash: toPeer.AccessHash},
193
- })
194
- if err != nil {
195
- return nil, err
196
- }
197
- return update.(*tg.Updates), nil
198
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/internal/utils/logger.go DELETED
@@ -1,52 +0,0 @@
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
- layout := "02/01/2006 03:04:05 PM"
17
- if debugMode {
18
- layout = "02/01/2006 03:04:05.000 PM"
19
- }
20
- enc.AppendString(t.Format(layout))
21
- }
22
- consoleConfig := zap.NewDevelopmentEncoderConfig()
23
- consoleConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder
24
- consoleConfig.EncodeTime = customTimeEncoder
25
- consoleEncoder := zapcore.NewConsoleEncoder(consoleConfig)
26
-
27
- fileEncoderConfig := zap.NewProductionEncoderConfig()
28
- fileEncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
29
- fileEncoder := zapcore.NewJSONEncoder(fileEncoderConfig)
30
-
31
- fileWriter := zapcore.AddSync(&lumberjack.Logger{
32
- Filename: "logs/app.log",
33
- MaxSize: 10,
34
- MaxBackups: 3,
35
- MaxAge: 7,
36
- Compress: true,
37
- })
38
-
39
- var consoleLevel zapcore.Level
40
- if debugMode {
41
- consoleLevel = zapcore.DebugLevel
42
- } else {
43
- consoleLevel = zapcore.FatalLevel
44
- }
45
-
46
- core := zapcore.NewTee(
47
- zapcore.NewCore(consoleEncoder, zapcore.AddSync(os.Stdout), consoleLevel),
48
- zapcore.NewCore(fileEncoder, fileWriter, zapcore.DebugLevel),
49
- )
50
-
51
- Logger = zap.New(core, zap.AddStacktrace(zapcore.FatalLevel))
52
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/internal/utils/time_format.go DELETED
@@ -1,42 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/internal/utils/timing.go DELETED
@@ -1,17 +0,0 @@
1
- package utils
2
-
3
- import (
4
- "time"
5
-
6
- "go.uber.org/zap"
7
- )
8
-
9
- // TimeFuncWithResult wraps a function call and logs its execution time, returning a result
10
- func TimeFuncWithResult[T any](log *zap.Logger, funcName string, fn func() (T, error)) (T, error) {
11
- start := time.Now()
12
- defer func() {
13
- duration := time.Since(start).Milliseconds()
14
- log.Debug(funcName+" executed", zap.Int64("duration_ms", duration))
15
- }()
16
- return fn()
17
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/logs/app.log DELETED
The diff for this file is too large to render. See raw diff
 
test-clone/pkg/qrlogin/encoder.go DELETED
@@ -1,52 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/pkg/qrlogin/qrcode.go DELETED
@@ -1,152 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test-clone/run.bat DELETED
@@ -1,4 +0,0 @@
1
- @echo off
2
- echo Iniciando Telegram File Stream Bot...
3
- go run ./cmd/fsb run
4
- pause
 
 
 
 
 
test-clone/start.bat DELETED
@@ -1,17 +0,0 @@
1
- @echo off
2
- echo.
3
- echo ==============================================
4
- echo Instalando dependencias del Bot...
5
- echo ==============================================
6
- echo.
7
-
8
- echo [1/2] Descargando modulos de Go...
9
- go mod download
10
- go mod tidy
11
-
12
- echo.
13
- echo [2/2] Iniciando Telegram File Stream Bot...
14
- echo ==============================================
15
- echo.
16
- go run ./cmd/fsb run
17
- pause