mtcute/packages/client/src/methods
2021-05-16 12:59:00 +03:00
..
auth refactor(client): normalized MtCuteTypeAssertionError errors 2021-05-12 18:16:50 +03:00
bots feat(client): getCallbackAnswer method 2021-05-16 12:59:00 +03:00
chats refactor(client): made resolvePeer return InputPeer, and removed now redundant normalizeTo calls 2021-05-15 20:25:59 +03:00
contacts feat(client): resolvePeerMany method 2021-05-11 22:43:11 +03:00
dialogs refactor(client): normalized MtCuteTypeAssertionError errors 2021-05-12 18:16:50 +03:00
files feat(client): stop geolive messages 2021-05-09 12:03:45 +03:00
invite-links refactor(client): made resolvePeer return InputPeer, and removed now redundant normalizeTo calls 2021-05-15 20:25:59 +03:00
messages refactor(client): moved handling of inline messages to a separate method 2021-05-16 02:09:51 +03:00
misc feat(client): support takeout session 2021-04-24 21:11:34 +03:00
parse-modes fix(client): stupid parse modes related bug 2021-04-24 19:26:23 +03:00
pasword feat(client): control 2fa password 2021-05-09 14:35:47 +03:00
stickers feat(client): setStickerSetThumb method 2021-05-06 12:11:09 +03:00
users refactor(client): made resolvePeer return InputPeer, and removed now redundant normalizeTo calls 2021-05-15 20:25:59 +03:00
_imports.ts fix(client): fixed game highscore exports 2021-05-16 02:52:51 +03:00
README.md Initial commit 2021-04-08 12:19:38 +03:00
updates.ts refactor: prefer switches to else-if chains 2021-05-12 17:58:45 +03:00

What is this?

Files in this directory are pre-processed by generate-client.js, and client.ts is generated from the functions that are exported in this directory.

Since we need to properly type the copied signatures, there are a few "magic" instructions for the preprocessor that are used to handle imports. Also, there are a few "magic" instructions to make private methods and extend client fields.

All instructions are used as a one-line comment, like this: // @copy

@copy

Can be placed before an import or any other code block.

When placed before import, this import will be copied to client.ts, and paths will be adjusted. When there are multiple copied imports from the same files, they are merged.

When placed before any other block, it will be directly copied before the TelegramClient class.

Note

all copied imports should be inside _imports.ts file.

Example:

// @copy
import { Something } from '../../somewhere'

// @copy
interface SomeGreatInterface { ... }

@extension

Used before an interface declaration. Fields from that interface will be added as protected to TelegramClient.

Example:

// @extension
interface AwesomeExtension {
    _field1: number
    _field2: string
}

@initialize

Often you'll want to initialize your @extension fields in a constructor. You can do this by using @initialize instruction before a function containing initialization code.

Note

If you are using some custom types, make sure their imports are copied!

Example:

// @initialize
function _initializeAwesomeExtension(this: TelegramClient) {
    this._field1 = 42
    this._field2 = 'uwu'
}

@returns-exported

Used as a first statement inside an exported function's body to indicate that this method returns an object of type which is exported from the same file.

Example:

export type FooOrBar = Foo | Bar

export function getFooOrBar(this: TelegramClient): FooOrBar {
    // @returns-exported
    return new Foo()
}