UNPKG

@tgsnake/fileid

Version:

core framework for tgsnake for generating file id

180 lines 5.34 kB
/// <reference types="node" /> /** * tgsnake - Telegram MTProto framework for nodejs. * Copyright (C) 2022 butthx <https://github.com/butthx> * * THIS FILE IS PART OF TGSNAKE * * tgsnake is a free software : you can redistribute it and/or modify * it under the terms of the MIT License as published. */ import { Buffer } from 'node:buffer'; export declare enum FileType { THUMBNAIL = 0, CHAT_PHOTO = 1, PHOTO = 2, VOICE = 3, VIDEO = 4, DOCUMENT = 5, ENCRYPTED = 6, TEMP = 7, STICKER = 8, AUDIO = 9, ANIMATION = 10, ENCRYPTED_THUMBNAIL = 11, WALLPAPER = 12, VIDEO_NOTE = 13, SECURE_RAW = 14, SECURE = 15, BACKGROUND = 16, DOCUMENT_AS_FILE = 17, WEB_LOCATION_FLAG = 16777216, FILE_REFERENCE_FLAG = 33554432 } export declare enum ThumbnailSource { LEGACY = 0, THUMBNAIL = 1, CHAT_PHOTO_SMALL = 2, CHAT_PHOTO_BIG = 3, STICKER_SET_THUMBNAIL = 4 } export declare enum FileTypeUniqueId { WEB = 0, PHOTO = 1, DOCUMENT = 2, SECURE = 3, ENCRYPTED = 4, TEMP = 5 } export declare const PHOTO_TYPES: FileType[]; export declare const DOCUMENT_TYPES: FileType[]; export interface Options { /** * The major version of bot api file id. Usually is 4. */ version: number; /** * The minor version of bot api file id. Usually same with tdlib version or 32. */ subVersion: number; /** * The data center id, where that file is stored. */ dcId: number; /** * The enum/number of FileType. recommend to use enum. * ```ts * import { FileType, FileId } from "@tgsnake/fileid" * const fileId = FileId.encode({ * fileType : FileType.PHOTO * }) * ``` */ fileType: FileType; /** * The id of file. */ id: bigint; /** * The hash to access that file. */ accessHash: bigint; /** * File reference of that file. */ fileReference?: Buffer; /** * If the file has web location, fill this with url of that web location. */ url?: string; /** * If the file has volume id, fill this with it. or if file doesn't have a volume id, fill this with BigInt(0). This is required when you try to make file id of photo/thumbnail. */ volumeId?: bigint; /** * If the file has local id, fill this with it. or if file doesn't have a local id, fill this with 0. This is required when you try to make file id of photo/thumbnail. */ localId?: number; /** * The secret key from file, if file doesn't have a secret key fill this with BigInt(0). This is required when you try to make ThumbnailSource.LEGACY */ secret?: bigint; /** * If you want to make a file id of photo profil, fill this with BigInt of chatId. */ chatId?: bigint; /** * If you want to make a file id of photo profil, fill this with BigInt of accessHash that chat, or BigInt(0) it must be work when you doesn't have a accessHash of that chat. */ chatAccessHash?: bigint; /** * The id of that sticker set. */ stickerSetId?: bigint; /** * The accessHash of that sticker set. BigInt(0) ot must be work when you doesn't have a accessHash of that sticker set. */ stickerSetAccessHash?: bigint; /** * The enum/number of ThumbnailSource. recommended to use enum. * ```ts * import { FileId, ThumbnailSource } from "@tgsnake/fileid" * const fileId = FileId.encode({ * thumbnailSource : ThumbnailSource.DOCUMENT * }) * ``` */ thumbnailSource?: ThumbnailSource; /** * The enum/number of FileType. recommend to use enum. * ```ts * import { FileType, FileId } from "@tgsnake/fileid" * const fileId = FileId.encode({ * thumbnailFileType : FileType.PHOTO * }) * ``` */ thumbnailFileType?: FileType; /** * The size of that thumbnail. * see : https://core.telegram.org/api/files#image-thumbnail-types */ thumbnailSize?: string; /** * Only for generating uniqueFileId. * The enum/number of FileTypeUniqueId. recommended to use enum. * ```ts * import { FileTypeUniqueId, FileId } from "@tgsnake/fileid" * const fileId = FileId.encode({ * fileType : FileTypeUniqueId.PHOTO * }) * ``` */ fileTypeUniqueId?: FileTypeUniqueId; } export declare function base64_url_encode(base: string | Buffer): string; export declare function base64_url_decode(base: string | Buffer): Buffer; export declare function base64urlTobase64(text: string): string; export declare function rle_encode(base: string | Buffer): Buffer; export declare function rle_decode(base: string | Buffer): Buffer; export declare class Writer { private buffer; constructor(); writeInt(int: number): Writer; writeBigInt(int: bigint): Writer; writeString(str: string): Writer; writeBuffer(buffer: Buffer): Writer; results(): Buffer; } export declare class Reader { private buffer; private start; private cur; constructor(buffer: Buffer); readInt(): number; readBigInt(signed?: boolean): bigint; readString(): string; readBuffer(): Buffer; } export declare function mod(n: number, m: number): number; //# sourceMappingURL=utils.d.ts.map