Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tg-file-id

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tg-file-id

Decode and encode telegram file_id and file_unique_id and convert between those.

  • 0.0.4
  • PyPI
  • Socket score

Maintainers
1

tg_file_id

Parse and construct Telegram file_ids and unique_file_ids. Even generate a unique_file_id from a file_id.

Examples below

  • Install
  • Parse file_ids
  • Parse file_unique_ids
  • Convert file_ids to file_unique_ids

Install

pip install tg-file-id

Parse file_ids

from tg_file_id.file_id import FileId

file_id = FileId.from_file_id('CAACAgIAAxkBAAIEol9yQhBqFnT4HXldAh31a-hYXuDIAAIECwACAoujAAFFn1sl9AABHbkbBA')

Now the file_id variable is an object like this:

DocumentFileId(
    file_id='CAACAgIAAxkBAAIEol9yQhBqFnT4HXldAh31a-hYXuDIAAIECwACAoujAAFFn1sl9AABHbkbBA',
    type_id=8,
    type_generic='document',
    type_detailed='sticker',
    dc_id=2,
    id=46033261910035204,
    access_hash=-5107925353769492667,
    version=4,
    sub_version=27,
)

Parse file_unique_ids

from tg_file_id.file_unique_id import FileUniqueId

unique_id = FileUniqueId.from_unique_id('AgADBAsAAgKLowAB')

Now the unique_id variable is an object like this:

FileUniqueId(
    unique_id='AgADBAsAAgKLowAB',
    type_id=2,
    id=46033261910035204
)

Convert file_ids to file_unique_ids

from tg_file_id.file_unique_id import FileUniqueId

unique_id = FileUniqueId.from_file_id('CAACAgIAAxkBAAIEol9yQhBqFnT4HXldAh31a-hYXuDIAAIECwACAoujAAFFn1sl9AABHbkbBA')
calculated_file_unique_id = unique_id.to_unique_id()

Now calculated_file_unique_id is

'AgADBAsAAgKLowAB'

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc