MCPcopy Index your code
hub / github.com/HirbodBehnam/file2url-go

github.com/HirbodBehnam/file2url-go @v1.5.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.5.2 ↗ · + Follow
48 symbols 125 edges 18 files 40 documented · 83%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

File 2 URL Bot

A simple bot to convert files sent to it to URLs to make direct download links.

Features

  • Fast download speeds
  • Option to allow only specific users to create download links
  • Range support
  • Database support

Setup

At first download the program from releases. Then before running the application, set these values as environment variables:

export APP_ID=1234
export APP_HASH=abcd
export BOT_TOKEN=zyxw
export ALLOWED_USERS=1,2

ALLOWED_USERS is the list of user IDs which are allowed to use the bot. Do not specify this variable in order to make the bot public.

Running on your server

If you are planning to run this bot on your server you also have to specify these two environment variables:

export LISTEN=0.0.0.0:12345
export URL_PREFIX=my-ip-or-domain:12345

LISTEN is the listen address of the server. URL_PREFIX will be as the domain/ip of the links which are sent to users.

Then simply run the executable file.

Running with Heroku

To run this app on Heroku, you only need to specify one environment variable other than bot id and app hash/id.

export DYNO_NAME=my-dyno-name

Databases

This bot will use a database to store the file information which is mapped from a UUID. By default, bot will use an in memory cache to store these values. This each entry has a TTL of one day by default.

You can change the in memory cache to bbolt in order to make the data persistent on disk. To enable bbolt, set the environment variable of BOLT_DB_PATH to a file which is the database.

Extension points exported contracts — how you extend this code

Interface (Interface)
Interface provides an interface to store the files in a database of choice [2 implementers]
database/database.go
ChunkSource (Interface)
ChunkSource downloads chunks. [1 implementers]
bot/downloader/streamer.go

Core symbols most depended-on inside this repo

Get
called by 6
bot/clients/pool.go
Put
called by 4
bot/clients/pool.go
Close
called by 2
database/database.go
API
called by 2
bot/clients/pool.go
Do
called by 2
util/Once.go
Store
called by 1
database/database.go
Load
called by 1
database/database.go
NewMemoryCache
called by 1
database/memory_cache.go

Shape

Method 19
Function 18
Struct 9
Interface 2

Languages

Go100%

Modules by API surface

bot/downloader/streamer.go9 symbols
bot/clients/pool.go7 symbols
database/memory_cache.go6 symbols
database/database.go5 symbols
database/bolt.go5 symbols
util/Once.go2 symbols
config/config.go2 symbols
bot/downloader/internal.go2 symbols
bot/bot.go2 symbols
main.go1 symbols
database/loader.go1 symbols
bot/downloader/downloader.go1 symbols

For agents

$ claude mcp add file2url-go \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page