telegram-api-schema-methods
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';
const mtproto = new MTProto({
api_id: YOU_API_ID,
api_hash: YOU_API_HASH,
storageOptions: {
path: path.resolve(__dirname, './1.json'),
},
});
const tgUserApiMethods = makeTgUserApiMethods({
request: (...args: any[]) => mtproto.call(...args),
});
tgUserApiMethods.helpGetNearestDc({}).then(({ success, data, error }) => {
if (success) {
console.log('country:', data.country);
} else {
console.error(error);
}
});
License
MIT