Skip to main content

A Telegram bot that can stream Telegram files to users over HTTP.

Project description

tgfilestream

A Telegram bot that can stream Telegram files to users over HTTP.

Setup

Install tgfilestream package

pip install tgfilestream

Optional Extras

  • For environment variables support:

    pip install tgfilestream[env]
    
  • For fast processing:

    pip install tgfilestream[fast]
    
  • For all features:

    pip install tgfilestream[all]
    

Create a text file to store environment variables example (secrets.env):

TG_API_ID=1234567
TG_API_HASH=66a73ed2f8a80f52488dfdb3b128bae6
HOST=127.0.0.1
PORT=8080
PUBLIC_URL=http://127.0.0.1:8080
TG_BOT_FATHER_TOKEN=1234567890:b93dcfa3120fa82350e2bc72df83380e

Start the bot and server using the following command

tgfilestream --env [path to the text file]

example:

tgfilestream --env secrets.env

Note

A reverse proxy is recommended to add TLS. When using a reverse proxy, keep HOST as-is, but add the publicly accessible URL to PUBLIC_URL. The URL should include the protocol, e.g. https://example.com.

Environment variables

  • TG_API_ID (required) - Your Telegram API ID.
  • TG_API_HASH (required) - Your Telegram API hash.
  • TG_BOT_TOKEN (required) - Your Telegram Bot Token.
  • TG_SESSION_NAME (defaults to tgfilestream) - The name of the Telethon session file to use.
  • PORT (defaults to 8080) - The port to listen at.
  • HOST (defaults to localhost) - The host to listen at.
  • PUBLIC_URL (defaults to http://localhost:8080) - The prefix for links that the bot gives.
  • TRUST_FORWARD_HEADERS (defaults to false) - Whether or not to trust X-Forwarded-For headers when logging requests.
  • DEBUG (defaults to false) - Whether or not to enable extra prints.
  • LOG_CONFIG - Path to a Python basic log config. Overrides DEBUG.
  • REQUEST_LIMIT (default 5) - The maximum number of requests a single IP can have active at a time.
  • CONNECTION_LIMIT (default 20) - The maximum number of connections to a single Telegram datacenter.
  • CACHE_SIZE (defaults to 128) - The number of FileInfo objects (messages) to cache.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tgfilestream-0.1.4.tar.gz (23.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tgfilestream-0.1.4-py3-none-any.whl (27.3 kB view details)

Uploaded Python 3

File details

Details for the file tgfilestream-0.1.4.tar.gz.

File metadata

  • Download URL: tgfilestream-0.1.4.tar.gz
  • Upload date:
  • Size: 23.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for tgfilestream-0.1.4.tar.gz
Algorithm Hash digest
SHA256 0d024ba9c15244ea4297b25639efade6fad4c7759384568a08768c6f464186a8
MD5 4350c4ccd4196f89519e808135b6b31e
BLAKE2b-256 a494e6fc22834c700389293f2643dac7171018e540f64bbd68bdd4053db0b096

See more details on using hashes here.

File details

Details for the file tgfilestream-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: tgfilestream-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 27.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for tgfilestream-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d6bd04f6f44281873dc3a1f1f988a9c2b102e923cf736f427f52e7c3134397de
MD5 abf1c0f08d9f04e94dc824b931e0b5da
BLAKE2b-256 a00ef13b1492d587a43b52ed96323f8ca5b51c33494f98afaa5ef757c995565a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page