1.3.0 • Published 6 months ago

telegram-api-schema-methods v1.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

telegram-api-schema-methods

NPM Downloads

The library helps to type all methods for the Telegram User API (https://core.telegram.org/methods)

Install

yarn add telegram-api-schema-methods
# or
npm i telegram-api-schema-methods

Example

Example using the @mtproto/core library, which is optional (https://github.com/alik0211/mtproto-core)

import { makeTgUserApiMethods } from 'telegram-api-schema-methods';
import MTProto from '@mtproto/core/envs/node';
import path from 'path';

// 1. Create instance
const mtproto = new MTProto({
    api_id: YOU_API_ID,
    api_hash: YOU_API_HASH,
    storageOptions: {
        path: path.resolve(__dirname, './1.json'),
    },
});

// 2. Create telegram user api methods (automatic typing of parameters and the result of methods)
const tgUserApiMethods = makeTgUserApiMethods({
    request: (...args: any[]) => mtproto.call(...args),
});

// 3. Print the user country code
tgUserApiMethods.helpGetNearestDc({}).then(({ success, data, error }) => {
    if (success) {
        // auto typing result for typescript
        console.log('country:', data.country);
    } else {
        console.error(error);
    }
});

License

MIT

1.3.0

6 months ago

1.2.0

11 months ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.7

2 years ago

1.1.2

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.3

2 years ago