ESM + end-to-end tests (#11)

* feat: moved tl-runtime to esm and native ArrayBuffers

* feat: migration to esm

* fix(core): web-related fixes

* test: finally, some good fucking e2e

* chore: fixed linters etc

* ci: added e2e to ci

* build(tl): fixed gen-code on node 20

* fix: codegen Uint8Array, not Buffer

never `git reset --hard` kids

* build: only do type-aware linting for `packages/*`

* build: ignore no-unresolved in ci for e2e

* fix: node 16 doesn't have subtle crypto apparently?

* fix(tests): use Uint8Array

for gods sake please can i just merge this already

* ci: don't parallel tasks in ci

because machines are utter garbage and it may just randomly break

* ci: pass secrets to e2e tests

* ci: separate cli command for ci

apparently im retarded

* fix: run codegen in e2e

im actually retarded

* ci: more fixes for e2e

* ci: debugging stuff

* ci: still debugging

* ci: hopefully fix ci???
This commit is contained in:
Alina Tumanova 2023-10-16 19:23:53 +03:00 committed by GitHub
parent 01e5fbb95d
commit f5976a2d74
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
613 changed files with 5532 additions and 3261 deletions

3
.dockerignore Normal file
View file

@ -0,0 +1,3 @@
**/node_modules
**/private
**/dist

View file

@ -3,12 +3,11 @@ const baseConfig = require('./.eslintrc.js')
module.exports = { module.exports = {
...baseConfig, ...baseConfig,
overrides: [ overrides: [
baseConfig.overrides[0],
{ {
...baseConfig.overrides[0], ...baseConfig.overrides[0],
extends: [ files: ['packages/**/*.ts'],
'plugin:@typescript-eslint/strict-type-checked', extends: ['plugin:@typescript-eslint/strict-type-checked', 'plugin:import/typescript'],
'plugin:import/typescript',
],
parser: '@typescript-eslint/parser', parser: '@typescript-eslint/parser',
parserOptions: { parserOptions: {
project: true, project: true,
@ -16,13 +15,16 @@ module.exports = {
}, },
rules: { rules: {
...baseConfig.overrides[0].rules, ...baseConfig.overrides[0].rules,
'@typescript-eslint/restrict-template-expressions': [ '@typescript-eslint/restrict-template-expressions': ['error', { allowNever: true }],
'error',
{ allowNever: true },
],
}, },
reportUnusedDisableDirectives: false, reportUnusedDisableDirectives: false,
}, },
...baseConfig.overrides.slice(1), ...baseConfig.overrides.slice(1),
{
files: ['e2e/**'],
rules: {
'import/no-unresolved': 'off',
},
},
], ],
} }

View file

@ -97,7 +97,7 @@ module.exports = {
yoda: 2, yoda: 2,
// Variables // Variables
'no-restricted-globals': [2], 'no-restricted-globals': ['error'],
'no-var': 1, 'no-var': 1,
// Codestyle // Codestyle
@ -169,6 +169,7 @@ module.exports = {
'import/no-default-export': 'error', 'import/no-default-export': 'error',
'no-console': ['error', { allow: ['warn', 'error'] }], 'no-console': ['error', { allow: ['warn', 'error'] }],
}, },
ignorePatterns: ['packages/client/utils.ts', 'packages/core/utils.ts'],
overrides: [ overrides: [
{ {
files: ['**/*.ts', '**/*.tsx'], files: ['**/*.ts', '**/*.tsx'],
@ -213,6 +214,7 @@ module.exports = {
'@typescript-eslint/unbound-method': 'off', '@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/no-dynamic-delete': 'off', '@typescript-eslint/no-dynamic-delete': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off', '@typescript-eslint/no-unsafe-member-access': 'off',
'no-restricted-globals': ['error', 'Buffer', '__dirname', 'require'],
}, },
reportUnusedDisableDirectives: false, reportUnusedDisableDirectives: false,
settings: { settings: {
@ -235,6 +237,12 @@ module.exports = {
'max-params': ['error', 4], 'max-params': ['error', 4],
}, },
}, },
{
files: ['e2e/cjs/**'],
rules: {
'no-restricted-globals': 'off',
},
},
], ],
settings: { settings: {
'import/resolver': { 'import/resolver': {

View file

@ -28,11 +28,19 @@ jobs:
- name: 'TL codegen' - name: 'TL codegen'
run: pnpm -C packages/tl run gen-code run: pnpm -C packages/tl run gen-code
- name: 'TypeScript' - name: 'TypeScript'
run: pnpm run lint:tsc run: pnpm run lint:tsc:ci
- name: 'ESLint' - name: 'ESLint'
env:
NODE_OPTIONS: "--max_old_space_size=4096"
run: pnpm run lint:ci run: pnpm run lint:ci
- name: 'Circular dependencies' - name: 'Circular dependencies'
run: pnpm run lint:dpdm run: pnpm run lint:dpdm
- run: pnpm run test:all - run: pnpm run test:all:ci
e2e:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- name: Run end-to-end tests
env:
API_ID: ${{ secrets.TELEGRAM_API_ID }}
API_HASH: ${{ secrets.TELEGRAM_API_HASH }}
run: cd e2e && ./cli.sh ci

2
.gitignore vendored
View file

@ -11,3 +11,5 @@ private/
docs/* docs/*
!docs/.nojekyll !docs/.nojekyll
*.tsbuildinfo

3
.mocharc.json Normal file
View file

@ -0,0 +1,3 @@
{
"node-option": ["experimental-specifier-resolution=node", "loader=ts-node/esm"]
}

7
e2e/.dockerignore Normal file
View file

@ -0,0 +1,7 @@
.verdaccio
node_modules
private
dist
pnpm-lock.yaml
.npmrc
.env*

3
e2e/.env.example Normal file
View file

@ -0,0 +1,3 @@
# obtain these values from my.telegram.org
API_ID=
API_HASH=

4
e2e/.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
.verdaccio/storage
.npmrc
pnpm-lock.yaml
.env

3
e2e/.mocharc.json Normal file
View file

@ -0,0 +1,3 @@
{
"node-option": []
}

View file

@ -0,0 +1,13 @@
storage: ./storage
auth:
htpasswd:
file: ./htpasswd
max_users: -1
packages:
'**':
access: $all
publish: $all
logs: { type: stdout, format: pretty, level: trace }

1
e2e/.verdaccio/htpasswd Normal file
View file

@ -0,0 +1 @@
mtcute-bot:$apr1$7rbqxva0$zyfFgknsbAxni.cq158Sf.

19
e2e/Dockerfile.build Normal file
View file

@ -0,0 +1,19 @@
FROM node:20-alpine
WORKDIR /app
RUN apk add python3 make g++ && \
corepack enable && \
corepack prepare pnpm@8.7.1 --activate
COPY ../ /app/
RUN pnpm install --frozen-lockfile && \
pnpm -C packages/tl run gen-code && \
# verdaccio is configured to allow anonymous publish, but npm requires a token 🥴
npm config set //verdaccio:4873/:_authToken fake-token
ENV REGISTRY="http://verdaccio:4873/"
ENV E2E="1"
ENTRYPOINT [ "node", "/app/scripts/publish.js" ]
CMD [ "all" ]

13
e2e/Dockerfile.test Normal file
View file

@ -0,0 +1,13 @@
FROM node:20-alpine
WORKDIR /app
RUN apk add python3 make g++ && \
corepack enable && \
corepack prepare pnpm@8.7.1 --activate
COPY ./ /app/
RUN npm config set -L project @mtcute:registry http://verdaccio:4873/ && \
chmod +x ./docker-entrypoint.sh
ENTRYPOINT [ "./docker-entrypoint.sh" ]
CMD [ "all" ]

48
e2e/README.md Normal file
View file

@ -0,0 +1,48 @@
# mtcute e2e tests
This directory contains end-to-end tests for mtcute.
They are made for 2 purposes:
- Ensure published packages work as expected and can properly be imported
- Ensure that the library works with the actual Telegram API (WIP)
To achieve the first goal, we use a Verdaccio container to publish the package to,
and then install it from there in another container
## Setting up
Before running the tests, you need to copy `.env.example` to `.env` and fill in the values
## Running tests
To run tests, you need to have Docker installed.
```bash
# first start Verdaccio:
./cli.sh start
# build and publish the package
./cli.sh update
# or a particular package
./cli.sh update tl-runtime
# run the tests
./cli.sh run
# or in docker
./cli.sh run-docker
```
## Developing
Once you have Verdaccio running, you can run the following commands to setup
the environment for development:
```bash
npm config set -L project @mtcute:registry http://verdaccio.e2e.orb.local/
./cli.sh install
```
> Replace the URL above with the one generated with your Docker GUI of choice
> (e2e > verdaccio > RMB > Open in browser). Example above assumes OrbStack
Then use `./cli.sh run` to run the tests

1
e2e/cjs/package.json Normal file
View file

@ -0,0 +1 @@
{}

View file

@ -0,0 +1,23 @@
const { BaseTelegramClient } = require('@mtcute/core')
const { describe, it } = require('mocha')
const { expect } = require('chai')
const { getApiParams } = require('../utils')
describe('@mtcute/core', function () {
this.timeout(60_000)
it('connects to test DC and makes help.getNearestDc', async () => {
const tg = new BaseTelegramClient({
...getApiParams(),
})
await tg.connect()
const config = await tg.call({ _: 'help.getNearestDc' })
await tg.close()
expect(config).to.be.an('object')
expect(config._).to.equal('nearestDc')
expect(config.thisDc).to.equal(2)
})
})

123
e2e/cjs/tests/tl-runtime.js Normal file
View file

@ -0,0 +1,123 @@
const {
TlBinaryReader,
TlBinaryWriter,
TlSerializationCounter,
hexEncode,
hexDecode,
hexDecodeToBuffer,
} = require('@mtcute/tl-runtime')
const Long = require('long')
const { describe, it } = require('mocha')
const { expect } = require('chai')
// here we primarily want to check that everything imports properly,
// and that the code is actually executable. The actual correctness
// of the implementation is covered tested by unit tests
describe('@mtcute/tl-runtime', () => {
describe('encodings', () => {
it('works with Buffers', () => {
const buf = Buffer.alloc(5)
hexDecode(buf, '0102030405')
expect(hexEncode(Buffer.from('hello'))).to.equal('68656c6c6f')
expect(buf).eql(Buffer.from([1, 2, 3, 4, 5]))
})
it('works with Uint8Arrays', () => {
const buf = new Uint8Array(5)
hexDecode(buf, '0102030405')
expect(hexEncode(new Uint8Array([1, 2, 3, 4, 5]))).to.equal('0102030405')
expect(buf).eql(new Uint8Array([1, 2, 3, 4, 5]))
})
})
describe('TlBinaryReader', () => {
const map = {
'85337187': function (r) {
const ret = {}
ret._ = 'mt_resPQ'
ret.nonce = r.int128()
ret.serverNonce = r.int128()
ret.pq = r.bytes()
ret.serverPublicKeyFingerprints = r.vector(r.long)
return ret
},
}
const data =
'000000000000000001c8831ec97ae55140000000632416053e0549828cca27e966b301a48fece2fca5cf4d33f4a11ea877ba4aa5739073300817ed48941a08f98100000015c4b51c01000000216be86c022bb4c3'
it('should work with Buffers', () => {
const buf = Buffer.from(data, 'hex')
const r = new TlBinaryReader(map, buf, 8)
expect(r.long().toString(16)).to.equal('51e57ac91e83c801')
expect(r.uint()).to.equal(64)
const obj = r.object()
expect(obj._).equal('mt_resPQ')
})
it('should work with Uint8Arrays', () => {
const buf = hexDecodeToBuffer(data)
const r = new TlBinaryReader(map, buf, 8)
expect(r.long().toString(16)).to.equal('51e57ac91e83c801')
expect(r.uint()).to.equal(64)
const obj = r.object()
expect(obj._).equal('mt_resPQ')
})
})
describe('TlBinaryWriter', () => {
const map = {
mt_resPQ: function (w, obj) {
w.uint(85337187)
w.bytes(obj.pq)
w.vector(w.long, obj.serverPublicKeyFingerprints)
},
}
it('should work with Buffers', () => {
const obj = {
_: 'mt_resPQ',
pq: Buffer.from('17ED48941A08F981', 'hex'),
serverPublicKeyFingerprints: [Long.fromString('c3b42b026ce86b21', 16)],
}
expect(TlSerializationCounter.countNeededBytes(map, obj)).to.equal(32)
const w = TlBinaryWriter.alloc(map, 48)
w.long(Long.ZERO)
w.long(Long.fromString('51E57AC91E83C801', true, 16)) // messageId
w.object(obj)
expect(hexEncode(w.result())).eq(
'000000000000000001c8831ec97ae551632416050817ed48941a08f98100000015c4b51c01000000216be86c022bb4c3',
)
})
it('should work with Uint8Arrays', () => {
const obj = {
_: 'mt_resPQ',
pq: hexDecodeToBuffer('17ED48941A08F981'),
serverPublicKeyFingerprints: [Long.fromString('c3b42b026ce86b21', 16)],
}
expect(TlSerializationCounter.countNeededBytes(map, obj)).to.equal(32)
const w = TlBinaryWriter.alloc(map, 48)
w.long(Long.ZERO)
w.long(Long.fromString('51E57AC91E83C801', true, 16)) // messageId
w.object(obj)
expect(hexEncode(w.result())).eq(
'000000000000000001c8831ec97ae551632416050817ed48941a08f98100000015c4b51c01000000216be86c022bb4c3',
)
})
})
})

View file

@ -0,0 +1,39 @@
const Long = require('long')
const {
TlBinaryReader,
TlBinaryWriter,
hexEncode,
} = require('@mtcute/tl-runtime')
const { tl } = require('@mtcute/tl')
const { __tlReaderMap } = require('@mtcute/tl/binary/reader')
const { __tlWriterMap } = require('@mtcute/tl/binary/writer')
const { describe, it } = require('mocha')
const { expect } = require('chai')
// here we primarily want to check that @mtcute/tl correctly works with @mtcute/tl-runtime
describe('@mtcute/tl', () => {
it('writers map works with TlBinaryWriter', () => {
const obj = {
_: 'inputPeerUser',
userId: 123,
accessHash: Long.fromNumber(456),
}
expect(hexEncode(TlBinaryWriter.serializeObject(__tlWriterMap, obj))).to.equal('4ca5e8dd7b00000000000000c801000000000000')
})
it('readers map works with TlBinaryReader', () => {
const buf = Buffer.from('4ca5e8dd7b00000000000000c801000000000000', 'hex')
const obj = TlBinaryReader.deserializeObject(__tlReaderMap, buf)
expect(obj._).equal('inputPeerUser')
expect(obj.userId).equal(123)
expect(obj.accessHash.toString()).equal('456')
})
it('correctly checks for combinator types', () => {
expect(tl.isAnyInputUser({ _: 'inputUserEmpty' })).to.be.true
})
})

11
e2e/cjs/utils.js Normal file
View file

@ -0,0 +1,11 @@
exports.getApiParams = () => {
if (!process.env.API_ID || !process.env.API_HASH) {
throw new Error('API_ID and API_HASH env variables must be set')
}
return {
apiId: parseInt(process.env.API_ID),
apiHash: process.env.API_HASH,
testMode: true,
}
}

41
e2e/cli.sh Executable file
View file

@ -0,0 +1,41 @@
#!/bin/bash
set -eau
method=$1
shift
# rewrite using switch:
case "$method" in
"run")
node runner.js $@
;;
"run-docker")
source .env
docker compose run --rm --build test $@
;;
"update")
docker compose run --build build $@
./cli.sh install
;;
"start")
docker compose up -d verdaccio
;;
"stop")
docker compose down
;;
"install")
rm -rf pnpm-lock.yaml node_modules
pnpm install
;;
"ci")
chmod -R 777 .verdaccio
docker compose up -d verdaccio
docker compose run --rm --build build
docker compose run --rm --build test
;;
*)
echo "Unknown command"
;;
esac

23
e2e/config.js Normal file
View file

@ -0,0 +1,23 @@
module.exports = {
cjs: {
getFiles: () => 'tests/**/*.js',
runFile: (file) => `mocha ${file}`,
},
esm: {
getFiles: () => 'tests/**/*.js',
runFile: (file) => `mocha ${file}`,
},
ts: {
getFiles: () => 'tests/**/*.ts',
beforeAll: () => [
'tsc',
'node build-esm.cjs',
],
runFile: (file) => [
`mocha -r ts-node/register ${file}`,
`mocha dist/${file.replace(/\.ts$/, '.js')}`,
`node run-esm.cjs ${file}`,
`mocha dist/esm/${file.replace(/\.ts$/, '.js')}`,
],
},
}

31
e2e/docker-compose.yaml Normal file
View file

@ -0,0 +1,31 @@
version: "3"
services:
verdaccio:
restart: unless-stopped
image: verdaccio/verdaccio:5.27
container_name: "verdaccio"
volumes:
- "./.verdaccio:/verdaccio/conf"
networks:
- mtcute-e2e
build:
build:
context: ..
dockerfile: e2e/Dockerfile.build
networks:
- mtcute-e2e
depends_on:
- verdaccio
test:
build:
context: .
dockerfile: Dockerfile.test
environment:
- API_ID=${API_ID}
- API_HASH=${API_HASH}
networks:
- mtcute-e2e
depends_on:
- verdaccio
networks:
mtcute-e2e: {}

8
e2e/docker-entrypoint.sh Normal file
View file

@ -0,0 +1,8 @@
#!/bin/sh
set -e
# we can't do this during build because we don't have network access
pnpm install
node runner.js $@

1
e2e/esm/package.json Normal file
View file

@ -0,0 +1 @@
{"type":"module"}

View file

@ -0,0 +1,24 @@
import { expect } from 'chai'
import { describe, it } from 'mocha'
import { BaseTelegramClient } from '@mtcute/core'
import { getApiParams } from '../utils.js'
describe('@mtcute/core', function () {
this.timeout(60_000)
it('connects to test DC and makes help.getNearestDc', async () => {
const tg = new BaseTelegramClient({
...getApiParams(),
})
await tg.connect()
const config = await tg.call({ _: 'help.getNearestDc' })
await tg.close()
expect(config).to.be.an('object')
expect(config._).to.equal('nearestDc')
expect(config.thisDc).to.equal(2)
})
})

122
e2e/esm/tests/tl-runtime.js Normal file
View file

@ -0,0 +1,122 @@
import { expect } from 'chai'
import Long from 'long'
import { describe, it } from 'mocha'
import {
hexDecode,
hexDecodeToBuffer,
hexEncode,
TlBinaryReader,
TlBinaryWriter,
TlSerializationCounter,
} from '@mtcute/tl-runtime'
// here we primarily want to check that everything imports properly,
// and that the code is actually executable. The actual correctness
// of the implementation is covered tested by unit tests
describe('encodings', () => {
it('works with Buffers', () => {
const buf = Buffer.alloc(5)
hexDecode(buf, '0102030405')
expect(hexEncode(Buffer.from('hello'))).to.equal('68656c6c6f')
expect(buf).eql(Buffer.from([1, 2, 3, 4, 5]))
})
it('works with Uint8Arrays', () => {
const buf = new Uint8Array(5)
hexDecode(buf, '0102030405')
expect(hexEncode(new Uint8Array([1, 2, 3, 4, 5]))).to.equal('0102030405')
expect(buf).eql(new Uint8Array([1, 2, 3, 4, 5]))
})
})
describe('TlBinaryReader', () => {
const map = {
'85337187': function (r) {
const ret = {}
ret._ = 'mt_resPQ'
ret.nonce = r.int128()
ret.serverNonce = r.int128()
ret.pq = r.bytes()
ret.serverPublicKeyFingerprints = r.vector(r.long)
return ret
},
}
const data =
'000000000000000001c8831ec97ae55140000000632416053e0549828cca27e966b301a48fece2fca5cf4d33f4a11ea877ba4aa5739073300817ed48941a08f98100000015c4b51c01000000216be86c022bb4c3'
it('should work with Buffers', () => {
const buf = Buffer.from(data, 'hex')
const r = new TlBinaryReader(map, buf, 8)
expect(r.long().toString(16)).to.equal('51e57ac91e83c801')
expect(r.uint()).to.equal(64)
const obj = r.object()
expect(obj._).equal('mt_resPQ')
})
it('should work with Uint8Arrays', () => {
const buf = hexDecodeToBuffer(data)
const r = new TlBinaryReader(map, buf, 8)
expect(r.long().toString(16)).to.equal('51e57ac91e83c801')
expect(r.uint()).to.equal(64)
const obj = r.object()
expect(obj._).equal('mt_resPQ')
})
})
describe('TlBinaryWriter', () => {
const map = {
mt_resPQ: function (w, obj) {
w.uint(85337187)
w.bytes(obj.pq)
w.vector(w.long, obj.serverPublicKeyFingerprints)
},
}
it('should work with Buffers', () => {
const obj = {
_: 'mt_resPQ',
pq: Buffer.from('17ED48941A08F981', 'hex'),
serverPublicKeyFingerprints: [Long.fromString('c3b42b026ce86b21', 16)],
}
expect(TlSerializationCounter.countNeededBytes(map, obj)).to.equal(32)
const w = TlBinaryWriter.alloc(map, 48)
w.long(Long.ZERO)
w.long(Long.fromString('51E57AC91E83C801', true, 16)) // messageId
w.object(obj)
expect(hexEncode(w.result())).eq(
'000000000000000001c8831ec97ae551632416050817ed48941a08f98100000015c4b51c01000000216be86c022bb4c3',
)
})
it('should work with Uint8Arrays', () => {
const obj = {
_: 'mt_resPQ',
pq: hexDecodeToBuffer('17ED48941A08F981'),
serverPublicKeyFingerprints: [Long.fromString('c3b42b026ce86b21', 16)],
}
expect(TlSerializationCounter.countNeededBytes(map, obj)).to.equal(32)
const w = TlBinaryWriter.alloc(map, 48)
w.long(Long.ZERO)
w.long(Long.fromString('51E57AC91E83C801', true, 16)) // messageId
w.object(obj)
expect(hexEncode(w.result())).eq(
'000000000000000001c8831ec97ae551632416050817ed48941a08f98100000015c4b51c01000000216be86c022bb4c3',
)
})
})

View file

@ -0,0 +1,35 @@
import { expect } from 'chai'
import Long from 'long'
import { describe, it } from 'mocha'
import { tl } from '@mtcute/tl'
import { __tlReaderMap } from '@mtcute/tl/binary/reader.js'
import { __tlWriterMap } from '@mtcute/tl/binary/writer.js'
import { hexDecodeToBuffer, hexEncode, TlBinaryReader, TlBinaryWriter } from '@mtcute/tl-runtime'
// here we primarily want to check that @mtcute/tl correctly works with @mtcute/tl-runtime
describe('@mtcute/tl', () => {
it('writers map works with TlBinaryWriter', () => {
const obj = {
_: 'inputPeerUser',
userId: 123,
accessHash: Long.fromNumber(456),
}
expect(hexEncode(TlBinaryWriter.serializeObject(__tlWriterMap, obj))).to.equal('4ca5e8dd7b00000000000000c801000000000000')
})
it('readers map works with TlBinaryReader', () => {
const buf = hexDecodeToBuffer('4ca5e8dd7b00000000000000c801000000000000')
const obj = TlBinaryReader.deserializeObject(__tlReaderMap, buf)
expect(obj._).equal('inputPeerUser')
expect(obj.userId).equal(123)
expect(obj.accessHash.toString()).equal('456')
})
it('correctly checks for combinator types', () => {
expect(tl.isAnyInputUser({ _: 'inputUserEmpty' })).to.be.true
})
})

11
e2e/esm/utils.js Normal file
View file

@ -0,0 +1,11 @@
export const getApiParams = () => {
if (!process.env.API_ID || !process.env.API_HASH) {
throw new Error('API_ID and API_HASH env variables must be set')
}
return {
apiId: parseInt(process.env.API_ID),
apiHash: process.env.API_HASH,
testMode: true,
}
}

31
e2e/package.json Normal file
View file

@ -0,0 +1,31 @@
{
"name": "mtcute-e2e",
"private": true,
"dependencies": {
"@mtcute/client": "*",
"@mtcute/core": "*",
"@mtcute/crypto-node": "*",
"@mtcute/dispatcher": "*",
"@mtcute/file-id": "*",
"@mtcute/html-parser": "*",
"@mtcute/http-proxy": "*",
"@mtcute/i18n": "*",
"@mtcute/markdown-parser": "*",
"@mtcute/mtproxy": "*",
"@mtcute/node": "*",
"@mtcute/socks-proxy": "*",
"@mtcute/sqlite": "*",
"@mtcute/tl": "*",
"@mtcute/tl-runtime": "*",
"@mtcute/tl-utils": "*",
"@types/chai": "^4.3.8",
"@types/mocha": "^10.0.2",
"chai": "^4.3.10",
"dotenv": "16.3.1",
"glob": "10.3.10",
"long": "^5.2.3",
"mocha": "^10.2.0",
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
}
}

2
e2e/pnpm-workspace.yaml Normal file
View file

@ -0,0 +1,2 @@
packages:
- .

123
e2e/runner.js Normal file
View file

@ -0,0 +1,123 @@
/* eslint-disable no-console */
const glob = require('glob')
const cp = require('child_process')
const path = require('path')
const env = {}
require('dotenv').config({ processEnv: env })
const config = require('./config')
const DIRS = Object.keys(config)
function runForFile(dir, file, single = true) {
const { runFile, beforeAll } = config[dir]
if (!runFile) {
console.log('No runFile for %s', dir)
return
}
let cmds = runFile(file)
const options = {
env: {
...env,
...process.env,
},
cwd: path.join(__dirname, dir),
stdio: 'inherit',
}
if (!Array.isArray(cmds)) {
cmds = [cmds]
}
if (beforeAll && single) {
cmds.unshift(...beforeAll())
}
for (const c of cmds) {
console.log('%s $ %s', dir, c)
cp.execSync('pnpm exec ' + c, options)
}
}
function runForDir(dir) {
const { getFiles, beforeAll } = config[dir]
if (!getFiles) {
console.log('No getFiles for %s', dir)
return
}
const options = {
env: {
...env,
...process.env,
},
cwd: path.join(__dirname, dir),
stdio: 'inherit',
}
if (beforeAll) {
for (const c of beforeAll()) {
console.log('%s $ %s', dir, c)
cp.execSync('pnpm exec ' + c, options)
}
}
const files = glob.sync(getFiles(), { cwd: path.join(__dirname, dir) })
for (const file of files) {
runForFile(dir, file, false)
}
}
async function main() {
if (!process.argv[2]) {
console.log('Usage: node runner.js <what>')
console.log(' where <what> is one of:')
console.log(' all - run all tests')
console.log(' <dirname> - (one of %s) - run tests for that directory', DIRS.join(', '))
console.log(' <dirname> <filename> - run tests for that file')
process.exit(1)
}
const [dir, file] = process.argv.slice(2)
if (dir === 'all') {
for (const d of DIRS) {
console.log('Entering %s', d)
runForDir(d)
}
return
}
if (!DIRS.includes(dir)) {
console.log('Unknown directory %s', dir)
process.exit(1)
}
if (file) {
const files = glob.sync(config[dir].getFiles(), { cwd: path.join(__dirname, dir) })
const matchingFile = files.find((f) => f.endsWith(file))
if (!matchingFile) {
console.log("Can't find file %s", file)
process.exit(1)
}
runForFile(dir, matchingFile)
} else {
runForDir(dir)
}
}
main().catch((e) => {
console.error(e)
process.exit(1)
})

52
e2e/ts/build-esm.cjs Normal file
View file

@ -0,0 +1,52 @@
/* eslint-disable no-restricted-globals */
const fs = require('fs')
const path = require('path')
const cp = require('child_process')
const glob = require('glob')
function fixForEsm() {
const modified = {}
fs.writeFileSync(path.join(__dirname, 'package.json'), JSON.stringify({ type: 'module' }))
for (const file of glob.sync('tests/**/*.ts')) {
let content = fs.readFileSync(file, 'utf8')
if (content.includes('@fix-import')) {
modified[file] = content
content = content.replace(/(?<=@fix-import\nimport.*?')(.*?)(?='$)/gms, '$1.js')
fs.writeFileSync(file, content)
}
}
return () => {
fs.writeFileSync(path.join(__dirname, 'package.json'), JSON.stringify({ type: 'commonjs' }))
for (const file of Object.keys(modified)) {
fs.writeFileSync(file, modified[file])
}
}
}
exports.fixForEsm = fixForEsm
function main() {
const restore = fixForEsm()
let error = null
try {
cp.execSync('pnpm exec tsc --outDir dist/esm', { stdio: 'inherit' })
fs.writeFileSync(path.join(__dirname, 'dist/esm/package.json'), JSON.stringify({ type: 'module' }))
} catch (e) {
error = e
}
restore()
if (error) {
throw error
}
}
if (require.main === module) {
main()
}

3
e2e/ts/mocha.esm.json Normal file
View file

@ -0,0 +1,3 @@
{
"node-option": ["experimental-specifier-resolution=node", "loader=ts-node/esm"]
}

1
e2e/ts/package.json Normal file
View file

@ -0,0 +1 @@
{"type":"commonjs"}

26
e2e/ts/run-esm.cjs Normal file
View file

@ -0,0 +1,26 @@
/* eslint-disable no-restricted-globals */
const cp = require('child_process')
const { fixForEsm } = require('./build-esm.cjs')
const file = process.argv[2]
if (!file) {
console.error('Usage: run-esm.cjs <file>')
process.exit(1)
}
let error = null
const restore = fixForEsm()
try {
cp.execSync(`pnpm exec mocha --config=mocha.esm.json ${file}`, { stdio: 'inherit' })
} catch (e) {
error = e
}
restore()
if (error) {
throw error
}

View file

@ -0,0 +1,25 @@
import { expect } from 'chai'
import { describe, it } from 'mocha'
import { BaseTelegramClient } from '@mtcute/core'
// @fix-import
import { getApiParams } from '../utils'
describe('@mtcute/core', function () {
this.timeout(60_000)
it('connects to test DC and makes help.getNearestDc', async () => {
const tg = new BaseTelegramClient({
...getApiParams(),
})
await tg.connect()
const config = await tg.call({ _: 'help.getNearestDc' })
await tg.close()
expect(config).to.be.an('object')
expect(config._).to.equal('nearestDc')
expect(config.thisDc).to.equal(2)
})
})

124
e2e/ts/tests/tl-runtime.ts Normal file
View file

@ -0,0 +1,124 @@
/* eslint-disable */
import { expect } from 'chai'
import Long from 'long'
import { describe, it } from 'mocha'
import {
hexDecode,
hexDecodeToBuffer,
hexEncode,
TlBinaryReader,
TlBinaryWriter,
TlSerializationCounter,
} from '@mtcute/tl-runtime'
// here we primarily want to check that everything imports properly,
// and that the code is actually executable. The actual correctness
// of the implementation is covered tested by unit tests
describe('encodings', () => {
it('works with Buffers', () => {
const buf = Buffer.alloc(5)
hexDecode(buf, '0102030405')
expect(hexEncode(Buffer.from('hello'))).to.equal('68656c6c6f')
expect(buf).eql(Buffer.from([1, 2, 3, 4, 5]))
})
it('works with Uint8Arrays', () => {
const buf = new Uint8Array(5)
hexDecode(buf, '0102030405')
expect(hexEncode(new Uint8Array([1, 2, 3, 4, 5]))).to.equal('0102030405')
expect(buf).eql(new Uint8Array([1, 2, 3, 4, 5]))
})
})
describe('TlBinaryReader', () => {
const map = {
'85337187': function (r: any) {
const ret: any = {}
ret._ = 'mt_resPQ'
ret.nonce = r.int128()
ret.serverNonce = r.int128()
ret.pq = r.bytes()
ret.serverPublicKeyFingerprints = r.vector(r.long)
return ret
},
}
const data =
'000000000000000001c8831ec97ae55140000000632416053e0549828cca27e966b301a48fece2fca5cf4d33f4a11ea877ba4aa5739073300817ed48941a08f98100000015c4b51c01000000216be86c022bb4c3'
it('should work with Buffers', () => {
const buf = Buffer.from(data, 'hex')
const r = new TlBinaryReader(map, buf, 8)
expect(r.long().toString(16)).to.equal('51e57ac91e83c801')
expect(r.uint()).to.equal(64)
const obj: any = r.object()
expect(obj._).equal('mt_resPQ')
})
it('should work with Uint8Arrays', () => {
const buf = hexDecodeToBuffer(data)
const r = new TlBinaryReader(map, buf, 8)
expect(r.long().toString(16)).to.equal('51e57ac91e83c801')
expect(r.uint()).to.equal(64)
const obj: any = r.object()
expect(obj._).equal('mt_resPQ')
})
})
describe('TlBinaryWriter', () => {
const map = {
mt_resPQ: function (w: any, obj: any) {
w.uint(85337187)
w.bytes(obj.pq)
w.vector(w.long, obj.serverPublicKeyFingerprints)
},
_staticSize: {} as any
}
it('should work with Buffers', () => {
const obj = {
_: 'mt_resPQ',
pq: Buffer.from('17ED48941A08F981', 'hex'),
serverPublicKeyFingerprints: [Long.fromString('c3b42b026ce86b21', 16)],
}
expect(TlSerializationCounter.countNeededBytes(map, obj)).to.equal(32)
const w = TlBinaryWriter.alloc(map, 48)
w.long(Long.ZERO)
w.long(Long.fromString('51E57AC91E83C801', true, 16)) // messageId
w.object(obj)
expect(hexEncode(w.result())).eq(
'000000000000000001c8831ec97ae551632416050817ed48941a08f98100000015c4b51c01000000216be86c022bb4c3',
)
})
it('should work with Uint8Arrays', () => {
const obj = {
_: 'mt_resPQ',
pq: hexDecodeToBuffer('17ED48941A08F981'),
serverPublicKeyFingerprints: [Long.fromString('c3b42b026ce86b21', 16)],
}
expect(TlSerializationCounter.countNeededBytes(map, obj)).to.equal(32)
const w = TlBinaryWriter.alloc(map, 48)
w.long(Long.ZERO)
w.long(Long.fromString('51E57AC91E83C801', true, 16)) // messageId
w.object(obj)
expect(hexEncode(w.result())).eq(
'000000000000000001c8831ec97ae551632416050817ed48941a08f98100000015c4b51c01000000216be86c022bb4c3',
)
})
})

39
e2e/ts/tests/tl-schema.ts Normal file
View file

@ -0,0 +1,39 @@
import { expect } from 'chai'
import Long from 'long'
import { describe, it } from 'mocha'
import { tl } from '@mtcute/tl'
import { __tlReaderMap } from '@mtcute/tl/binary/reader.js'
import { __tlWriterMap } from '@mtcute/tl/binary/writer.js'
import { hexDecodeToBuffer, hexEncode, TlBinaryReader, TlBinaryWriter } from '@mtcute/tl-runtime'
// here we primarily want to check that @mtcute/tl correctly works with @mtcute/tl-runtime
describe('@mtcute/tl', () => {
it('writers map works with TlBinaryWriter', () => {
const obj = {
_: 'inputPeerUser',
userId: 123,
accessHash: Long.fromNumber(456),
}
expect(hexEncode(TlBinaryWriter.serializeObject(__tlWriterMap, obj))).to.equal(
'4ca5e8dd7b00000000000000c801000000000000',
)
})
it('readers map works with TlBinaryReader', () => {
const buf = hexDecodeToBuffer('4ca5e8dd7b00000000000000c801000000000000')
// eslint-disable-next-line
const obj = TlBinaryReader.deserializeObject<any>(__tlReaderMap, buf)
expect(obj._).equal('inputPeerUser')
expect(obj.userId).equal(123)
// eslint-disable-next-line
expect(obj.accessHash.toString()).equal('456')
})
it('correctly checks for combinator types', () => {
expect(tl.isAnyInputUser({ _: 'inputUserEmpty' })).to.be.true
})
})

28
e2e/ts/tsconfig.json Normal file
View file

@ -0,0 +1,28 @@
{
"compilerOptions": {
"outDir": "./dist",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"target": "es2020",
"allowJs": true,
"sourceMap": true,
"inlineSources": true,
"declaration": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"noImplicitAny": true,
"noImplicitThis": true,
"incremental": true,
"stripInternal": true,
"skipLibCheck": true,
"rootDir": "."
},
"exclude": [
"**/node_modules",
],
"include": [
"./tests",
"./utils.ts"
]
}

13
e2e/ts/utils.ts Normal file
View file

@ -0,0 +1,13 @@
import type { BaseTelegramClientOptions } from '@mtcute/core'
export const getApiParams = (): BaseTelegramClientOptions => {
if (!process.env.API_ID || !process.env.API_HASH) {
throw new Error('API_ID and API_HASH env variables must be set')
}
return {
apiId: parseInt(process.env.API_ID),
apiHash: process.env.API_HASH,
testMode: true,
}
}

View file

@ -8,15 +8,18 @@
"scripts": { "scripts": {
"prepare": "husky install", "prepare": "husky install",
"postinstall": "node scripts/validate-deps-versions.mjs", "postinstall": "node scripts/validate-deps-versions.mjs",
"test:all": "pnpm run -r test", "test:all": "pnpm run -r --parallel test",
"test:all:ci": "pnpm run -r test",
"lint": "eslint .", "lint": "eslint .",
"lint:ci": "eslint --config .eslintrc.ci.js .", "lint:ci": "NODE_OPTIONS=\"--max_old_space_size=8192\" eslint --config .eslintrc.ci.js .",
"lint:tsc": "pnpm run -r build --noEmit", "lint:tsc": "pnpm -r --filter=!crypto --parallel exec tsc --build",
"lint:tsc:ci": "pnpm -r --filter=!crypto exec tsc --build",
"lint:dpdm": "dpdm -T --no-warning --no-tree --exit-code circular:1 packages/*", "lint:dpdm": "dpdm -T --no-warning --no-tree --exit-code circular:1 packages/*",
"lint:fix": "eslint --fix .", "lint:fix": "eslint --fix .",
"format": "prettier --write \"packages/**/*.ts\"", "format": "prettier --write \"packages/**/*.ts\"",
"publish-all": "node scripts/publish.js all", "publish-all": "node scripts/publish.js all",
"docs": "pnpm run -r docs" "docs": "pnpm run -r docs",
"build-package": "node scripts/build-package.js"
}, },
"dependencies": { "dependencies": {
"node-gyp": "9.3.1" "node-gyp": "9.3.1"
@ -25,6 +28,7 @@
"@commitlint/cli": "^17.6.5", "@commitlint/cli": "^17.6.5",
"@commitlint/config-conventional": "^17.6.5", "@commitlint/config-conventional": "^17.6.5",
"@types/chai": "4.3.5", "@types/chai": "4.3.5",
"@types/chai-spies": "^1.0.4",
"@types/mocha": "10.0.1", "@types/mocha": "10.0.1",
"@types/node": "18.16.0", "@types/node": "18.16.0",
"@types/node-forge": "1.3.2", "@types/node-forge": "1.3.2",
@ -32,6 +36,7 @@
"@typescript-eslint/eslint-plugin": "6.4.0", "@typescript-eslint/eslint-plugin": "6.4.0",
"@typescript-eslint/parser": "6.4.0", "@typescript-eslint/parser": "6.4.0",
"chai": "4.3.7", "chai": "4.3.7",
"chai-spies": "^1.0.0",
"dotenv-flow": "3.2.0", "dotenv-flow": "3.2.0",
"dpdm": "^3.14.0", "dpdm": "^3.14.0",
"eslint": "8.47.0", "eslint": "8.47.0",

View file

@ -6,13 +6,29 @@
"author": "Alina Sireneva <alina@tei.su>", "author": "Alina Sireneva <alina@tei.su>",
"license": "MIT", "license": "MIT",
"main": "src/index.ts", "main": "src/index.ts",
"module": "_esm/index.js", "type": "module",
"scripts": { "scripts": {
"test": "mocha -r ts-node/register \"tests/**/*.spec.ts\"", "test": "mocha \"tests/**/*.spec.ts\"",
"docs": "typedoc", "docs": "typedoc",
"build": "tsc", "build": "pnpm run -w build-package client",
"gen-client": "node ./scripts/generate-client.js", "gen-client": "node ./scripts/generate-client.cjs",
"gen-updates": "node ./scripts/generate-updates.js" "gen-updates": "node ./scripts/generate-updates.cjs"
},
"distOnlyFields": {
"exports": {
".": {
"import": "./esm/index.js",
"require": "./cjs/index.js"
},
"./methods/*.js": {
"import": "./esm/methods/*.js",
"require": "./cjs/methods/*.js"
},
"./utils.js": {
"import": "./esm/utils/index.js",
"require": "./cjs/utils/index.js"
}
}
}, },
"dependencies": { "dependencies": {
"@types/node": "18.16.0", "@types/node": "18.16.0",

View file

@ -1,8 +1,9 @@
/* eslint-disable no-restricted-globals */
const ts = require('typescript') const ts = require('typescript')
const path = require('path') const path = require('path')
const fs = require('fs') const fs = require('fs')
const prettier = require('prettier') const prettier = require('prettier')
const updates = require('./generate-updates') const updates = require('./generate-updates.cjs')
const schema = require('../../tl/api-schema.json') const schema = require('../../tl/api-schema.json')
@ -189,7 +190,7 @@ async function addSingleMethod(state, fileName) {
const fileFullText = await fs.promises.readFile(fileName, 'utf-8') const fileFullText = await fs.promises.readFile(fileName, 'utf-8')
const program = ts.createSourceFile(path.basename(fileName), fileFullText, ts.ScriptTarget.ES2018, true) const program = ts.createSourceFile(path.basename(fileName), fileFullText, ts.ScriptTarget.ES2018, true)
const relPath = path.relative(targetDir, fileName).replace(/\\/g, '/') // replace path delim to unix const relPath = path.relative(targetDir, fileName).replace(/\\/g, '/') // replace path delim to unix
const module = `./${relPath.replace(/\.ts$/, '')}` const module = `./${relPath.replace(/\.ts$/, '.js')}`
state.files[relPath] = fileFullText state.files[relPath] = fileFullText
@ -319,7 +320,7 @@ async function addSingleMethod(state, fileName) {
const isPrivate = checkForFlag(stmt, '@internal') const isPrivate = checkForFlag(stmt, '@internal')
const isManual = checkForFlag(stmt, '@manual') const isManual = checkForFlag(stmt, '@manual')
const isNoemit = checkForFlag(stmt, '@noemit') const isNoemit = checkForFlag(stmt, '@noemit')
const shouldEmit = !isNoemit && !(isPrivate && !isOverload && !hasOverloads) const shouldEmit = !isNoemit && !(isPrivate && !isOverload && !Object.keys(hasOverloads).length)
if (shouldEmit) { if (shouldEmit) {
state.methods.list.push({ state.methods.list.push({
@ -432,6 +433,7 @@ async function main() {
) )
Object.entries(state.imports).forEach(([module, items]) => { Object.entries(state.imports).forEach(([module, items]) => {
items = [...items] items = [...items]
if (!items.length) return
output.write(`import { ${items.sort().join(', ')} } from '${module}'\n`) output.write(`import { ${items.sort().join(', ')} } from '${module}'\n`)
}) })

View file

@ -1,3 +1,4 @@
/* eslint-disable no-restricted-globals */
const fs = require('fs') const fs = require('fs')
const path = require('path') const path = require('path')
const prettier = require('prettier') const prettier = require('prettier')

View file

@ -2,224 +2,208 @@
/* THIS FILE WAS AUTO-GENERATED */ /* THIS FILE WAS AUTO-GENERATED */
import { Readable } from 'stream' import { Readable } from 'stream'
import { import { BaseTelegramClient, BaseTelegramClientOptions, Long, MaybeArray, MaybeAsync, PartialExcept, PartialOnly, tl } from '@mtcute/core'
BaseTelegramClient,
BaseTelegramClientOptions,
Long,
MaybeArray,
MaybeAsync,
PartialExcept,
PartialOnly,
tl,
} from '@mtcute/core'
import { tdFileId } from '@mtcute/file-id' import { tdFileId } from '@mtcute/file-id'
import { _onAuthorization, AuthState, getAuthState } from './methods/auth/_state' import { AuthState, getAuthState } from './methods/auth/_state.js'
import { checkPassword } from './methods/auth/check-password' import { checkPassword } from './methods/auth/check-password.js'
import { getPasswordHint } from './methods/auth/get-password-hint' import { getPasswordHint } from './methods/auth/get-password-hint.js'
import { logOut } from './methods/auth/log-out' import { logOut } from './methods/auth/log-out.js'
import { recoverPassword } from './methods/auth/recover-password' import { recoverPassword } from './methods/auth/recover-password.js'
import { resendCode } from './methods/auth/resend-code' import { resendCode } from './methods/auth/resend-code.js'
import {} from './methods/auth/run' import { sendCode } from './methods/auth/send-code.js'
import { sendCode } from './methods/auth/send-code' import { sendRecoveryCode } from './methods/auth/send-recovery-code.js'
import { sendRecoveryCode } from './methods/auth/send-recovery-code' import { signIn } from './methods/auth/sign-in.js'
import { signIn } from './methods/auth/sign-in' import { signInBot } from './methods/auth/sign-in-bot.js'
import { signInBot } from './methods/auth/sign-in-bot' import { start } from './methods/auth/start.js'
import { start } from './methods/auth/start' import { startTest } from './methods/auth/start-test.js'
import { startTest } from './methods/auth/start-test' import { answerCallbackQuery } from './methods/bots/answer-callback-query.js'
import { answerCallbackQuery } from './methods/bots/answer-callback-query' import { answerInlineQuery } from './methods/bots/answer-inline-query.js'
import { answerInlineQuery } from './methods/bots/answer-inline-query' import { answerPreCheckoutQuery } from './methods/bots/answer-pre-checkout-query.js'
import { answerPreCheckoutQuery } from './methods/bots/answer-pre-checkout-query' import { deleteMyCommands } from './methods/bots/delete-my-commands.js'
import { deleteMyCommands } from './methods/bots/delete-my-commands' import { getBotInfo } from './methods/bots/get-bot-info.js'
import { getBotInfo } from './methods/bots/get-bot-info' import { getBotMenuButton } from './methods/bots/get-bot-menu-button.js'
import { getBotMenuButton } from './methods/bots/get-bot-menu-button' import { getCallbackAnswer } from './methods/bots/get-callback-answer.js'
import { getCallbackAnswer } from './methods/bots/get-callback-answer' import { getGameHighScores, getInlineGameHighScores } from './methods/bots/get-game-high-scores.js'
import { getGameHighScores, getInlineGameHighScores } from './methods/bots/get-game-high-scores' import { getMyCommands } from './methods/bots/get-my-commands.js'
import { getMyCommands } from './methods/bots/get-my-commands' import { setBotInfo } from './methods/bots/set-bot-info.js'
import { _normalizeCommandScope } from './methods/bots/normalize-command-scope' import { setBotMenuButton } from './methods/bots/set-bot-menu-button.js'
import { setBotInfo } from './methods/bots/set-bot-info' import { setGameScore, setInlineGameScore } from './methods/bots/set-game-score.js'
import { setBotMenuButton } from './methods/bots/set-bot-menu-button' import { setMyCommands } from './methods/bots/set-my-commands.js'
import { setGameScore, setInlineGameScore } from './methods/bots/set-game-score' import { setMyDefaultRights } from './methods/bots/set-my-default-rights.js'
import { setMyCommands } from './methods/bots/set-my-commands' import { addChatMembers } from './methods/chats/add-chat-members.js'
import { setMyDefaultRights } from './methods/bots/set-my-default-rights' import { archiveChats } from './methods/chats/archive-chats.js'
import { addChatMembers } from './methods/chats/add-chat-members' import { banChatMember } from './methods/chats/ban-chat-member.js'
import { archiveChats } from './methods/chats/archive-chats' import { createChannel } from './methods/chats/create-channel.js'
import { banChatMember } from './methods/chats/ban-chat-member' import { createGroup } from './methods/chats/create-group.js'
import { createChannel } from './methods/chats/create-channel' import { createSupergroup } from './methods/chats/create-supergroup.js'
import { createGroup } from './methods/chats/create-group' import { deleteChannel } from './methods/chats/delete-channel.js'
import { createSupergroup } from './methods/chats/create-supergroup' import { deleteChatPhoto } from './methods/chats/delete-chat-photo.js'
import { deleteChannel } from './methods/chats/delete-channel' import { deleteGroup } from './methods/chats/delete-group.js'
import { deleteChatPhoto } from './methods/chats/delete-chat-photo' import { deleteHistory } from './methods/chats/delete-history.js'
import { deleteGroup } from './methods/chats/delete-group' import { deleteUserHistory } from './methods/chats/delete-user-history.js'
import { deleteHistory } from './methods/chats/delete-history' import { editAdminRights } from './methods/chats/edit-admin-rights.js'
import { deleteUserHistory } from './methods/chats/delete-user-history' import { getChat } from './methods/chats/get-chat.js'
import { editAdminRights } from './methods/chats/edit-admin-rights' import { getChatEventLog } from './methods/chats/get-chat-event-log.js'
import { getChat } from './methods/chats/get-chat' import { getChatMember } from './methods/chats/get-chat-member.js'
import { getChatEventLog } from './methods/chats/get-chat-event-log' import { getChatMembers } from './methods/chats/get-chat-members.js'
import { getChatMember } from './methods/chats/get-chat-member' import { getChatPreview } from './methods/chats/get-chat-preview.js'
import { getChatMembers } from './methods/chats/get-chat-members' import { getFullChat } from './methods/chats/get-full-chat.js'
import { getChatPreview } from './methods/chats/get-chat-preview' import { getNearbyChats } from './methods/chats/get-nearby-chats.js'
import { getFullChat } from './methods/chats/get-full-chat' import { iterChatEventLog } from './methods/chats/iter-chat-event-log.js'
import { getNearbyChats } from './methods/chats/get-nearby-chats' import { iterChatMembers } from './methods/chats/iter-chat-members.js'
import { iterChatEventLog } from './methods/chats/iter-chat-event-log' import { joinChat } from './methods/chats/join-chat.js'
import { iterChatMembers } from './methods/chats/iter-chat-members' import { kickChatMember } from './methods/chats/kick-chat-member.js'
import { joinChat } from './methods/chats/join-chat' import { leaveChat } from './methods/chats/leave-chat.js'
import { kickChatMember } from './methods/chats/kick-chat-member' import { markChatUnread } from './methods/chats/mark-chat-unread.js'
import { leaveChat } from './methods/chats/leave-chat' import { reorderUsernames } from './methods/chats/reorder-usernames.js'
import { markChatUnread } from './methods/chats/mark-chat-unread' import { restrictChatMember } from './methods/chats/restrict-chat-member.js'
import { reorderUsernames } from './methods/chats/reorder-usernames' import { saveDraft } from './methods/chats/save-draft.js'
import { restrictChatMember } from './methods/chats/restrict-chat-member' import { setChatDefaultPermissions } from './methods/chats/set-chat-default-permissions.js'
import { saveDraft } from './methods/chats/save-draft' import { setChatDescription } from './methods/chats/set-chat-description.js'
import { setChatDefaultPermissions } from './methods/chats/set-chat-default-permissions' import { setChatPhoto } from './methods/chats/set-chat-photo.js'
import { setChatDescription } from './methods/chats/set-chat-description' import { setChatTitle } from './methods/chats/set-chat-title.js'
import { setChatPhoto } from './methods/chats/set-chat-photo' import { setChatTtl } from './methods/chats/set-chat-ttl.js'
import { setChatTitle } from './methods/chats/set-chat-title' import { setChatUsername } from './methods/chats/set-chat-username.js'
import { setChatTtl } from './methods/chats/set-chat-ttl' import { setSlowMode } from './methods/chats/set-slow-mode.js'
import { setChatUsername } from './methods/chats/set-chat-username' import { toggleContentProtection } from './methods/chats/toggle-content-protection.js'
import { setSlowMode } from './methods/chats/set-slow-mode' import { toggleFragmentUsername } from './methods/chats/toggle-fragment-username.js'
import { toggleContentProtection } from './methods/chats/toggle-content-protection' import { toggleJoinRequests } from './methods/chats/toggle-join-requests.js'
import { toggleFragmentUsername } from './methods/chats/toggle-fragment-username' import { toggleJoinToSend } from './methods/chats/toggle-join-to-send.js'
import { toggleJoinRequests } from './methods/chats/toggle-join-requests' import { unarchiveChats } from './methods/chats/unarchive-chats.js'
import { toggleJoinToSend } from './methods/chats/toggle-join-to-send' import { unbanChatMember } from './methods/chats/unban-chat-member.js'
import { unarchiveChats } from './methods/chats/unarchive-chats' import { addContact } from './methods/contacts/add-contact.js'
import { unbanChatMember } from './methods/chats/unban-chat-member' import { deleteContacts } from './methods/contacts/delete-contacts.js'
import { addContact } from './methods/contacts/add-contact' import { getContacts } from './methods/contacts/get-contacts.js'
import { deleteContacts } from './methods/contacts/delete-contacts' import { importContacts } from './methods/contacts/import-contacts.js'
import { getContacts } from './methods/contacts/get-contacts' import { createFolder } from './methods/dialogs/create-folder.js'
import { importContacts } from './methods/contacts/import-contacts' import { deleteFolder } from './methods/dialogs/delete-folder.js'
import { createFolder } from './methods/dialogs/create-folder' import { editFolder } from './methods/dialogs/edit-folder.js'
import { deleteFolder } from './methods/dialogs/delete-folder' import { findFolder } from './methods/dialogs/find-folder.js'
import { editFolder } from './methods/dialogs/edit-folder' import { getFolders } from './methods/dialogs/get-folders.js'
import { findFolder } from './methods/dialogs/find-folder' import { getPeerDialogs } from './methods/dialogs/get-peer-dialogs.js'
import { _normalizeInputFolder, getFolders } from './methods/dialogs/get-folders' import { iterDialogs } from './methods/dialogs/iter-dialogs.js'
import { getPeerDialogs } from './methods/dialogs/get-peer-dialogs' import { setFoldersOrder } from './methods/dialogs/set-folders-order.js'
import { iterDialogs } from './methods/dialogs/iter-dialogs' import { downloadAsBuffer } from './methods/files/download-buffer.js'
import { setFoldersOrder } from './methods/dialogs/set-folders-order' import { downloadToFile } from './methods/files/download-file.js'
import { downloadAsBuffer } from './methods/files/download-buffer' import { downloadAsIterable } from './methods/files/download-iterable.js'
import { downloadToFile } from './methods/files/download-file' import { downloadAsStream } from './methods/files/download-stream.js'
import { downloadAsIterable } from './methods/files/download-iterable' import { _normalizeInputFile } from './methods/files/normalize-input-file.js'
import { downloadAsStream } from './methods/files/download-stream' import { _normalizeInputMedia } from './methods/files/normalize-input-media.js'
import { _normalizeFileToDocument } from './methods/files/normalize-file-to-document' import { uploadFile } from './methods/files/upload-file.js'
import { _normalizeInputFile } from './methods/files/normalize-input-file' import { uploadMedia } from './methods/files/upload-media.js'
import { _normalizeInputMedia } from './methods/files/normalize-input-media' import { createForumTopic } from './methods/forums/create-forum-topic.js'
import { uploadFile } from './methods/files/upload-file' import { deleteForumTopicHistory } from './methods/forums/delete-forum-topic-history.js'
import { uploadMedia } from './methods/files/upload-media' import { editForumTopic } from './methods/forums/edit-forum-topic.js'
import { createForumTopic } from './methods/forums/create-forum-topic' import { getForumTopics, GetForumTopicsOffset } from './methods/forums/get-forum-topics.js'
import { deleteForumTopicHistory } from './methods/forums/delete-forum-topic-history' import { getForumTopicsById } from './methods/forums/get-forum-topics-by-id.js'
import { editForumTopic } from './methods/forums/edit-forum-topic' import { iterForumTopics } from './methods/forums/iter-forum-topics.js'
import { getForumTopics, GetForumTopicsOffset } from './methods/forums/get-forum-topics' import { reorderPinnedForumTopics } from './methods/forums/reorder-pinned-forum-topics.js'
import { getForumTopicsById } from './methods/forums/get-forum-topics-by-id' import { toggleForum } from './methods/forums/toggle-forum.js'
import { iterForumTopics } from './methods/forums/iter-forum-topics' import { toggleForumTopicClosed } from './methods/forums/toggle-forum-topic-closed.js'
import { reorderPinnedForumTopics } from './methods/forums/reorder-pinned-forum-topics' import { toggleForumTopicPinned } from './methods/forums/toggle-forum-topic-pinned.js'
import { toggleForum } from './methods/forums/toggle-forum' import { toggleGeneralTopicHidden } from './methods/forums/toggle-general-topic-hidden.js'
import { toggleForumTopicClosed } from './methods/forums/toggle-forum-topic-closed' import { createInviteLink } from './methods/invite-links/create-invite-link.js'
import { toggleForumTopicPinned } from './methods/forums/toggle-forum-topic-pinned' import { editInviteLink } from './methods/invite-links/edit-invite-link.js'
import { toggleGeneralTopicHidden } from './methods/forums/toggle-general-topic-hidden' import { exportInviteLink } from './methods/invite-links/export-invite-link.js'
import { createInviteLink } from './methods/invite-links/create-invite-link' import { getInviteLink } from './methods/invite-links/get-invite-link.js'
import { editInviteLink } from './methods/invite-links/edit-invite-link' import { getInviteLinkMembers } from './methods/invite-links/get-invite-link-members.js'
import { exportInviteLink } from './methods/invite-links/export-invite-link' import { getInviteLinks, GetInviteLinksOffset } from './methods/invite-links/get-invite-links.js'
import { getInviteLink } from './methods/invite-links/get-invite-link' import { getPrimaryInviteLink } from './methods/invite-links/get-primary-invite-link.js'
import { getInviteLinkMembers } from './methods/invite-links/get-invite-link-members' import { hideAllJoinRequests } from './methods/invite-links/hide-all-join-requests.js'
import { getInviteLinks, GetInviteLinksOffset } from './methods/invite-links/get-invite-links' import { hideJoinRequest } from './methods/invite-links/hide-join-request.js'
import { getPrimaryInviteLink } from './methods/invite-links/get-primary-invite-link' import { iterInviteLinkMembers } from './methods/invite-links/iter-invite-link-members.js'
import { hideAllJoinRequests } from './methods/invite-links/hide-all-join-requests' import { iterInviteLinks } from './methods/invite-links/iter-invite-links.js'
import { hideJoinRequest } from './methods/invite-links/hide-join-request' import { revokeInviteLink } from './methods/invite-links/revoke-invite-link.js'
import { iterInviteLinkMembers } from './methods/invite-links/iter-invite-link-members' import { closePoll } from './methods/messages/close-poll.js'
import { iterInviteLinks } from './methods/invite-links/iter-invite-links' import { deleteMessages, deleteMessagesById, DeleteMessagesParams } from './methods/messages/delete-messages.js'
import { revokeInviteLink } from './methods/invite-links/revoke-invite-link' import { deleteScheduledMessages } from './methods/messages/delete-scheduled-messages.js'
import { closePoll } from './methods/messages/close-poll' import { editInlineMessage } from './methods/messages/edit-inline-message.js'
import { deleteMessages, deleteMessagesById, DeleteMessagesParams } from './methods/messages/delete-messages' import { editMessage } from './methods/messages/edit-message.js'
import { deleteScheduledMessages } from './methods/messages/delete-scheduled-messages' import { ForwardMessageOptions, forwardMessages, forwardMessagesById } from './methods/messages/forward-messages.js'
import { editInlineMessage } from './methods/messages/edit-inline-message' import { getDiscussionMessage } from './methods/messages/get-discussion-message.js'
import { editMessage } from './methods/messages/edit-message' import { getHistory, GetHistoryOffset } from './methods/messages/get-history.js'
import { _findMessageInUpdate } from './methods/messages/find-in-update' import { getMessageGroup } from './methods/messages/get-message-group.js'
import { ForwardMessageOptions, forwardMessages, forwardMessagesById } from './methods/messages/forward-messages' import { getMessageReactions, getMessageReactionsById } from './methods/messages/get-message-reactions.js'
import { _getDiscussionMessage, getDiscussionMessage } from './methods/messages/get-discussion-message' import { getMessages } from './methods/messages/get-messages.js'
import { getHistory, GetHistoryOffset } from './methods/messages/get-history' import { getMessagesUnsafe } from './methods/messages/get-messages-unsafe.js'
import { getMessageGroup } from './methods/messages/get-message-group' import { getReactionUsers, GetReactionUsersOffset } from './methods/messages/get-reaction-users.js'
import { getMessageReactions, getMessageReactionsById } from './methods/messages/get-message-reactions' import { getReplyTo } from './methods/messages/get-reply-to.js'
import { getMessages } from './methods/messages/get-messages' import { getScheduledMessages } from './methods/messages/get-scheduled-messages.js'
import { getMessagesUnsafe } from './methods/messages/get-messages-unsafe' import { iterHistory } from './methods/messages/iter-history.js'
import { getReactionUsers, GetReactionUsersOffset } from './methods/messages/get-reaction-users' import { iterReactionUsers } from './methods/messages/iter-reaction-users.js'
import { getReplyTo } from './methods/messages/get-reply-to' import { iterSearchGlobal } from './methods/messages/iter-search-global.js'
import { getScheduledMessages } from './methods/messages/get-scheduled-messages' import { iterSearchMessages } from './methods/messages/iter-search-messages.js'
import { iterHistory } from './methods/messages/iter-history' import { pinMessage } from './methods/messages/pin-message.js'
import { iterReactionUsers } from './methods/messages/iter-reaction-users' import { readHistory } from './methods/messages/read-history.js'
import { iterSearchGlobal } from './methods/messages/iter-search-global' import { readReactions } from './methods/messages/read-reactions.js'
import { iterSearchMessages } from './methods/messages/iter-search-messages' import { searchGlobal, SearchGlobalOffset } from './methods/messages/search-global.js'
import { _parseEntities } from './methods/messages/parse-entities' import { searchMessages, SearchMessagesOffset } from './methods/messages/search-messages.js'
import { pinMessage } from './methods/messages/pin-message' import { answerMedia, answerMediaGroup, answerText } from './methods/messages/send-answer.js'
import { readHistory } from './methods/messages/read-history' import { commentMedia, commentMediaGroup, commentText } from './methods/messages/send-comment.js'
import { readReactions } from './methods/messages/read-reactions' import { CommonSendParams } from './methods/messages/send-common.js'
import { searchGlobal, SearchGlobalOffset } from './methods/messages/search-global' import { sendCopy, SendCopyParams } from './methods/messages/send-copy.js'
import { searchMessages, SearchMessagesOffset } from './methods/messages/search-messages' import { sendCopyGroup, SendCopyGroupParams } from './methods/messages/send-copy-group.js'
import { answerMedia, answerMediaGroup, answerText } from './methods/messages/send-answer' import { sendMedia } from './methods/messages/send-media.js'
import { commentMedia, commentMediaGroup, commentText } from './methods/messages/send-comment' import { sendMediaGroup } from './methods/messages/send-media-group.js'
import { CommonSendParams } from './methods/messages/send-common' import { sendReaction } from './methods/messages/send-reaction.js'
import { sendCopy, SendCopyParams } from './methods/messages/send-copy' import { replyMedia, replyMediaGroup, replyText } from './methods/messages/send-reply.js'
import { sendCopyGroup, SendCopyGroupParams } from './methods/messages/send-copy-group' import { sendScheduled } from './methods/messages/send-scheduled.js'
import { sendMedia } from './methods/messages/send-media' import { sendText } from './methods/messages/send-text.js'
import { sendMediaGroup } from './methods/messages/send-media-group' import { sendTyping } from './methods/messages/send-typing.js'
import { sendReaction } from './methods/messages/send-reaction' import { sendVote } from './methods/messages/send-vote.js'
import { replyMedia, replyMediaGroup, replyText } from './methods/messages/send-reply' import { translateMessage } from './methods/messages/translate-message.js'
import { sendScheduled } from './methods/messages/send-scheduled' import { translateText } from './methods/messages/translate-text.js'
import { sendText } from './methods/messages/send-text' import { unpinAllMessages } from './methods/messages/unpin-all-messages.js'
import { sendTyping } from './methods/messages/send-typing' import { unpinMessage } from './methods/messages/unpin-message.js'
import { sendVote } from './methods/messages/send-vote' import { initTakeoutSession } from './methods/misc/init-takeout-session.js'
import { translateMessage } from './methods/messages/translate-message' import { _normalizePrivacyRules } from './methods/misc/normalize-privacy-rules.js'
import { translateText } from './methods/messages/translate-text'
import { unpinAllMessages } from './methods/messages/unpin-all-messages'
import { unpinMessage } from './methods/messages/unpin-message'
import { initTakeoutSession } from './methods/misc/init-takeout-session'
import { _normalizePrivacyRules } from './methods/misc/normalize-privacy-rules'
import { getParseModesState, ParseModesState } from './methods/parse-modes/_state'
import { import {
getParseMode, getParseMode,
registerParseMode, registerParseMode,
setDefaultParseMode, setDefaultParseMode,
unregisterParseMode, unregisterParseMode,
} from './methods/parse-modes/parse-modes' } from './methods/parse-modes/parse-modes.js'
import { changeCloudPassword } from './methods/password/change-cloud-password' import { changeCloudPassword } from './methods/password/change-cloud-password.js'
import { enableCloudPassword } from './methods/password/enable-cloud-password' import { enableCloudPassword } from './methods/password/enable-cloud-password.js'
import { cancelPasswordEmail, resendPasswordEmail, verifyPasswordEmail } from './methods/password/password-email' import { cancelPasswordEmail, resendPasswordEmail, verifyPasswordEmail } from './methods/password/password-email.js'
import { removeCloudPassword } from './methods/password/remove-cloud-password' import { removeCloudPassword } from './methods/password/remove-cloud-password.js'
import { addStickerToSet } from './methods/stickers/add-sticker-to-set' import { addStickerToSet } from './methods/stickers/add-sticker-to-set.js'
import { createStickerSet } from './methods/stickers/create-sticker-set' import { createStickerSet } from './methods/stickers/create-sticker-set.js'
import { deleteStickerFromSet } from './methods/stickers/delete-sticker-from-set' import { deleteStickerFromSet } from './methods/stickers/delete-sticker-from-set.js'
import { getCustomEmojis, getCustomEmojisFromMessages } from './methods/stickers/get-custom-emojis' import { getCustomEmojis, getCustomEmojisFromMessages } from './methods/stickers/get-custom-emojis.js'
import { getInstalledStickers } from './methods/stickers/get-installed-stickers' import { getInstalledStickers } from './methods/stickers/get-installed-stickers.js'
import { getStickerSet } from './methods/stickers/get-sticker-set' import { getStickerSet } from './methods/stickers/get-sticker-set.js'
import { moveStickerInSet } from './methods/stickers/move-sticker-in-set' import { moveStickerInSet } from './methods/stickers/move-sticker-in-set.js'
import { setChatStickerSet } from './methods/stickers/set-chat-sticker-set' import { setChatStickerSet } from './methods/stickers/set-chat-sticker-set.js'
import { setStickerSetThumb } from './methods/stickers/set-sticker-set-thumb' import { setStickerSetThumb } from './methods/stickers/set-sticker-set-thumb.js'
import { applyBoost } from './methods/stories/apply-boost' import { applyBoost } from './methods/stories/apply-boost.js'
import { canApplyBoost, CanApplyBoostResult } from './methods/stories/can-apply-boost' import { canApplyBoost, CanApplyBoostResult } from './methods/stories/can-apply-boost.js'
import { canSendStory, CanSendStoryResult } from './methods/stories/can-send-story' import { canSendStory, CanSendStoryResult } from './methods/stories/can-send-story.js'
import { deleteStories } from './methods/stories/delete-stories' import { deleteStories } from './methods/stories/delete-stories.js'
import { editStory } from './methods/stories/edit-story' import { editStory } from './methods/stories/edit-story.js'
import { _findStoryInUpdate } from './methods/stories/find-in-update' import { getAllStories } from './methods/stories/get-all-stories.js'
import { getAllStories } from './methods/stories/get-all-stories' import { getBoostStats } from './methods/stories/get-boost-stats.js'
import { getBoostStats } from './methods/stories/get-boost-stats' import { getBoosters } from './methods/stories/get-boosters.js'
import { getBoosters } from './methods/stories/get-boosters' import { getPeerStories } from './methods/stories/get-peer-stories.js'
import { getPeerStories } from './methods/stories/get-peer-stories' import { getProfileStories } from './methods/stories/get-profile-stories.js'
import { getProfileStories } from './methods/stories/get-profile-stories' import { getStoriesById } from './methods/stories/get-stories-by-id.js'
import { getStoriesById } from './methods/stories/get-stories-by-id' import { getStoriesInteractions } from './methods/stories/get-stories-interactions.js'
import { getStoriesInteractions } from './methods/stories/get-stories-interactions' import { getStoryLink } from './methods/stories/get-story-link.js'
import { getStoryLink } from './methods/stories/get-story-link' import { getStoryViewers } from './methods/stories/get-story-viewers.js'
import { getStoryViewers } from './methods/stories/get-story-viewers' import { hideMyStoriesViews } from './methods/stories/hide-my-stories-views.js'
import { hideMyStoriesViews } from './methods/stories/hide-my-stories-views' import { incrementStoriesViews } from './methods/stories/increment-stories-views.js'
import { incrementStoriesViews } from './methods/stories/increment-stories-views' import { iterAllStories } from './methods/stories/iter-all-stories.js'
import { iterAllStories } from './methods/stories/iter-all-stories' import { iterBoosters } from './methods/stories/iter-boosters.js'
import { iterBoosters } from './methods/stories/iter-boosters' import { iterProfileStories } from './methods/stories/iter-profile-stories.js'
import { iterProfileStories } from './methods/stories/iter-profile-stories' import { iterStoryViewers } from './methods/stories/iter-story-viewers.js'
import { iterStoryViewers } from './methods/stories/iter-story-viewers' import { readStories } from './methods/stories/read-stories.js'
import { readStories } from './methods/stories/read-stories' import { reportStory } from './methods/stories/report-story.js'
import { reportStory } from './methods/stories/report-story' import { sendStory } from './methods/stories/send-story.js'
import { sendStory } from './methods/stories/send-story' import { sendStoryReaction } from './methods/stories/send-story-reaction.js'
import { sendStoryReaction } from './methods/stories/send-story-reaction' import { togglePeerStoriesArchived } from './methods/stories/toggle-peer-stories-archived.js'
import { togglePeerStoriesArchived } from './methods/stories/toggle-peer-stories-archived' import { toggleStoriesPinned } from './methods/stories/toggle-stories-pinned.js'
import { toggleStoriesPinned } from './methods/stories/toggle-stories-pinned' import { enableUpdatesProcessing, makeParsedUpdateHandler, ParsedUpdateHandlerParams } from './methods/updates/index.js'
import { enableUpdatesProcessing, makeParsedUpdateHandler, ParsedUpdateHandlerParams } from './methods/updates'
import { import {
catchUp, catchUp,
enableRps, enableRps,
@ -227,27 +211,28 @@ import {
getCurrentRpsProcessing, getCurrentRpsProcessing,
startUpdatesLoop, startUpdatesLoop,
stopUpdatesLoop, stopUpdatesLoop,
} from './methods/updates/manager' } from './methods/updates/manager.js'
import { blockUser } from './methods/users/block-user' import { blockUser } from './methods/users/block-user.js'
import { deleteProfilePhotos } from './methods/users/delete-profile-photos' import { deleteProfilePhotos } from './methods/users/delete-profile-photos.js'
import { editCloseFriends, editCloseFriendsRaw } from './methods/users/edit-close-friends' import { editCloseFriends, editCloseFriendsRaw } from './methods/users/edit-close-friends.js'
import { getCommonChats } from './methods/users/get-common-chats' import { getCommonChats } from './methods/users/get-common-chats.js'
import { getGlobalTtl } from './methods/users/get-global-ttl' import { getGlobalTtl } from './methods/users/get-global-ttl.js'
import { getMe } from './methods/users/get-me' import { getMe } from './methods/users/get-me.js'
import { getMyUsername } from './methods/users/get-my-username' import { getMyUsername } from './methods/users/get-my-username.js'
import { getProfilePhoto } from './methods/users/get-profile-photo' import { getProfilePhoto } from './methods/users/get-profile-photo.js'
import { getProfilePhotos } from './methods/users/get-profile-photos' import { getProfilePhotos } from './methods/users/get-profile-photos.js'
import { getUsers } from './methods/users/get-users' import { getUsers } from './methods/users/get-users.js'
import { iterProfilePhotos } from './methods/users/iter-profile-photos' import { iterProfilePhotos } from './methods/users/iter-profile-photos.js'
import { resolvePeer } from './methods/users/resolve-peer' import { resolvePeer } from './methods/users/resolve-peer.js'
import { resolvePeerMany } from './methods/users/resolve-peer-many' import { resolvePeerMany } from './methods/users/resolve-peer-many.js'
import { setEmojiStatus } from './methods/users/set-emoji-status' import { setEmojiStatus } from './methods/users/set-emoji-status.js'
import { setGlobalTtl } from './methods/users/set-global-ttl' import { setGlobalTtl } from './methods/users/set-global-ttl.js'
import { setOffline } from './methods/users/set-offline' import { setOffline } from './methods/users/set-offline.js'
import { setProfilePhoto } from './methods/users/set-profile-photo' import { setProfilePhoto } from './methods/users/set-profile-photo.js'
import { setUsername } from './methods/users/set-username' import { setUsername } from './methods/users/set-username.js'
import { unblockUser } from './methods/users/unblock-user' import { unblockUser } from './methods/users/unblock-user.js'
import { updateProfile } from './methods/users/update-profile' import { updateProfile } from './methods/users/update-profile.js'
import { Conversation } from './types/conversation.js'
import { import {
AllStories, AllStories,
ArrayPaginated, ArrayPaginated,
@ -323,8 +308,7 @@ import {
User, User,
UserStatusUpdate, UserStatusUpdate,
UserTypingUpdate, UserTypingUpdate,
} from './types' } from './types/index.js'
import { Conversation } from './types/conversation'
// from methods/_init.ts // from methods/_init.ts
interface TelegramClientOptions extends BaseTelegramClientOptions { interface TelegramClientOptions extends BaseTelegramClientOptions {
@ -484,8 +468,6 @@ export interface TelegramClient extends BaseTelegramClient {
on(name: 'delete_story', handler: (upd: DeleteStoryUpdate) => void): this on(name: 'delete_story', handler: (upd: DeleteStoryUpdate) => void): this
getAuthState(): AuthState getAuthState(): AuthState
_onAuthorization(auth: tl.auth.TypeAuthorization, bot?: boolean): User
/** /**
* Check your Two-Step verification password and log in * Check your Two-Step verification password and log in
* *
@ -928,7 +910,7 @@ export interface TelegramClient extends BaseTelegramClient {
message: number message: number
/** Data contained in the button */ /** Data contained in the button */
data: string | Buffer data: string | Uint8Array
/** /**
* Timeout for the query in ms. * Timeout for the query in ms.
@ -994,10 +976,6 @@ export interface TelegramClient extends BaseTelegramClient {
*/ */
langCode?: string langCode?: string
}): Promise<tl.RawBotCommand[]> }): Promise<tl.RawBotCommand[]>
_normalizeCommandScope(
scope: tl.TypeBotCommandScope | BotCommands.IntermediateScope,
): Promise<tl.TypeBotCommandScope>
/** /**
* Sets information about a bot the current uzer owns (or the current bot) * Sets information about a bot the current uzer owns (or the current bot)
* **Available**: both users and bots * **Available**: both users and bots
@ -1997,8 +1975,6 @@ export interface TelegramClient extends BaseTelegramClient {
* *
*/ */
getFolders(): Promise<tl.TypeDialogFilter[]> getFolders(): Promise<tl.TypeDialogFilter[]>
_normalizeInputFolder(folder: InputDialogFolder): Promise<tl.TypeDialogFilter>
/** /**
* Get dialogs with certain peers. * Get dialogs with certain peers.
* *
@ -2135,7 +2111,7 @@ export interface TelegramClient extends BaseTelegramClient {
* *
* @param params File download parameters * @param params File download parameters
*/ */
downloadAsBuffer(params: FileDownloadParameters): Promise<Buffer> downloadAsBuffer(params: FileDownloadParameters): Promise<Uint8Array>
/** /**
* Download a remote file to a local file (only for NodeJS). * Download a remote file to a local file (only for NodeJS).
* Promise will resolve once the download is complete. * Promise will resolve once the download is complete.
@ -2155,7 +2131,7 @@ export interface TelegramClient extends BaseTelegramClient {
* *
* @param params Download parameters * @param params Download parameters
*/ */
downloadAsIterable(params: FileDownloadParameters): AsyncIterableIterator<Buffer> downloadAsIterable(params: FileDownloadParameters): AsyncIterableIterator<Uint8Array>
/** /**
* Download a file and return it as a Node readable stream, * Download a file and return it as a Node readable stream,
* streaming file contents. * streaming file contents.
@ -2165,16 +2141,6 @@ export interface TelegramClient extends BaseTelegramClient {
* @param params File download parameters * @param params File download parameters
*/ */
downloadAsStream(params: FileDownloadParameters): Readable downloadAsStream(params: FileDownloadParameters): Readable
/**
* **Available**: both users and bots
*
*/
_normalizeFileToDocument(
file: InputFileLike | tl.TypeInputDocument,
params: {
progressCallback?: (uploaded: number, total: number) => void
},
): Promise<tl.TypeInputDocument>
/** /**
* Normalize a {@link InputFileLike} to `InputFile`, * Normalize a {@link InputFileLike} to `InputFile`,
* uploading it if needed. * uploading it if needed.
@ -3001,8 +2967,6 @@ export interface TelegramClient extends BaseTelegramClient {
shouldDispatch?: true shouldDispatch?: true
}, },
): Promise<Message> ): Promise<Message>
_findMessageInUpdate(res: tl.TypeUpdates, isEdit?: boolean, noDispatch?: boolean): Message
/** /**
* Forward one or more messages by their IDs. * Forward one or more messages by their IDs.
* You can forward no more than 100 messages at once. * You can forward no more than 100 messages at once.
@ -3037,8 +3001,6 @@ export interface TelegramClient extends BaseTelegramClient {
messages: Message[] messages: Message[]
}, },
): Promise<Message[]> ): Promise<Message[]>
_getDiscussionMessage(peer: InputPeerLike, message: number): Promise<[tl.TypeInputPeer, number]>
// public version of the same method because why not // public version of the same method because why not
/** /**
* Get discussion message for some channel post. * Get discussion message for some channel post.
@ -3356,12 +3318,6 @@ export interface TelegramClient extends BaseTelegramClient {
chunkSize?: number chunkSize?: number
}, },
): AsyncIterableIterator<Message> ): AsyncIterableIterator<Message>
_parseEntities(
text?: string | FormattedString<string>,
mode?: string | null,
entities?: tl.TypeMessageEntity[],
): Promise<[string, tl.TypeMessageEntity[] | undefined]>
/** /**
* Pin a message in a group, supergroup, channel or PM. * Pin a message in a group, supergroup, channel or PM.
* *
@ -3856,7 +3812,7 @@ export interface TelegramClient extends BaseTelegramClient {
* representing them. In case of indexes, the poll will first * representing them. In case of indexes, the poll will first
* be requested from the server. * be requested from the server.
*/ */
options: null | MaybeArray<number | Buffer> options: null | MaybeArray<number | Uint8Array>
}, },
): Promise<Poll> ): Promise<Poll>
/** /**
@ -3928,8 +3884,6 @@ export interface TelegramClient extends BaseTelegramClient {
* *
*/ */
_normalizePrivacyRules(rules: InputPrivacyRule[]): Promise<tl.TypeInputPrivacyRule[]> _normalizePrivacyRules(rules: InputPrivacyRule[]): Promise<tl.TypeInputPrivacyRule[]>
getParseModesState(): ParseModesState
/** /**
* Register a given {@link IMessageEntityParser} as a parse mode * Register a given {@link IMessageEntityParser} as a parse mode
* for messages. When this method is first called, given parse * for messages. When this method is first called, given parse
@ -4344,8 +4298,6 @@ export interface TelegramClient extends BaseTelegramClient {
*/ */
privacyRules?: InputPrivacyRule[] privacyRules?: InputPrivacyRule[]
}): Promise<Story> }): Promise<Story>
_findStoryInUpdate(res: tl.TypeUpdates): Story
/** /**
* Get all stories (e.g. to load the top bar) * Get all stories (e.g. to load the top bar)
* **Available**: both users and bots * **Available**: both users and bots
@ -5148,7 +5100,6 @@ export class TelegramClient extends BaseTelegramClient {
} }
} }
getAuthState = getAuthState.bind(null, this) getAuthState = getAuthState.bind(null, this)
_onAuthorization = _onAuthorization.bind(null, this)
checkPassword = checkPassword.bind(null, this) checkPassword = checkPassword.bind(null, this)
getPasswordHint = getPasswordHint.bind(null, this) getPasswordHint = getPasswordHint.bind(null, this)
logOut = logOut.bind(null, this) logOut = logOut.bind(null, this)
@ -5169,7 +5120,6 @@ export class TelegramClient extends BaseTelegramClient {
getGameHighScores = getGameHighScores.bind(null, this) getGameHighScores = getGameHighScores.bind(null, this)
getInlineGameHighScores = getInlineGameHighScores.bind(null, this) getInlineGameHighScores = getInlineGameHighScores.bind(null, this)
getMyCommands = getMyCommands.bind(null, this) getMyCommands = getMyCommands.bind(null, this)
_normalizeCommandScope = _normalizeCommandScope.bind(null, this)
setBotInfo = setBotInfo.bind(null, this) setBotInfo = setBotInfo.bind(null, this)
setBotMenuButton = setBotMenuButton.bind(null, this) setBotMenuButton = setBotMenuButton.bind(null, this)
setGameScore = setGameScore.bind(null, this) setGameScore = setGameScore.bind(null, this)
@ -5228,7 +5178,6 @@ export class TelegramClient extends BaseTelegramClient {
editFolder = editFolder.bind(null, this) editFolder = editFolder.bind(null, this)
findFolder = findFolder.bind(null, this) findFolder = findFolder.bind(null, this)
getFolders = getFolders.bind(null, this) getFolders = getFolders.bind(null, this)
_normalizeInputFolder = _normalizeInputFolder.bind(null, this)
getPeerDialogs = getPeerDialogs.bind(null, this) getPeerDialogs = getPeerDialogs.bind(null, this)
iterDialogs = iterDialogs.bind(null, this) iterDialogs = iterDialogs.bind(null, this)
setFoldersOrder = setFoldersOrder.bind(null, this) setFoldersOrder = setFoldersOrder.bind(null, this)
@ -5236,7 +5185,6 @@ export class TelegramClient extends BaseTelegramClient {
downloadToFile = downloadToFile.bind(null, this) downloadToFile = downloadToFile.bind(null, this)
downloadAsIterable = downloadAsIterable.bind(null, this) downloadAsIterable = downloadAsIterable.bind(null, this)
downloadAsStream = downloadAsStream.bind(null, this) downloadAsStream = downloadAsStream.bind(null, this)
_normalizeFileToDocument = _normalizeFileToDocument.bind(null, this)
_normalizeInputFile = _normalizeInputFile.bind(null, this) _normalizeInputFile = _normalizeInputFile.bind(null, this)
_normalizeInputMedia = _normalizeInputMedia.bind(null, this) _normalizeInputMedia = _normalizeInputMedia.bind(null, this)
uploadFile = uploadFile.bind(null, this) uploadFile = uploadFile.bind(null, this)
@ -5270,10 +5218,8 @@ export class TelegramClient extends BaseTelegramClient {
deleteScheduledMessages = deleteScheduledMessages.bind(null, this) deleteScheduledMessages = deleteScheduledMessages.bind(null, this)
editInlineMessage = editInlineMessage.bind(null, this) editInlineMessage = editInlineMessage.bind(null, this)
editMessage = editMessage.bind(null, this) editMessage = editMessage.bind(null, this)
_findMessageInUpdate = _findMessageInUpdate.bind(null, this)
forwardMessagesById = forwardMessagesById.bind(null, this) forwardMessagesById = forwardMessagesById.bind(null, this)
forwardMessages = forwardMessages.bind(null, this) forwardMessages = forwardMessages.bind(null, this)
_getDiscussionMessage = _getDiscussionMessage.bind(null, this)
getDiscussionMessage = getDiscussionMessage.bind(null, this) getDiscussionMessage = getDiscussionMessage.bind(null, this)
getHistory = getHistory.bind(null, this) getHistory = getHistory.bind(null, this)
getMessageGroup = getMessageGroup.bind(null, this) getMessageGroup = getMessageGroup.bind(null, this)
@ -5288,7 +5234,6 @@ export class TelegramClient extends BaseTelegramClient {
iterReactionUsers = iterReactionUsers.bind(null, this) iterReactionUsers = iterReactionUsers.bind(null, this)
iterSearchGlobal = iterSearchGlobal.bind(null, this) iterSearchGlobal = iterSearchGlobal.bind(null, this)
iterSearchMessages = iterSearchMessages.bind(null, this) iterSearchMessages = iterSearchMessages.bind(null, this)
_parseEntities = _parseEntities.bind(null, this)
pinMessage = pinMessage.bind(null, this) pinMessage = pinMessage.bind(null, this)
readHistory = readHistory.bind(null, this) readHistory = readHistory.bind(null, this)
readReactions = readReactions.bind(null, this) readReactions = readReactions.bind(null, this)
@ -5318,7 +5263,6 @@ export class TelegramClient extends BaseTelegramClient {
unpinMessage = unpinMessage.bind(null, this) unpinMessage = unpinMessage.bind(null, this)
initTakeoutSession = initTakeoutSession.bind(null, this) initTakeoutSession = initTakeoutSession.bind(null, this)
_normalizePrivacyRules = _normalizePrivacyRules.bind(null, this) _normalizePrivacyRules = _normalizePrivacyRules.bind(null, this)
getParseModesState = getParseModesState.bind(null, this)
registerParseMode = registerParseMode.bind(null, this) registerParseMode = registerParseMode.bind(null, this)
unregisterParseMode = unregisterParseMode.bind(null, this) unregisterParseMode = unregisterParseMode.bind(null, this)
getParseMode = getParseMode.bind(null, this) getParseMode = getParseMode.bind(null, this)
@ -5344,7 +5288,6 @@ export class TelegramClient extends BaseTelegramClient {
canSendStory = canSendStory.bind(null, this) canSendStory = canSendStory.bind(null, this)
deleteStories = deleteStories.bind(null, this) deleteStories = deleteStories.bind(null, this)
editStory = editStory.bind(null, this) editStory = editStory.bind(null, this)
_findStoryInUpdate = _findStoryInUpdate.bind(null, this)
getAllStories = getAllStories.bind(null, this) getAllStories = getAllStories.bind(null, this)
getBoostStats = getBoostStats.bind(null, this) getBoostStats = getBoostStats.bind(null, this)
getBoosters = getBoosters.bind(null, this) getBoosters = getBoosters.bind(null, this)

View file

@ -1,5 +1,5 @@
export * from './client' export * from './client.js'
export * from './types' export * from './types/index.js'
export * from './utils/peer-utils' export * from './utils/peer-utils.js'
export { createDummyUpdate } from './utils/updates-utils' export { createDummyUpdate } from './utils/updates-utils.js'
export * from '@mtcute/core' export * from '@mtcute/core'

View file

@ -24,7 +24,7 @@ Example:
```typescript ```typescript
// @copy // @copy
import { Something } from '../../somewhere' import { Something } from '../../somewhere.js'
// @copy // @copy
interface SomeGreatInterface { ... } interface SomeGreatInterface { ... }

View file

@ -83,4 +83,4 @@ import {
User, User,
UserStatusUpdate, UserStatusUpdate,
UserTypingUpdate, UserTypingUpdate,
} from '../types' } from '../types/index.js'

View file

@ -2,13 +2,13 @@
import { BaseTelegramClientOptions } from '@mtcute/core' import { BaseTelegramClientOptions } from '@mtcute/core'
import { TelegramClient } from '../client' import { TelegramClient } from '../client.js'
// @copy // @copy
import { Conversation } from '../types/conversation' import { Conversation } from '../types/conversation.js'
// @copy // @copy
import { start } from './auth/start' import { start } from './auth/start.js'
// @copy // @copy
import { enableUpdatesProcessing, makeParsedUpdateHandler, ParsedUpdateHandlerParams } from './updates' import { enableUpdatesProcessing, makeParsedUpdateHandler, ParsedUpdateHandlerParams } from './updates/index.js'
// @copy // @copy
interface TelegramClientOptions extends BaseTelegramClientOptions { interface TelegramClientOptions extends BaseTelegramClientOptions {

View file

@ -1,14 +1,11 @@
/* eslint-disable no-inner-declarations */ /* eslint-disable no-inner-declarations */
import { BaseTelegramClient, MtUnsupportedError, tl } from '@mtcute/core' import { BaseTelegramClient, MtUnsupportedError, tl } from '@mtcute/core'
import { assertTypeIs } from '@mtcute/core/utils' import { assertTypeIs } from '@mtcute/core/utils.js'
import { User } from '../../types/peers/user' import { User } from '../../types/peers/user.js'
const STATE_SYMBOL = Symbol('authState') const STATE_SYMBOL = Symbol('authState')
/** /** @exported */
* @internal
* @exported
*/
export interface AuthState { export interface AuthState {
// local copy of "self" in storage, // local copy of "self" in storage,
// so we can use it w/out relying on storage. // so we can use it w/out relying on storage.
@ -20,7 +17,6 @@ export interface AuthState {
selfChanged?: boolean selfChanged?: boolean
} }
/** @internal */
export function getAuthState(client: BaseTelegramClient): AuthState { export function getAuthState(client: BaseTelegramClient): AuthState {
// eslint-disable-next-line // eslint-disable-next-line
let state: AuthState = (client as any)[STATE_SYMBOL] let state: AuthState = (client as any)[STATE_SYMBOL]

View file

@ -1,8 +1,8 @@
import { BaseTelegramClient } from '@mtcute/core' import { BaseTelegramClient } from '@mtcute/core'
import { computeSrpParams } from '@mtcute/core/utils' import { computeSrpParams } from '@mtcute/core/utils.js'
import { User } from '../../types' import { User } from '../../types/index.js'
import { _onAuthorization } from './_state' import { _onAuthorization } from './_state.js'
/** /**
* Check your Two-Step verification password and log in * Check your Two-Step verification password and log in

View file

@ -1,6 +1,6 @@
import { BaseTelegramClient } from '@mtcute/core' import { BaseTelegramClient } from '@mtcute/core'
import { getAuthState } from './_state' import { getAuthState } from './_state.js'
/** /**
* Log out from Telegram account and optionally reset the session storage. * Log out from Telegram account and optionally reset the session storage.

View file

@ -1,7 +1,7 @@
import { BaseTelegramClient } from '@mtcute/core' import { BaseTelegramClient } from '@mtcute/core'
import { User } from '../../types' import { User } from '../../types/index.js'
import { _onAuthorization } from './_state' import { _onAuthorization } from './_state.js'
/** /**
* Recover your password with a recovery code and log in. * Recover your password with a recovery code and log in.

View file

@ -1,8 +1,8 @@
import { BaseTelegramClient } from '@mtcute/core' import { BaseTelegramClient } from '@mtcute/core'
import { assertTypeIs } from '@mtcute/core/utils' import { assertTypeIs } from '@mtcute/core/utils.js'
import { SentCode } from '../../types' import { SentCode } from '../../types/index.js'
import { normalizePhoneNumber } from '../../utils/misc-utils' import { normalizePhoneNumber } from '../../utils/misc-utils.js'
/** /**
* Re-send the confirmation code using a different type. * Re-send the confirmation code using a different type.

View file

@ -1,7 +1,7 @@
import { BaseTelegramClient } from '@mtcute/core' import { BaseTelegramClient } from '@mtcute/core'
import { User } from '../../types' import { User } from '../../types/index.js'
import { start } from './start' import { start } from './start.js'
/** /**
* Simple wrapper that calls {@link start} and then * Simple wrapper that calls {@link start} and then

View file

@ -1,8 +1,8 @@
import { BaseTelegramClient } from '@mtcute/core' import { BaseTelegramClient } from '@mtcute/core'
import { assertTypeIs } from '@mtcute/core/utils' import { assertTypeIs } from '@mtcute/core/utils.js'
import { SentCode } from '../../types' import { SentCode } from '../../types/index.js'
import { normalizePhoneNumber } from '../../utils/misc-utils' import { normalizePhoneNumber } from '../../utils/misc-utils.js'
/** /**
* Send the confirmation code to the given phone number * Send the confirmation code to the given phone number

View file

@ -1,7 +1,7 @@
import { BaseTelegramClient } from '@mtcute/core' import { BaseTelegramClient } from '@mtcute/core'
import { User } from '../../types' import { User } from '../../types/index.js'
import { _onAuthorization } from './_state' import { _onAuthorization } from './_state.js'
/** /**
* Authorize a bot using its token issued by [@BotFather](//t.me/BotFather) * Authorize a bot using its token issued by [@BotFather](//t.me/BotFather)

View file

@ -1,8 +1,8 @@
import { BaseTelegramClient } from '@mtcute/core' import { BaseTelegramClient } from '@mtcute/core'
import { User } from '../../types' import { User } from '../../types/index.js'
import { normalizePhoneNumber } from '../../utils/misc-utils' import { normalizePhoneNumber } from '../../utils/misc-utils.js'
import { _onAuthorization } from './_state' import { _onAuthorization } from './_state.js'
/** /**
* Authorize a user in Telegram with a valid confirmation code. * Authorize a user in Telegram with a valid confirmation code.

View file

@ -1,8 +1,8 @@
import { BaseTelegramClient, MtArgumentError } from '@mtcute/core' import { BaseTelegramClient, MtArgumentError } from '@mtcute/core'
import { User } from '../../types' import { User } from '../../types/index.js'
import { logOut } from './log-out' import { logOut } from './log-out.js'
import { start } from './start' import { start } from './start.js'
/** /**
* Utility function to quickly authorize on test DC * Utility function to quickly authorize on test DC

View file

@ -1,14 +1,14 @@
/* eslint-disable no-console */ /* eslint-disable no-console */
import { BaseTelegramClient, MaybeAsync, MtArgumentError, tl } from '@mtcute/core' import { BaseTelegramClient, MaybeAsync, MtArgumentError, tl } from '@mtcute/core'
import { MaybeDynamic, SentCode, User } from '../../types' import { MaybeDynamic, SentCode, User } from '../../types/index.js'
import { normalizePhoneNumber, resolveMaybeDynamic } from '../../utils/misc-utils' import { normalizePhoneNumber, resolveMaybeDynamic } from '../../utils/misc-utils.js'
import { getMe } from '../users/get-me' import { getMe } from '../users/get-me.js'
import { checkPassword } from './check-password' import { checkPassword } from './check-password.js'
import { resendCode } from './resend-code' import { resendCode } from './resend-code.js'
import { sendCode } from './send-code' import { sendCode } from './send-code.js'
import { signIn } from './sign-in' import { signIn } from './sign-in.js'
import { signInBot } from './sign-in-bot' import { signInBot } from './sign-in-bot.js'
// @manual // @manual
// @available=both // @available=both

View file

@ -1,6 +1,6 @@
import { BaseTelegramClient, Long } from '@mtcute/core' import { BaseTelegramClient, Long } from '@mtcute/core'
import { CallbackQuery } from '../../types/bots/callback-query' import { CallbackQuery } from '../../types/bots/callback-query.js'
/** /**
* Send an answer to a callback query. * Send an answer to a callback query.

View file

@ -1,6 +1,6 @@
import { BaseTelegramClient, Long, tl } from '@mtcute/core' import { BaseTelegramClient, Long, tl } from '@mtcute/core'
import { BotInline, InlineQuery, InputInlineResult } from '../../types/bots' import { BotInline, InlineQuery, InputInlineResult } from '../../types/bots/index.js'
/** /**
* Answer an inline query. * Answer an inline query.

View file

@ -1,6 +1,6 @@
import { BaseTelegramClient, Long, tl } from '@mtcute/core' import { BaseTelegramClient, Long, tl } from '@mtcute/core'
import { PreCheckoutQuery } from '../../types/updates' import type { PreCheckoutQuery } from '../../types/updates/pre-checkout-query.js'
/** /**
* Answer a pre-checkout query. * Answer a pre-checkout query.

View file

@ -1,7 +1,7 @@
import { BaseTelegramClient, tl } from '@mtcute/core' import { BaseTelegramClient, tl } from '@mtcute/core'
import { BotCommands } from '../../types' import { BotCommands } from '../../types/index.js'
import { _normalizeCommandScope } from './normalize-command-scope' import { _normalizeCommandScope } from './normalize-command-scope.js'
/** /**
* Delete commands for the current bot and the given scope. * Delete commands for the current bot and the given scope.

View file

@ -1,8 +1,8 @@
import { BaseTelegramClient, tl } from '@mtcute/core' import { BaseTelegramClient, tl } from '@mtcute/core'
import { InputPeerLike } from '../../types' import { InputPeerLike } from '../../types/index.js'
import { normalizeToInputUser } from '../../utils/peer-utils' import { normalizeToInputUser } from '../../utils/peer-utils.js'
import { resolvePeer } from '../users/resolve-peer' import { resolvePeer } from '../users/resolve-peer.js'
/** /**
* Gets information about a bot the current uzer owns (or the current bot) * Gets information about a bot the current uzer owns (or the current bot)

View file

@ -1,8 +1,8 @@
import { BaseTelegramClient, tl } from '@mtcute/core' import { BaseTelegramClient, tl } from '@mtcute/core'
import { InputPeerLike } from '../../types' import { InputPeerLike } from '../../types/index.js'
import { normalizeToInputUser } from '../../utils/peer-utils' import { normalizeToInputUser } from '../../utils/peer-utils.js'
import { resolvePeer } from '../users/resolve-peer' import { resolvePeer } from '../users/resolve-peer.js'
/** /**
* Fetches the menu button set for the given user. * Fetches the menu button set for the given user.

View file

@ -1,8 +1,8 @@
import { BaseTelegramClient, tl } from '@mtcute/core' import { BaseTelegramClient, tl } from '@mtcute/core'
import { computeSrpParams } from '@mtcute/core/utils' import { computeSrpParams, utf8EncodeToBuffer } from '@mtcute/core/utils.js'
import { InputPeerLike } from '../../types' import { InputPeerLike } from '../../types/index.js'
import { resolvePeer } from '../users/resolve-peer' import { resolvePeer } from '../users/resolve-peer.js'
/** /**
* Request a callback answer from a bot, * Request a callback answer from a bot,
@ -20,7 +20,7 @@ export async function getCallbackAnswer(
message: number message: number
/** Data contained in the button */ /** Data contained in the button */
data: string | Buffer data: string | Uint8Array
/** /**
* Timeout for the query in ms. * Timeout for the query in ms.
@ -57,7 +57,7 @@ export async function getCallbackAnswer(
_: 'messages.getBotCallbackAnswer', _: 'messages.getBotCallbackAnswer',
peer: await resolvePeer(client, chatId), peer: await resolvePeer(client, chatId),
msgId: message, msgId: message,
data: typeof data === 'string' ? Buffer.from(data) : data, data: typeof data === 'string' ? utf8EncodeToBuffer(data) : data,
password, password,
game: game, game: game,
}, },

View file

@ -1,9 +1,9 @@
import { BaseTelegramClient, tl } from '@mtcute/core' import { BaseTelegramClient, tl } from '@mtcute/core'
import { GameHighScore, InputMessageId, InputPeerLike, normalizeInputMessageId, PeersIndex } from '../../types' import { GameHighScore, InputMessageId, InputPeerLike, normalizeInputMessageId, PeersIndex } from '../../types/index.js'
import { normalizeInlineId } from '../../utils/inline-utils' import { normalizeInlineId } from '../../utils/inline-utils.js'
import { normalizeToInputUser } from '../../utils/peer-utils' import { normalizeToInputUser } from '../../utils/peer-utils.js'
import { resolvePeer } from '../users/resolve-peer' import { resolvePeer } from '../users/resolve-peer.js'
/** /**
* Get high scores of a game * Get high scores of a game

View file

@ -1,7 +1,7 @@
import { BaseTelegramClient, tl } from '@mtcute/core' import { BaseTelegramClient, tl } from '@mtcute/core'
import { BotCommands } from '../../types' import { BotCommands } from '../../types/index.js'
import { _normalizeCommandScope } from './normalize-command-scope' import { _normalizeCommandScope } from './normalize-command-scope.js'
/** /**
* Get a list of current bot's commands for the given command scope * Get a list of current bot's commands for the given command scope

View file

@ -1,8 +1,8 @@
import { assertNever, BaseTelegramClient, tl } from '@mtcute/core' import { assertNever, BaseTelegramClient, tl } from '@mtcute/core'
import { BotCommands } from '../../types' import { BotCommands } from '../../types/index.js'
import { normalizeToInputUser } from '../../utils/peer-utils' import { normalizeToInputUser } from '../../utils/peer-utils.js'
import { resolvePeer } from '../users/resolve-peer' import { resolvePeer } from '../users/resolve-peer.js'
/** @internal */ /** @internal */
export async function _normalizeCommandScope( export async function _normalizeCommandScope(

View file

@ -1,8 +1,8 @@
import { BaseTelegramClient } from '@mtcute/core' import { BaseTelegramClient } from '@mtcute/core'
import { InputPeerLike } from '../../types' import { InputPeerLike } from '../../types/index.js'
import { normalizeToInputUser } from '../../utils/peer-utils' import { normalizeToInputUser } from '../../utils/peer-utils.js'
import { resolvePeer } from '../users/resolve-peer' import { resolvePeer } from '../users/resolve-peer.js'
/** /**
* Sets information about a bot the current uzer owns (or the current bot) * Sets information about a bot the current uzer owns (or the current bot)

View file

@ -1,8 +1,8 @@
import { BaseTelegramClient, tl } from '@mtcute/core' import { BaseTelegramClient, tl } from '@mtcute/core'
import { InputPeerLike } from '../../types' import { InputPeerLike } from '../../types/index.js'
import { normalizeToInputUser } from '../../utils/peer-utils' import { normalizeToInputUser } from '../../utils/peer-utils.js'
import { resolvePeer } from '../users/resolve-peer' import { resolvePeer } from '../users/resolve-peer.js'
/** /**
* Sets a menu button for the given user. * Sets a menu button for the given user.

View file

@ -1,10 +1,10 @@
import { BaseTelegramClient, tl } from '@mtcute/core' import { BaseTelegramClient, tl } from '@mtcute/core'
import { InputMessageId, InputPeerLike, Message, normalizeInputMessageId } from '../../types' import { InputMessageId, InputPeerLike, Message, normalizeInputMessageId } from '../../types/index.js'
import { normalizeInlineId } from '../../utils/inline-utils' import { normalizeInlineId } from '../../utils/inline-utils.js'
import { normalizeToInputUser } from '../../utils/peer-utils' import { normalizeToInputUser } from '../../utils/peer-utils.js'
import { _findMessageInUpdate } from '../messages/find-in-update' import { _findMessageInUpdate } from '../messages/find-in-update.js'
import { resolvePeer } from '../users/resolve-peer' import { resolvePeer } from '../users/resolve-peer.js'
/** /**
* Set a score of a user in a game * Set a score of a user in a game

View file

@ -1,7 +1,7 @@
import { BaseTelegramClient, tl } from '@mtcute/core' import { BaseTelegramClient, tl } from '@mtcute/core'
import { BotCommands } from '../../types' import { BotCommands } from '../../types/index.js'
import { _normalizeCommandScope } from './normalize-command-scope' import { _normalizeCommandScope } from './normalize-command-scope.js'
/** /**
* Set or delete commands for the current bot and the given scope * Set or delete commands for the current bot and the given scope

View file

@ -1,14 +1,14 @@
import { BaseTelegramClient, MaybeArray } from '@mtcute/core' import { BaseTelegramClient, MaybeArray } from '@mtcute/core'
import { InputPeerLike, MtInvalidPeerTypeError } from '../../types' import { InputPeerLike, MtInvalidPeerTypeError } from '../../types/index.js'
import { import {
isInputPeerChannel, isInputPeerChannel,
isInputPeerChat, isInputPeerChat,
normalizeToInputChannel, normalizeToInputChannel,
normalizeToInputUser, normalizeToInputUser,
} from '../../utils/peer-utils' } from '../../utils/peer-utils.js'
import { resolvePeer } from '../users/resolve-peer' import { resolvePeer } from '../users/resolve-peer.js'
import { resolvePeerMany } from '../users/resolve-peer-many' import { resolvePeerMany } from '../users/resolve-peer-many.js'
/** /**
* Add one or more new members to a group, supergroup or channel. * Add one or more new members to a group, supergroup or channel.

View file

@ -1,7 +1,7 @@
import { BaseTelegramClient, MaybeArray } from '@mtcute/core' import { BaseTelegramClient, MaybeArray } from '@mtcute/core'
import { InputPeerLike } from '../../types' import { InputPeerLike } from '../../types/index.js'
import { resolvePeerMany } from '../users/resolve-peer-many' import { resolvePeerMany } from '../users/resolve-peer-many.js'
/** /**
* Archive one or more chats * Archive one or more chats

View file

@ -1,14 +1,14 @@
import { BaseTelegramClient, MtTypeAssertionError } from '@mtcute/core' import { BaseTelegramClient, MtTypeAssertionError } from '@mtcute/core'
import { InputPeerLike, Message, MtInvalidPeerTypeError } from '../../types' import { InputPeerLike, Message, MtInvalidPeerTypeError } from '../../types/index.js'
import { import {
isInputPeerChannel, isInputPeerChannel,
isInputPeerChat, isInputPeerChat,
normalizeToInputChannel, normalizeToInputChannel,
normalizeToInputUser, normalizeToInputUser,
} from '../../utils/peer-utils' } from '../../utils/peer-utils.js'
import { _findMessageInUpdate } from '../messages/find-in-update' import { _findMessageInUpdate } from '../messages/find-in-update.js'
import { resolvePeer } from '../users/resolve-peer' import { resolvePeer } from '../users/resolve-peer.js'
/** /**
* Ban a user/channel from a legacy group, a supergroup or a channel. * Ban a user/channel from a legacy group, a supergroup or a channel.

View file

@ -1,7 +1,7 @@
import { BaseTelegramClient } from '@mtcute/core' import { BaseTelegramClient } from '@mtcute/core'
import { Chat } from '../../types' import { Chat } from '../../types/index.js'
import { assertIsUpdatesGroup } from '../../utils/updates-utils' import { assertIsUpdatesGroup } from '../../utils/updates-utils.js'
/** /**
* Create a new broadcast channel * Create a new broadcast channel

View file

@ -1,9 +1,9 @@
import { BaseTelegramClient, MaybeArray } from '@mtcute/core' import { BaseTelegramClient, MaybeArray } from '@mtcute/core'
import { Chat, InputPeerLike } from '../../types' import { Chat, InputPeerLike } from '../../types/index.js'
import { normalizeToInputUser } from '../../utils/peer-utils' import { normalizeToInputUser } from '../../utils/peer-utils.js'
import { assertIsUpdatesGroup } from '../../utils/updates-utils' import { assertIsUpdatesGroup } from '../../utils/updates-utils.js'
import { resolvePeerMany } from '../users/resolve-peer-many' import { resolvePeerMany } from '../users/resolve-peer-many.js'
/** /**
* Create a legacy group chat * Create a legacy group chat

View file

@ -1,7 +1,7 @@
import { BaseTelegramClient } from '@mtcute/core' import { BaseTelegramClient } from '@mtcute/core'
import { Chat } from '../../types' import { Chat } from '../../types/index.js'
import { assertIsUpdatesGroup } from '../../utils/updates-utils' import { assertIsUpdatesGroup } from '../../utils/updates-utils.js'
/** /**
* Create a new supergroup * Create a new supergroup

View file

@ -1,8 +1,8 @@
import { BaseTelegramClient } from '@mtcute/core' import { BaseTelegramClient } from '@mtcute/core'
import { InputPeerLike } from '../../types' import { InputPeerLike } from '../../types/index.js'
import { normalizeToInputChannel } from '../../utils/peer-utils' import { normalizeToInputChannel } from '../../utils/peer-utils.js'
import { resolvePeer } from '../users/resolve-peer' import { resolvePeer } from '../users/resolve-peer.js'
// @alias=deleteSupergroup // @alias=deleteSupergroup
/** /**

View file

@ -1,8 +1,8 @@
import { BaseTelegramClient } from '@mtcute/core' import { BaseTelegramClient } from '@mtcute/core'
import { InputPeerLike, MtInvalidPeerTypeError } from '../../types' import { InputPeerLike, MtInvalidPeerTypeError } from '../../types/index.js'
import { isInputPeerChannel, isInputPeerChat, normalizeToInputChannel } from '../../utils/peer-utils' import { isInputPeerChannel, isInputPeerChat, normalizeToInputChannel } from '../../utils/peer-utils.js'
import { resolvePeer } from '../users/resolve-peer' import { resolvePeer } from '../users/resolve-peer.js'
/** /**
* Delete a chat photo * Delete a chat photo

View file

@ -1,8 +1,8 @@
import { BaseTelegramClient } from '@mtcute/core' import { BaseTelegramClient } from '@mtcute/core'
import { InputPeerLike, MtInvalidPeerTypeError } from '../../types' import { InputPeerLike, MtInvalidPeerTypeError } from '../../types/index.js'
import { isInputPeerChat } from '../../utils/peer-utils' import { isInputPeerChat } from '../../utils/peer-utils.js'
import { resolvePeer } from '../users/resolve-peer' import { resolvePeer } from '../users/resolve-peer.js'
/** /**
* Delete a legacy group chat for all members * Delete a legacy group chat for all members

View file

@ -1,9 +1,9 @@
import { BaseTelegramClient } from '@mtcute/core' import { BaseTelegramClient } from '@mtcute/core'
import { InputPeerLike } from '../../types' import { InputPeerLike } from '../../types/index.js'
import { isInputPeerChannel } from '../../utils/peer-utils' import { isInputPeerChannel } from '../../utils/peer-utils.js'
import { createDummyUpdate } from '../../utils/updates-utils' import { createDummyUpdate } from '../../utils/updates-utils.js'
import { resolvePeer } from '../users/resolve-peer' import { resolvePeer } from '../users/resolve-peer.js'
/** /**
* Delete communication history (for private chats and legacy groups) * Delete communication history (for private chats and legacy groups)

View file

@ -1,9 +1,9 @@
import { BaseTelegramClient, tl } from '@mtcute/core' import { BaseTelegramClient, tl } from '@mtcute/core'
import { InputPeerLike } from '../../types' import { InputPeerLike } from '../../types/index.js'
import { normalizeToInputChannel } from '../../utils/peer-utils' import { normalizeToInputChannel } from '../../utils/peer-utils.js'
import { createDummyUpdate } from '../../utils/updates-utils' import { createDummyUpdate } from '../../utils/updates-utils.js'
import { resolvePeer } from '../users/resolve-peer' import { resolvePeer } from '../users/resolve-peer.js'
/** /**
* Delete all messages of a user (or channel) in a supergroup * Delete all messages of a user (or channel) in a supergroup

View file

@ -1,8 +1,8 @@
import { BaseTelegramClient, tl } from '@mtcute/core' import { BaseTelegramClient, tl } from '@mtcute/core'
import { InputPeerLike } from '../../types' import { InputPeerLike } from '../../types/index.js'
import { normalizeToInputChannel, normalizeToInputUser } from '../../utils/peer-utils' import { normalizeToInputChannel, normalizeToInputUser } from '../../utils/peer-utils.js'
import { resolvePeer } from '../users/resolve-peer' import { resolvePeer } from '../users/resolve-peer.js'
/** /**
* Edit supergroup/channel admin rights of a user. * Edit supergroup/channel admin rights of a user.

View file

@ -1,10 +1,10 @@
import { BaseTelegramClient, Long, tl } from '@mtcute/core' import { BaseTelegramClient, Long, tl } from '@mtcute/core'
import { ChatEvent, InputPeerLike, PeersIndex } from '../../types' import { ChatEvent, InputPeerLike, PeersIndex } from '../../types/index.js'
import { InputChatEventFilters, normalizeChatEventFilters } from '../../types/peers/chat-event/filters' import { InputChatEventFilters, normalizeChatEventFilters } from '../../types/peers/chat-event/filters.js'
import { normalizeToInputChannel, normalizeToInputUser } from '../../utils/peer-utils' import { normalizeToInputChannel, normalizeToInputUser } from '../../utils/peer-utils.js'
import { resolvePeer } from '../users/resolve-peer' import { resolvePeer } from '../users/resolve-peer.js'
import { resolvePeerMany } from '../users/resolve-peer-many' import { resolvePeerMany } from '../users/resolve-peer-many.js'
/** /**
* Get chat event log ("Recent actions" in official clients). * Get chat event log ("Recent actions" in official clients).

View file

@ -1,9 +1,9 @@
import { BaseTelegramClient, tl } from '@mtcute/core' import { BaseTelegramClient, tl } from '@mtcute/core'
import { assertTypeIs } from '@mtcute/core/utils' import { assertTypeIs } from '@mtcute/core/utils.js'
import { ChatMember, InputPeerLike, MtInvalidPeerTypeError, PeersIndex } from '../../types' import { ChatMember, InputPeerLike, MtInvalidPeerTypeError, PeersIndex } from '../../types/index.js'
import { isInputPeerChannel, isInputPeerChat, isInputPeerUser, normalizeToInputChannel } from '../../utils/peer-utils' import { isInputPeerChannel, isInputPeerChat, isInputPeerUser, normalizeToInputChannel } from '../../utils/peer-utils.js'
import { resolvePeer } from '../users/resolve-peer' import { resolvePeer } from '../users/resolve-peer.js'
/** /**
* Get information about a single chat member * Get information about a single chat member

View file

@ -1,10 +1,10 @@
import { assertNever, BaseTelegramClient, Long, tl } from '@mtcute/core' import { assertNever, BaseTelegramClient, Long, tl } from '@mtcute/core'
import { assertTypeIs } from '@mtcute/core/utils' import { assertTypeIs } from '@mtcute/core/utils.js'
import { ArrayWithTotal, ChatMember, InputPeerLike, MtInvalidPeerTypeError, PeersIndex } from '../../types' import { ArrayWithTotal, ChatMember, InputPeerLike, MtInvalidPeerTypeError, PeersIndex } from '../../types/index.js'
import { makeArrayWithTotal } from '../../utils' import { makeArrayWithTotal } from '../../utils/index.js'
import { isInputPeerChannel, isInputPeerChat, normalizeToInputChannel } from '../../utils/peer-utils' import { isInputPeerChannel, isInputPeerChat, normalizeToInputChannel } from '../../utils/peer-utils.js'
import { resolvePeer } from '../users/resolve-peer' import { resolvePeer } from '../users/resolve-peer.js'
/** /**
* Get a chunk of members of some chat. * Get a chunk of members of some chat.

View file

@ -1,7 +1,7 @@
import { BaseTelegramClient, MtArgumentError } from '@mtcute/core' import { BaseTelegramClient, MtArgumentError } from '@mtcute/core'
import { ChatPreview, MtPeerNotFoundError } from '../../types' import { ChatPreview, MtPeerNotFoundError } from '../../types/index.js'
import { INVITE_LINK_REGEX } from '../../utils/peer-utils' import { INVITE_LINK_REGEX } from '../../utils/peer-utils.js'
/** /**
* Get preview information about a private chat. * Get preview information about a private chat.

View file

@ -1,6 +1,6 @@
import { BaseTelegramClient, MtArgumentError, tl } from '@mtcute/core' import { BaseTelegramClient, MtArgumentError, tl } from '@mtcute/core'
import { Chat, InputPeerLike } from '../../types' import { Chat, InputPeerLike } from '../../types/index.js'
import { import {
INVITE_LINK_REGEX, INVITE_LINK_REGEX,
isInputPeerChannel, isInputPeerChannel,
@ -8,8 +8,8 @@ import {
isInputPeerUser, isInputPeerUser,
normalizeToInputChannel, normalizeToInputChannel,
normalizeToInputUser, normalizeToInputUser,
} from '../../utils/peer-utils' } from '../../utils/peer-utils.js'
import { resolvePeer } from '../users/resolve-peer' import { resolvePeer } from '../users/resolve-peer.js'
// @available=both // @available=both
/** /**

View file

@ -1,6 +1,6 @@
import { BaseTelegramClient, MtArgumentError, tl } from '@mtcute/core' import { BaseTelegramClient, MtArgumentError, tl } from '@mtcute/core'
import { Chat, InputPeerLike } from '../../types' import { Chat, InputPeerLike } from '../../types/index.js'
import { import {
INVITE_LINK_REGEX, INVITE_LINK_REGEX,
isInputPeerChannel, isInputPeerChannel,
@ -8,8 +8,8 @@ import {
isInputPeerUser, isInputPeerUser,
normalizeToInputChannel, normalizeToInputChannel,
normalizeToInputUser, normalizeToInputUser,
} from '../../utils/peer-utils' } from '../../utils/peer-utils.js'
import { resolvePeer } from '../users/resolve-peer' import { resolvePeer } from '../users/resolve-peer.js'
// @available=both // @available=both
/** /**

View file

@ -1,8 +1,8 @@
import { BaseTelegramClient, getMarkedPeerId, tl } from '@mtcute/core' import { BaseTelegramClient, getMarkedPeerId, tl } from '@mtcute/core'
import { assertTypeIs } from '@mtcute/core/utils' import { assertTypeIs } from '@mtcute/core/utils.js'
import { Chat } from '../../types' import { Chat } from '../../types/index.js'
import { assertIsUpdatesGroup } from '../../utils/updates-utils' import { assertIsUpdatesGroup } from '../../utils/updates-utils.js'
/** /**
* Get nearby chats * Get nearby chats

View file

@ -1,11 +1,11 @@
import { BaseTelegramClient, Long, tl } from '@mtcute/core' import { BaseTelegramClient, Long, tl } from '@mtcute/core'
import { ChatEvent, InputPeerLike } from '../../types' import { ChatEvent, InputPeerLike } from '../../types/index.js'
import { normalizeChatEventFilters } from '../../types/peers/chat-event/filters' import { normalizeChatEventFilters } from '../../types/peers/chat-event/filters.js'
import { normalizeToInputChannel, normalizeToInputUser } from '../../utils/peer-utils' import { normalizeToInputChannel, normalizeToInputUser } from '../../utils/peer-utils.js'
import { resolvePeer } from '../users/resolve-peer' import { resolvePeer } from '../users/resolve-peer.js'
import { resolvePeerMany } from '../users/resolve-peer-many' import { resolvePeerMany } from '../users/resolve-peer-many.js'
import { getChatEventLog } from './get-chat-event-log' import { getChatEventLog } from './get-chat-event-log.js'
/** /**
* Iterate over chat event log. * Iterate over chat event log.

View file

@ -1,9 +1,9 @@
import { BaseTelegramClient } from '@mtcute/core' import { BaseTelegramClient } from '@mtcute/core'
import { ChatMember, InputPeerLike } from '../../types' import { ChatMember, InputPeerLike } from '../../types/index.js'
import { isInputPeerChat } from '../../utils/peer-utils' import { isInputPeerChat } from '../../utils/peer-utils.js'
import { resolvePeer } from '../users/resolve-peer' import { resolvePeer } from '../users/resolve-peer.js'
import { getChatMembers } from './get-chat-members' import { getChatMembers } from './get-chat-members.js'
/** /**
* Iterate through chat members * Iterate through chat members

View file

@ -1,9 +1,9 @@
import { BaseTelegramClient } from '@mtcute/core' import { BaseTelegramClient } from '@mtcute/core'
import { Chat, InputPeerLike } from '../../types' import { Chat, InputPeerLike } from '../../types/index.js'
import { INVITE_LINK_REGEX, normalizeToInputChannel } from '../../utils/peer-utils' import { INVITE_LINK_REGEX, normalizeToInputChannel } from '../../utils/peer-utils.js'
import { assertIsUpdatesGroup } from '../../utils/updates-utils' import { assertIsUpdatesGroup } from '../../utils/updates-utils.js'
import { resolvePeer } from '../users/resolve-peer' import { resolvePeer } from '../users/resolve-peer.js'
/** /**
* Join a channel or supergroup * Join a channel or supergroup

View file

@ -1,11 +1,11 @@
import { BaseTelegramClient } from '@mtcute/core' import { BaseTelegramClient } from '@mtcute/core'
import { sleep } from '@mtcute/core/utils' import { sleep } from '@mtcute/core/utils.js'
import { InputPeerLike } from '../../types' import { InputPeerLike } from '../../types/index.js'
import { isInputPeerChannel } from '../../utils/peer-utils' import { isInputPeerChannel } from '../../utils/peer-utils.js'
import { resolvePeer } from '../users/resolve-peer' import { resolvePeer } from '../users/resolve-peer.js'
import { banChatMember } from './ban-chat-member' import { banChatMember } from './ban-chat-member.js'
import { unbanChatMember } from './unban-chat-member' import { unbanChatMember } from './unban-chat-member.js'
/** /**
* Kick a user from a chat. * Kick a user from a chat.

View file

@ -1,9 +1,9 @@
import { BaseTelegramClient } from '@mtcute/core' import { BaseTelegramClient } from '@mtcute/core'
import { InputPeerLike, MtInvalidPeerTypeError } from '../../types' import { InputPeerLike, MtInvalidPeerTypeError } from '../../types/index.js'
import { isInputPeerChannel, isInputPeerChat, normalizeToInputChannel } from '../../utils/peer-utils' import { isInputPeerChannel, isInputPeerChat, normalizeToInputChannel } from '../../utils/peer-utils.js'
import { resolvePeer } from '../users/resolve-peer' import { resolvePeer } from '../users/resolve-peer.js'
import { deleteHistory } from './delete-history' import { deleteHistory } from './delete-history.js'
/** /**
* Leave a group chat, supergroup or channel * Leave a group chat, supergroup or channel

View file

@ -1,7 +1,7 @@
import { BaseTelegramClient } from '@mtcute/core' import { BaseTelegramClient } from '@mtcute/core'
import { InputPeerLike } from '../../types' import { InputPeerLike } from '../../types/index.js'
import { resolvePeer } from '../users/resolve-peer' import { resolvePeer } from '../users/resolve-peer.js'
/** /**
* Mark a chat as unread * Mark a chat as unread

Some files were not shown because too many files have changed in this diff Show more