e39057bda5
todo: should we really enforce the version? tdlib uses current version from Version.h, but not every version there changes file id format (and v32 is fully compatible with v41 as far as im concerned) |
||
---|---|---|
.. | ||
src | ||
tests | ||
package.json | ||
README.md | ||
tsconfig.json |
@mtcute/file-id
A package that is used internally by @mtcute/client
to parse, serialize
and manipulate TDLib and Bot API compatible File IDs, but can also be used
for any other purposes.
Contents
This package exports a number of functions, namely:
parseFileId()
which parses provided File ID to an object representing its contentstoFileId()
which serializes provided object containing file info to a File IDtoUniqueFileId()
which serializes provided object containing file info to a Unique File IDfileIdTo*()
which converts a File ID to an input TL object, which can be used in RPC calls etc.
This package also exports namespace tdFileId
, which contains all the types
used by the library
Dependencies
This package uses @mtcute/core
BinaryReader
and BinaryWriter
classes to
work with binary streams. Additionally, it depends on @mtcute/tl
types to
allow type-safe code for conversion functions.
Note that @mtcute/core
itself depends on @mtcute/tl
, which might
redundantly increase your bundle size in case you don't actually use TL types.
Acknowledgements
This is basically a port of a portion of TDLib APIs, but greatly simplified in usage and made to work seamlessly with the rest of the MTCute APIs.
This is a list of files from TDLib repository, from which most of the code was taken:
- td/telegram/files/FileManager.cpp
- td/telegram/files/FileLocation.hpp
- td/telegram/PhotoSizeSource.h
- td/telegram/PhotoSizeSource.hpp
- td/telegram/Version.h
Additionally, some of the test cases were taken from a similar Python library, luckydonald/telegram_file_id