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:
parent
01e5fbb95d
commit
f5976a2d74
613 changed files with 5532 additions and 3261 deletions
3
.dockerignore
Normal file
3
.dockerignore
Normal file
|
@ -0,0 +1,3 @@
|
|||
**/node_modules
|
||||
**/private
|
||||
**/dist
|
|
@ -3,12 +3,11 @@ const baseConfig = require('./.eslintrc.js')
|
|||
module.exports = {
|
||||
...baseConfig,
|
||||
overrides: [
|
||||
baseConfig.overrides[0],
|
||||
{
|
||||
...baseConfig.overrides[0],
|
||||
extends: [
|
||||
'plugin:@typescript-eslint/strict-type-checked',
|
||||
'plugin:import/typescript',
|
||||
],
|
||||
files: ['packages/**/*.ts'],
|
||||
extends: ['plugin:@typescript-eslint/strict-type-checked', 'plugin:import/typescript'],
|
||||
parser: '@typescript-eslint/parser',
|
||||
parserOptions: {
|
||||
project: true,
|
||||
|
@ -16,13 +15,16 @@ module.exports = {
|
|||
},
|
||||
rules: {
|
||||
...baseConfig.overrides[0].rules,
|
||||
'@typescript-eslint/restrict-template-expressions': [
|
||||
'error',
|
||||
{ allowNever: true },
|
||||
],
|
||||
'@typescript-eslint/restrict-template-expressions': ['error', { allowNever: true }],
|
||||
},
|
||||
reportUnusedDisableDirectives: false,
|
||||
},
|
||||
...baseConfig.overrides.slice(1),
|
||||
{
|
||||
files: ['e2e/**'],
|
||||
rules: {
|
||||
'import/no-unresolved': 'off',
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
|
|
10
.eslintrc.js
10
.eslintrc.js
|
@ -97,7 +97,7 @@ module.exports = {
|
|||
yoda: 2,
|
||||
|
||||
// Variables
|
||||
'no-restricted-globals': [2],
|
||||
'no-restricted-globals': ['error'],
|
||||
'no-var': 1,
|
||||
|
||||
// Codestyle
|
||||
|
@ -169,6 +169,7 @@ module.exports = {
|
|||
'import/no-default-export': 'error',
|
||||
'no-console': ['error', { allow: ['warn', 'error'] }],
|
||||
},
|
||||
ignorePatterns: ['packages/client/utils.ts', 'packages/core/utils.ts'],
|
||||
overrides: [
|
||||
{
|
||||
files: ['**/*.ts', '**/*.tsx'],
|
||||
|
@ -213,6 +214,7 @@ module.exports = {
|
|||
'@typescript-eslint/unbound-method': 'off',
|
||||
'@typescript-eslint/no-dynamic-delete': 'off',
|
||||
'@typescript-eslint/no-unsafe-member-access': 'off',
|
||||
'no-restricted-globals': ['error', 'Buffer', '__dirname', 'require'],
|
||||
},
|
||||
reportUnusedDisableDirectives: false,
|
||||
settings: {
|
||||
|
@ -235,6 +237,12 @@ module.exports = {
|
|||
'max-params': ['error', 4],
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['e2e/cjs/**'],
|
||||
rules: {
|
||||
'no-restricted-globals': 'off',
|
||||
},
|
||||
},
|
||||
],
|
||||
settings: {
|
||||
'import/resolver': {
|
||||
|
|
16
.github/workflows/test.yaml
vendored
16
.github/workflows/test.yaml
vendored
|
@ -28,11 +28,19 @@ jobs:
|
|||
- name: 'TL codegen'
|
||||
run: pnpm -C packages/tl run gen-code
|
||||
- name: 'TypeScript'
|
||||
run: pnpm run lint:tsc
|
||||
run: pnpm run lint:tsc:ci
|
||||
- name: 'ESLint'
|
||||
env:
|
||||
NODE_OPTIONS: "--max_old_space_size=4096"
|
||||
run: pnpm run lint:ci
|
||||
- name: 'Circular dependencies'
|
||||
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
2
.gitignore
vendored
|
@ -11,3 +11,5 @@ private/
|
|||
|
||||
docs/*
|
||||
!docs/.nojekyll
|
||||
|
||||
*.tsbuildinfo
|
3
.mocharc.json
Normal file
3
.mocharc.json
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"node-option": ["experimental-specifier-resolution=node", "loader=ts-node/esm"]
|
||||
}
|
2
.npmrc
2
.npmrc
|
@ -1 +1 @@
|
|||
@mtcute:registry=https://npm.tei.su
|
||||
@mtcute:registry=https://npm.tei.su
|
7
e2e/.dockerignore
Normal file
7
e2e/.dockerignore
Normal file
|
@ -0,0 +1,7 @@
|
|||
.verdaccio
|
||||
node_modules
|
||||
private
|
||||
dist
|
||||
pnpm-lock.yaml
|
||||
.npmrc
|
||||
.env*
|
3
e2e/.env.example
Normal file
3
e2e/.env.example
Normal file
|
@ -0,0 +1,3 @@
|
|||
# obtain these values from my.telegram.org
|
||||
API_ID=
|
||||
API_HASH=
|
4
e2e/.gitignore
vendored
Normal file
4
e2e/.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
.verdaccio/storage
|
||||
.npmrc
|
||||
pnpm-lock.yaml
|
||||
.env
|
3
e2e/.mocharc.json
Normal file
3
e2e/.mocharc.json
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"node-option": []
|
||||
}
|
13
e2e/.verdaccio/config.yaml
Normal file
13
e2e/.verdaccio/config.yaml
Normal 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
1
e2e/.verdaccio/htpasswd
Normal file
|
@ -0,0 +1 @@
|
|||
mtcute-bot:$apr1$7rbqxva0$zyfFgknsbAxni.cq158Sf.
|
19
e2e/Dockerfile.build
Normal file
19
e2e/Dockerfile.build
Normal 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
13
e2e/Dockerfile.test
Normal 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
48
e2e/README.md
Normal 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
1
e2e/cjs/package.json
Normal file
|
@ -0,0 +1 @@
|
|||
{}
|
23
e2e/cjs/tests/base-client.js
Normal file
23
e2e/cjs/tests/base-client.js
Normal 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
123
e2e/cjs/tests/tl-runtime.js
Normal 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',
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
39
e2e/cjs/tests/tl-schema.js
Normal file
39
e2e/cjs/tests/tl-schema.js
Normal 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
11
e2e/cjs/utils.js
Normal 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
41
e2e/cli.sh
Executable 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
23
e2e/config.js
Normal 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
31
e2e/docker-compose.yaml
Normal 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
8
e2e/docker-entrypoint.sh
Normal 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
1
e2e/esm/package.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"type":"module"}
|
24
e2e/esm/tests/base-client.js
Normal file
24
e2e/esm/tests/base-client.js
Normal 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
122
e2e/esm/tests/tl-runtime.js
Normal 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',
|
||||
)
|
||||
})
|
||||
})
|
35
e2e/esm/tests/tl-schema.js
Normal file
35
e2e/esm/tests/tl-schema.js
Normal 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
11
e2e/esm/utils.js
Normal 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
31
e2e/package.json
Normal 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
2
e2e/pnpm-workspace.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
packages:
|
||||
- .
|
123
e2e/runner.js
Normal file
123
e2e/runner.js
Normal 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
52
e2e/ts/build-esm.cjs
Normal 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
3
e2e/ts/mocha.esm.json
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"node-option": ["experimental-specifier-resolution=node", "loader=ts-node/esm"]
|
||||
}
|
1
e2e/ts/package.json
Normal file
1
e2e/ts/package.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"type":"commonjs"}
|
26
e2e/ts/run-esm.cjs
Normal file
26
e2e/ts/run-esm.cjs
Normal 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
|
||||
}
|
25
e2e/ts/tests/base-client.ts
Normal file
25
e2e/ts/tests/base-client.ts
Normal 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
124
e2e/ts/tests/tl-runtime.ts
Normal 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
39
e2e/ts/tests/tl-schema.ts
Normal 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
28
e2e/ts/tsconfig.json
Normal 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
13
e2e/ts/utils.ts
Normal 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,
|
||||
}
|
||||
}
|
13
package.json
13
package.json
|
@ -8,15 +8,18 @@
|
|||
"scripts": {
|
||||
"prepare": "husky install",
|
||||
"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:ci": "eslint --config .eslintrc.ci.js .",
|
||||
"lint:tsc": "pnpm run -r build --noEmit",
|
||||
"lint:ci": "NODE_OPTIONS=\"--max_old_space_size=8192\" eslint --config .eslintrc.ci.js .",
|
||||
"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:fix": "eslint --fix .",
|
||||
"format": "prettier --write \"packages/**/*.ts\"",
|
||||
"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": {
|
||||
"node-gyp": "9.3.1"
|
||||
|
@ -25,6 +28,7 @@
|
|||
"@commitlint/cli": "^17.6.5",
|
||||
"@commitlint/config-conventional": "^17.6.5",
|
||||
"@types/chai": "4.3.5",
|
||||
"@types/chai-spies": "^1.0.4",
|
||||
"@types/mocha": "10.0.1",
|
||||
"@types/node": "18.16.0",
|
||||
"@types/node-forge": "1.3.2",
|
||||
|
@ -32,6 +36,7 @@
|
|||
"@typescript-eslint/eslint-plugin": "6.4.0",
|
||||
"@typescript-eslint/parser": "6.4.0",
|
||||
"chai": "4.3.7",
|
||||
"chai-spies": "^1.0.0",
|
||||
"dotenv-flow": "3.2.0",
|
||||
"dpdm": "^3.14.0",
|
||||
"eslint": "8.47.0",
|
||||
|
|
|
@ -6,13 +6,29 @@
|
|||
"author": "Alina Sireneva <alina@tei.su>",
|
||||
"license": "MIT",
|
||||
"main": "src/index.ts",
|
||||
"module": "_esm/index.js",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "mocha -r ts-node/register \"tests/**/*.spec.ts\"",
|
||||
"test": "mocha \"tests/**/*.spec.ts\"",
|
||||
"docs": "typedoc",
|
||||
"build": "tsc",
|
||||
"gen-client": "node ./scripts/generate-client.js",
|
||||
"gen-updates": "node ./scripts/generate-updates.js"
|
||||
"build": "pnpm run -w build-package client",
|
||||
"gen-client": "node ./scripts/generate-client.cjs",
|
||||
"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": {
|
||||
"@types/node": "18.16.0",
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
/* eslint-disable no-restricted-globals */
|
||||
const ts = require('typescript')
|
||||
const path = require('path')
|
||||
const fs = require('fs')
|
||||
const prettier = require('prettier')
|
||||
const updates = require('./generate-updates')
|
||||
const updates = require('./generate-updates.cjs')
|
||||
|
||||
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 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 module = `./${relPath.replace(/\.ts$/, '')}`
|
||||
const module = `./${relPath.replace(/\.ts$/, '.js')}`
|
||||
|
||||
state.files[relPath] = fileFullText
|
||||
|
||||
|
@ -319,7 +320,7 @@ async function addSingleMethod(state, fileName) {
|
|||
const isPrivate = checkForFlag(stmt, '@internal')
|
||||
const isManual = checkForFlag(stmt, '@manual')
|
||||
const isNoemit = checkForFlag(stmt, '@noemit')
|
||||
const shouldEmit = !isNoemit && !(isPrivate && !isOverload && !hasOverloads)
|
||||
const shouldEmit = !isNoemit && !(isPrivate && !isOverload && !Object.keys(hasOverloads).length)
|
||||
|
||||
if (shouldEmit) {
|
||||
state.methods.list.push({
|
||||
|
@ -432,6 +433,7 @@ async function main() {
|
|||
)
|
||||
Object.entries(state.imports).forEach(([module, items]) => {
|
||||
items = [...items]
|
||||
if (!items.length) return
|
||||
output.write(`import { ${items.sort().join(', ')} } from '${module}'\n`)
|
||||
})
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable no-restricted-globals */
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const prettier = require('prettier')
|
|
@ -2,224 +2,208 @@
|
|||
/* THIS FILE WAS AUTO-GENERATED */
|
||||
import { Readable } from 'stream'
|
||||
|
||||
import {
|
||||
BaseTelegramClient,
|
||||
BaseTelegramClientOptions,
|
||||
Long,
|
||||
MaybeArray,
|
||||
MaybeAsync,
|
||||
PartialExcept,
|
||||
PartialOnly,
|
||||
tl,
|
||||
} from '@mtcute/core'
|
||||
import { BaseTelegramClient, BaseTelegramClientOptions, Long, MaybeArray, MaybeAsync, PartialExcept, PartialOnly, tl } from '@mtcute/core'
|
||||
import { tdFileId } from '@mtcute/file-id'
|
||||
|
||||
import { _onAuthorization, AuthState, getAuthState } from './methods/auth/_state'
|
||||
import { checkPassword } from './methods/auth/check-password'
|
||||
import { getPasswordHint } from './methods/auth/get-password-hint'
|
||||
import { logOut } from './methods/auth/log-out'
|
||||
import { recoverPassword } from './methods/auth/recover-password'
|
||||
import { resendCode } from './methods/auth/resend-code'
|
||||
import {} from './methods/auth/run'
|
||||
import { sendCode } from './methods/auth/send-code'
|
||||
import { sendRecoveryCode } from './methods/auth/send-recovery-code'
|
||||
import { signIn } from './methods/auth/sign-in'
|
||||
import { signInBot } from './methods/auth/sign-in-bot'
|
||||
import { start } from './methods/auth/start'
|
||||
import { startTest } from './methods/auth/start-test'
|
||||
import { answerCallbackQuery } from './methods/bots/answer-callback-query'
|
||||
import { answerInlineQuery } from './methods/bots/answer-inline-query'
|
||||
import { answerPreCheckoutQuery } from './methods/bots/answer-pre-checkout-query'
|
||||
import { deleteMyCommands } from './methods/bots/delete-my-commands'
|
||||
import { getBotInfo } from './methods/bots/get-bot-info'
|
||||
import { getBotMenuButton } from './methods/bots/get-bot-menu-button'
|
||||
import { getCallbackAnswer } from './methods/bots/get-callback-answer'
|
||||
import { getGameHighScores, getInlineGameHighScores } from './methods/bots/get-game-high-scores'
|
||||
import { getMyCommands } from './methods/bots/get-my-commands'
|
||||
import { _normalizeCommandScope } from './methods/bots/normalize-command-scope'
|
||||
import { setBotInfo } from './methods/bots/set-bot-info'
|
||||
import { setBotMenuButton } from './methods/bots/set-bot-menu-button'
|
||||
import { setGameScore, setInlineGameScore } from './methods/bots/set-game-score'
|
||||
import { setMyCommands } from './methods/bots/set-my-commands'
|
||||
import { setMyDefaultRights } from './methods/bots/set-my-default-rights'
|
||||
import { addChatMembers } from './methods/chats/add-chat-members'
|
||||
import { archiveChats } from './methods/chats/archive-chats'
|
||||
import { banChatMember } from './methods/chats/ban-chat-member'
|
||||
import { createChannel } from './methods/chats/create-channel'
|
||||
import { createGroup } from './methods/chats/create-group'
|
||||
import { createSupergroup } from './methods/chats/create-supergroup'
|
||||
import { deleteChannel } from './methods/chats/delete-channel'
|
||||
import { deleteChatPhoto } from './methods/chats/delete-chat-photo'
|
||||
import { deleteGroup } from './methods/chats/delete-group'
|
||||
import { deleteHistory } from './methods/chats/delete-history'
|
||||
import { deleteUserHistory } from './methods/chats/delete-user-history'
|
||||
import { editAdminRights } from './methods/chats/edit-admin-rights'
|
||||
import { getChat } from './methods/chats/get-chat'
|
||||
import { getChatEventLog } from './methods/chats/get-chat-event-log'
|
||||
import { getChatMember } from './methods/chats/get-chat-member'
|
||||
import { getChatMembers } from './methods/chats/get-chat-members'
|
||||
import { getChatPreview } from './methods/chats/get-chat-preview'
|
||||
import { getFullChat } from './methods/chats/get-full-chat'
|
||||
import { getNearbyChats } from './methods/chats/get-nearby-chats'
|
||||
import { iterChatEventLog } from './methods/chats/iter-chat-event-log'
|
||||
import { iterChatMembers } from './methods/chats/iter-chat-members'
|
||||
import { joinChat } from './methods/chats/join-chat'
|
||||
import { kickChatMember } from './methods/chats/kick-chat-member'
|
||||
import { leaveChat } from './methods/chats/leave-chat'
|
||||
import { markChatUnread } from './methods/chats/mark-chat-unread'
|
||||
import { reorderUsernames } from './methods/chats/reorder-usernames'
|
||||
import { restrictChatMember } from './methods/chats/restrict-chat-member'
|
||||
import { saveDraft } from './methods/chats/save-draft'
|
||||
import { setChatDefaultPermissions } from './methods/chats/set-chat-default-permissions'
|
||||
import { setChatDescription } from './methods/chats/set-chat-description'
|
||||
import { setChatPhoto } from './methods/chats/set-chat-photo'
|
||||
import { setChatTitle } from './methods/chats/set-chat-title'
|
||||
import { setChatTtl } from './methods/chats/set-chat-ttl'
|
||||
import { setChatUsername } from './methods/chats/set-chat-username'
|
||||
import { setSlowMode } from './methods/chats/set-slow-mode'
|
||||
import { toggleContentProtection } from './methods/chats/toggle-content-protection'
|
||||
import { toggleFragmentUsername } from './methods/chats/toggle-fragment-username'
|
||||
import { toggleJoinRequests } from './methods/chats/toggle-join-requests'
|
||||
import { toggleJoinToSend } from './methods/chats/toggle-join-to-send'
|
||||
import { unarchiveChats } from './methods/chats/unarchive-chats'
|
||||
import { unbanChatMember } from './methods/chats/unban-chat-member'
|
||||
import { addContact } from './methods/contacts/add-contact'
|
||||
import { deleteContacts } from './methods/contacts/delete-contacts'
|
||||
import { getContacts } from './methods/contacts/get-contacts'
|
||||
import { importContacts } from './methods/contacts/import-contacts'
|
||||
import { createFolder } from './methods/dialogs/create-folder'
|
||||
import { deleteFolder } from './methods/dialogs/delete-folder'
|
||||
import { editFolder } from './methods/dialogs/edit-folder'
|
||||
import { findFolder } from './methods/dialogs/find-folder'
|
||||
import { _normalizeInputFolder, getFolders } from './methods/dialogs/get-folders'
|
||||
import { getPeerDialogs } from './methods/dialogs/get-peer-dialogs'
|
||||
import { iterDialogs } from './methods/dialogs/iter-dialogs'
|
||||
import { setFoldersOrder } from './methods/dialogs/set-folders-order'
|
||||
import { downloadAsBuffer } from './methods/files/download-buffer'
|
||||
import { downloadToFile } from './methods/files/download-file'
|
||||
import { downloadAsIterable } from './methods/files/download-iterable'
|
||||
import { downloadAsStream } from './methods/files/download-stream'
|
||||
import { _normalizeFileToDocument } from './methods/files/normalize-file-to-document'
|
||||
import { _normalizeInputFile } from './methods/files/normalize-input-file'
|
||||
import { _normalizeInputMedia } from './methods/files/normalize-input-media'
|
||||
import { uploadFile } from './methods/files/upload-file'
|
||||
import { uploadMedia } from './methods/files/upload-media'
|
||||
import { createForumTopic } from './methods/forums/create-forum-topic'
|
||||
import { deleteForumTopicHistory } from './methods/forums/delete-forum-topic-history'
|
||||
import { editForumTopic } from './methods/forums/edit-forum-topic'
|
||||
import { getForumTopics, GetForumTopicsOffset } from './methods/forums/get-forum-topics'
|
||||
import { getForumTopicsById } from './methods/forums/get-forum-topics-by-id'
|
||||
import { iterForumTopics } from './methods/forums/iter-forum-topics'
|
||||
import { reorderPinnedForumTopics } from './methods/forums/reorder-pinned-forum-topics'
|
||||
import { toggleForum } from './methods/forums/toggle-forum'
|
||||
import { toggleForumTopicClosed } from './methods/forums/toggle-forum-topic-closed'
|
||||
import { toggleForumTopicPinned } from './methods/forums/toggle-forum-topic-pinned'
|
||||
import { toggleGeneralTopicHidden } from './methods/forums/toggle-general-topic-hidden'
|
||||
import { createInviteLink } from './methods/invite-links/create-invite-link'
|
||||
import { editInviteLink } from './methods/invite-links/edit-invite-link'
|
||||
import { exportInviteLink } from './methods/invite-links/export-invite-link'
|
||||
import { getInviteLink } from './methods/invite-links/get-invite-link'
|
||||
import { getInviteLinkMembers } from './methods/invite-links/get-invite-link-members'
|
||||
import { getInviteLinks, GetInviteLinksOffset } from './methods/invite-links/get-invite-links'
|
||||
import { getPrimaryInviteLink } from './methods/invite-links/get-primary-invite-link'
|
||||
import { hideAllJoinRequests } from './methods/invite-links/hide-all-join-requests'
|
||||
import { hideJoinRequest } from './methods/invite-links/hide-join-request'
|
||||
import { iterInviteLinkMembers } from './methods/invite-links/iter-invite-link-members'
|
||||
import { iterInviteLinks } from './methods/invite-links/iter-invite-links'
|
||||
import { revokeInviteLink } from './methods/invite-links/revoke-invite-link'
|
||||
import { closePoll } from './methods/messages/close-poll'
|
||||
import { deleteMessages, deleteMessagesById, DeleteMessagesParams } from './methods/messages/delete-messages'
|
||||
import { deleteScheduledMessages } from './methods/messages/delete-scheduled-messages'
|
||||
import { editInlineMessage } from './methods/messages/edit-inline-message'
|
||||
import { editMessage } from './methods/messages/edit-message'
|
||||
import { _findMessageInUpdate } from './methods/messages/find-in-update'
|
||||
import { ForwardMessageOptions, forwardMessages, forwardMessagesById } from './methods/messages/forward-messages'
|
||||
import { _getDiscussionMessage, getDiscussionMessage } from './methods/messages/get-discussion-message'
|
||||
import { getHistory, GetHistoryOffset } from './methods/messages/get-history'
|
||||
import { getMessageGroup } from './methods/messages/get-message-group'
|
||||
import { getMessageReactions, getMessageReactionsById } from './methods/messages/get-message-reactions'
|
||||
import { getMessages } from './methods/messages/get-messages'
|
||||
import { getMessagesUnsafe } from './methods/messages/get-messages-unsafe'
|
||||
import { getReactionUsers, GetReactionUsersOffset } from './methods/messages/get-reaction-users'
|
||||
import { getReplyTo } from './methods/messages/get-reply-to'
|
||||
import { getScheduledMessages } from './methods/messages/get-scheduled-messages'
|
||||
import { iterHistory } from './methods/messages/iter-history'
|
||||
import { iterReactionUsers } from './methods/messages/iter-reaction-users'
|
||||
import { iterSearchGlobal } from './methods/messages/iter-search-global'
|
||||
import { iterSearchMessages } from './methods/messages/iter-search-messages'
|
||||
import { _parseEntities } from './methods/messages/parse-entities'
|
||||
import { pinMessage } from './methods/messages/pin-message'
|
||||
import { readHistory } from './methods/messages/read-history'
|
||||
import { readReactions } from './methods/messages/read-reactions'
|
||||
import { searchGlobal, SearchGlobalOffset } from './methods/messages/search-global'
|
||||
import { searchMessages, SearchMessagesOffset } from './methods/messages/search-messages'
|
||||
import { answerMedia, answerMediaGroup, answerText } from './methods/messages/send-answer'
|
||||
import { commentMedia, commentMediaGroup, commentText } from './methods/messages/send-comment'
|
||||
import { CommonSendParams } from './methods/messages/send-common'
|
||||
import { sendCopy, SendCopyParams } from './methods/messages/send-copy'
|
||||
import { sendCopyGroup, SendCopyGroupParams } from './methods/messages/send-copy-group'
|
||||
import { sendMedia } from './methods/messages/send-media'
|
||||
import { sendMediaGroup } from './methods/messages/send-media-group'
|
||||
import { sendReaction } from './methods/messages/send-reaction'
|
||||
import { replyMedia, replyMediaGroup, replyText } from './methods/messages/send-reply'
|
||||
import { sendScheduled } from './methods/messages/send-scheduled'
|
||||
import { sendText } from './methods/messages/send-text'
|
||||
import { sendTyping } from './methods/messages/send-typing'
|
||||
import { sendVote } from './methods/messages/send-vote'
|
||||
import { translateMessage } from './methods/messages/translate-message'
|
||||
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 { AuthState, getAuthState } from './methods/auth/_state.js'
|
||||
import { checkPassword } from './methods/auth/check-password.js'
|
||||
import { getPasswordHint } from './methods/auth/get-password-hint.js'
|
||||
import { logOut } from './methods/auth/log-out.js'
|
||||
import { recoverPassword } from './methods/auth/recover-password.js'
|
||||
import { resendCode } from './methods/auth/resend-code.js'
|
||||
import { sendCode } from './methods/auth/send-code.js'
|
||||
import { sendRecoveryCode } from './methods/auth/send-recovery-code.js'
|
||||
import { signIn } from './methods/auth/sign-in.js'
|
||||
import { signInBot } from './methods/auth/sign-in-bot.js'
|
||||
import { start } from './methods/auth/start.js'
|
||||
import { startTest } from './methods/auth/start-test.js'
|
||||
import { answerCallbackQuery } from './methods/bots/answer-callback-query.js'
|
||||
import { answerInlineQuery } from './methods/bots/answer-inline-query.js'
|
||||
import { answerPreCheckoutQuery } from './methods/bots/answer-pre-checkout-query.js'
|
||||
import { deleteMyCommands } from './methods/bots/delete-my-commands.js'
|
||||
import { getBotInfo } from './methods/bots/get-bot-info.js'
|
||||
import { getBotMenuButton } from './methods/bots/get-bot-menu-button.js'
|
||||
import { getCallbackAnswer } from './methods/bots/get-callback-answer.js'
|
||||
import { getGameHighScores, getInlineGameHighScores } from './methods/bots/get-game-high-scores.js'
|
||||
import { getMyCommands } from './methods/bots/get-my-commands.js'
|
||||
import { setBotInfo } from './methods/bots/set-bot-info.js'
|
||||
import { setBotMenuButton } from './methods/bots/set-bot-menu-button.js'
|
||||
import { setGameScore, setInlineGameScore } from './methods/bots/set-game-score.js'
|
||||
import { setMyCommands } from './methods/bots/set-my-commands.js'
|
||||
import { setMyDefaultRights } from './methods/bots/set-my-default-rights.js'
|
||||
import { addChatMembers } from './methods/chats/add-chat-members.js'
|
||||
import { archiveChats } from './methods/chats/archive-chats.js'
|
||||
import { banChatMember } from './methods/chats/ban-chat-member.js'
|
||||
import { createChannel } from './methods/chats/create-channel.js'
|
||||
import { createGroup } from './methods/chats/create-group.js'
|
||||
import { createSupergroup } from './methods/chats/create-supergroup.js'
|
||||
import { deleteChannel } from './methods/chats/delete-channel.js'
|
||||
import { deleteChatPhoto } from './methods/chats/delete-chat-photo.js'
|
||||
import { deleteGroup } from './methods/chats/delete-group.js'
|
||||
import { deleteHistory } from './methods/chats/delete-history.js'
|
||||
import { deleteUserHistory } from './methods/chats/delete-user-history.js'
|
||||
import { editAdminRights } from './methods/chats/edit-admin-rights.js'
|
||||
import { getChat } from './methods/chats/get-chat.js'
|
||||
import { getChatEventLog } from './methods/chats/get-chat-event-log.js'
|
||||
import { getChatMember } from './methods/chats/get-chat-member.js'
|
||||
import { getChatMembers } from './methods/chats/get-chat-members.js'
|
||||
import { getChatPreview } from './methods/chats/get-chat-preview.js'
|
||||
import { getFullChat } from './methods/chats/get-full-chat.js'
|
||||
import { getNearbyChats } from './methods/chats/get-nearby-chats.js'
|
||||
import { iterChatEventLog } from './methods/chats/iter-chat-event-log.js'
|
||||
import { iterChatMembers } from './methods/chats/iter-chat-members.js'
|
||||
import { joinChat } from './methods/chats/join-chat.js'
|
||||
import { kickChatMember } from './methods/chats/kick-chat-member.js'
|
||||
import { leaveChat } from './methods/chats/leave-chat.js'
|
||||
import { markChatUnread } from './methods/chats/mark-chat-unread.js'
|
||||
import { reorderUsernames } from './methods/chats/reorder-usernames.js'
|
||||
import { restrictChatMember } from './methods/chats/restrict-chat-member.js'
|
||||
import { saveDraft } from './methods/chats/save-draft.js'
|
||||
import { setChatDefaultPermissions } from './methods/chats/set-chat-default-permissions.js'
|
||||
import { setChatDescription } from './methods/chats/set-chat-description.js'
|
||||
import { setChatPhoto } from './methods/chats/set-chat-photo.js'
|
||||
import { setChatTitle } from './methods/chats/set-chat-title.js'
|
||||
import { setChatTtl } from './methods/chats/set-chat-ttl.js'
|
||||
import { setChatUsername } from './methods/chats/set-chat-username.js'
|
||||
import { setSlowMode } from './methods/chats/set-slow-mode.js'
|
||||
import { toggleContentProtection } from './methods/chats/toggle-content-protection.js'
|
||||
import { toggleFragmentUsername } from './methods/chats/toggle-fragment-username.js'
|
||||
import { toggleJoinRequests } from './methods/chats/toggle-join-requests.js'
|
||||
import { toggleJoinToSend } from './methods/chats/toggle-join-to-send.js'
|
||||
import { unarchiveChats } from './methods/chats/unarchive-chats.js'
|
||||
import { unbanChatMember } from './methods/chats/unban-chat-member.js'
|
||||
import { addContact } from './methods/contacts/add-contact.js'
|
||||
import { deleteContacts } from './methods/contacts/delete-contacts.js'
|
||||
import { getContacts } from './methods/contacts/get-contacts.js'
|
||||
import { importContacts } from './methods/contacts/import-contacts.js'
|
||||
import { createFolder } from './methods/dialogs/create-folder.js'
|
||||
import { deleteFolder } from './methods/dialogs/delete-folder.js'
|
||||
import { editFolder } from './methods/dialogs/edit-folder.js'
|
||||
import { findFolder } from './methods/dialogs/find-folder.js'
|
||||
import { getFolders } from './methods/dialogs/get-folders.js'
|
||||
import { getPeerDialogs } from './methods/dialogs/get-peer-dialogs.js'
|
||||
import { iterDialogs } from './methods/dialogs/iter-dialogs.js'
|
||||
import { setFoldersOrder } from './methods/dialogs/set-folders-order.js'
|
||||
import { downloadAsBuffer } from './methods/files/download-buffer.js'
|
||||
import { downloadToFile } from './methods/files/download-file.js'
|
||||
import { downloadAsIterable } from './methods/files/download-iterable.js'
|
||||
import { downloadAsStream } from './methods/files/download-stream.js'
|
||||
import { _normalizeInputFile } from './methods/files/normalize-input-file.js'
|
||||
import { _normalizeInputMedia } from './methods/files/normalize-input-media.js'
|
||||
import { uploadFile } from './methods/files/upload-file.js'
|
||||
import { uploadMedia } from './methods/files/upload-media.js'
|
||||
import { createForumTopic } from './methods/forums/create-forum-topic.js'
|
||||
import { deleteForumTopicHistory } from './methods/forums/delete-forum-topic-history.js'
|
||||
import { editForumTopic } from './methods/forums/edit-forum-topic.js'
|
||||
import { getForumTopics, GetForumTopicsOffset } from './methods/forums/get-forum-topics.js'
|
||||
import { getForumTopicsById } from './methods/forums/get-forum-topics-by-id.js'
|
||||
import { iterForumTopics } from './methods/forums/iter-forum-topics.js'
|
||||
import { reorderPinnedForumTopics } from './methods/forums/reorder-pinned-forum-topics.js'
|
||||
import { toggleForum } from './methods/forums/toggle-forum.js'
|
||||
import { toggleForumTopicClosed } from './methods/forums/toggle-forum-topic-closed.js'
|
||||
import { toggleForumTopicPinned } from './methods/forums/toggle-forum-topic-pinned.js'
|
||||
import { toggleGeneralTopicHidden } from './methods/forums/toggle-general-topic-hidden.js'
|
||||
import { createInviteLink } from './methods/invite-links/create-invite-link.js'
|
||||
import { editInviteLink } from './methods/invite-links/edit-invite-link.js'
|
||||
import { exportInviteLink } from './methods/invite-links/export-invite-link.js'
|
||||
import { getInviteLink } from './methods/invite-links/get-invite-link.js'
|
||||
import { getInviteLinkMembers } from './methods/invite-links/get-invite-link-members.js'
|
||||
import { getInviteLinks, GetInviteLinksOffset } from './methods/invite-links/get-invite-links.js'
|
||||
import { getPrimaryInviteLink } from './methods/invite-links/get-primary-invite-link.js'
|
||||
import { hideAllJoinRequests } from './methods/invite-links/hide-all-join-requests.js'
|
||||
import { hideJoinRequest } from './methods/invite-links/hide-join-request.js'
|
||||
import { iterInviteLinkMembers } from './methods/invite-links/iter-invite-link-members.js'
|
||||
import { iterInviteLinks } from './methods/invite-links/iter-invite-links.js'
|
||||
import { revokeInviteLink } from './methods/invite-links/revoke-invite-link.js'
|
||||
import { closePoll } from './methods/messages/close-poll.js'
|
||||
import { deleteMessages, deleteMessagesById, DeleteMessagesParams } from './methods/messages/delete-messages.js'
|
||||
import { deleteScheduledMessages } from './methods/messages/delete-scheduled-messages.js'
|
||||
import { editInlineMessage } from './methods/messages/edit-inline-message.js'
|
||||
import { editMessage } from './methods/messages/edit-message.js'
|
||||
import { ForwardMessageOptions, forwardMessages, forwardMessagesById } from './methods/messages/forward-messages.js'
|
||||
import { getDiscussionMessage } from './methods/messages/get-discussion-message.js'
|
||||
import { getHistory, GetHistoryOffset } from './methods/messages/get-history.js'
|
||||
import { getMessageGroup } from './methods/messages/get-message-group.js'
|
||||
import { getMessageReactions, getMessageReactionsById } from './methods/messages/get-message-reactions.js'
|
||||
import { getMessages } from './methods/messages/get-messages.js'
|
||||
import { getMessagesUnsafe } from './methods/messages/get-messages-unsafe.js'
|
||||
import { getReactionUsers, GetReactionUsersOffset } from './methods/messages/get-reaction-users.js'
|
||||
import { getReplyTo } from './methods/messages/get-reply-to.js'
|
||||
import { getScheduledMessages } from './methods/messages/get-scheduled-messages.js'
|
||||
import { iterHistory } from './methods/messages/iter-history.js'
|
||||
import { iterReactionUsers } from './methods/messages/iter-reaction-users.js'
|
||||
import { iterSearchGlobal } from './methods/messages/iter-search-global.js'
|
||||
import { iterSearchMessages } from './methods/messages/iter-search-messages.js'
|
||||
import { pinMessage } from './methods/messages/pin-message.js'
|
||||
import { readHistory } from './methods/messages/read-history.js'
|
||||
import { readReactions } from './methods/messages/read-reactions.js'
|
||||
import { searchGlobal, SearchGlobalOffset } from './methods/messages/search-global.js'
|
||||
import { searchMessages, SearchMessagesOffset } from './methods/messages/search-messages.js'
|
||||
import { answerMedia, answerMediaGroup, answerText } from './methods/messages/send-answer.js'
|
||||
import { commentMedia, commentMediaGroup, commentText } from './methods/messages/send-comment.js'
|
||||
import { CommonSendParams } from './methods/messages/send-common.js'
|
||||
import { sendCopy, SendCopyParams } from './methods/messages/send-copy.js'
|
||||
import { sendCopyGroup, SendCopyGroupParams } from './methods/messages/send-copy-group.js'
|
||||
import { sendMedia } from './methods/messages/send-media.js'
|
||||
import { sendMediaGroup } from './methods/messages/send-media-group.js'
|
||||
import { sendReaction } from './methods/messages/send-reaction.js'
|
||||
import { replyMedia, replyMediaGroup, replyText } from './methods/messages/send-reply.js'
|
||||
import { sendScheduled } from './methods/messages/send-scheduled.js'
|
||||
import { sendText } from './methods/messages/send-text.js'
|
||||
import { sendTyping } from './methods/messages/send-typing.js'
|
||||
import { sendVote } from './methods/messages/send-vote.js'
|
||||
import { translateMessage } from './methods/messages/translate-message.js'
|
||||
import { translateText } from './methods/messages/translate-text.js'
|
||||
import { unpinAllMessages } from './methods/messages/unpin-all-messages.js'
|
||||
import { unpinMessage } from './methods/messages/unpin-message.js'
|
||||
import { initTakeoutSession } from './methods/misc/init-takeout-session.js'
|
||||
import { _normalizePrivacyRules } from './methods/misc/normalize-privacy-rules.js'
|
||||
import {
|
||||
getParseMode,
|
||||
registerParseMode,
|
||||
setDefaultParseMode,
|
||||
unregisterParseMode,
|
||||
} from './methods/parse-modes/parse-modes'
|
||||
import { changeCloudPassword } from './methods/password/change-cloud-password'
|
||||
import { enableCloudPassword } from './methods/password/enable-cloud-password'
|
||||
import { cancelPasswordEmail, resendPasswordEmail, verifyPasswordEmail } from './methods/password/password-email'
|
||||
import { removeCloudPassword } from './methods/password/remove-cloud-password'
|
||||
import { addStickerToSet } from './methods/stickers/add-sticker-to-set'
|
||||
import { createStickerSet } from './methods/stickers/create-sticker-set'
|
||||
import { deleteStickerFromSet } from './methods/stickers/delete-sticker-from-set'
|
||||
import { getCustomEmojis, getCustomEmojisFromMessages } from './methods/stickers/get-custom-emojis'
|
||||
import { getInstalledStickers } from './methods/stickers/get-installed-stickers'
|
||||
import { getStickerSet } from './methods/stickers/get-sticker-set'
|
||||
import { moveStickerInSet } from './methods/stickers/move-sticker-in-set'
|
||||
import { setChatStickerSet } from './methods/stickers/set-chat-sticker-set'
|
||||
import { setStickerSetThumb } from './methods/stickers/set-sticker-set-thumb'
|
||||
import { applyBoost } from './methods/stories/apply-boost'
|
||||
import { canApplyBoost, CanApplyBoostResult } from './methods/stories/can-apply-boost'
|
||||
import { canSendStory, CanSendStoryResult } from './methods/stories/can-send-story'
|
||||
import { deleteStories } from './methods/stories/delete-stories'
|
||||
import { editStory } from './methods/stories/edit-story'
|
||||
import { _findStoryInUpdate } from './methods/stories/find-in-update'
|
||||
import { getAllStories } from './methods/stories/get-all-stories'
|
||||
import { getBoostStats } from './methods/stories/get-boost-stats'
|
||||
import { getBoosters } from './methods/stories/get-boosters'
|
||||
import { getPeerStories } from './methods/stories/get-peer-stories'
|
||||
import { getProfileStories } from './methods/stories/get-profile-stories'
|
||||
import { getStoriesById } from './methods/stories/get-stories-by-id'
|
||||
import { getStoriesInteractions } from './methods/stories/get-stories-interactions'
|
||||
import { getStoryLink } from './methods/stories/get-story-link'
|
||||
import { getStoryViewers } from './methods/stories/get-story-viewers'
|
||||
import { hideMyStoriesViews } from './methods/stories/hide-my-stories-views'
|
||||
import { incrementStoriesViews } from './methods/stories/increment-stories-views'
|
||||
import { iterAllStories } from './methods/stories/iter-all-stories'
|
||||
import { iterBoosters } from './methods/stories/iter-boosters'
|
||||
import { iterProfileStories } from './methods/stories/iter-profile-stories'
|
||||
import { iterStoryViewers } from './methods/stories/iter-story-viewers'
|
||||
import { readStories } from './methods/stories/read-stories'
|
||||
import { reportStory } from './methods/stories/report-story'
|
||||
import { sendStory } from './methods/stories/send-story'
|
||||
import { sendStoryReaction } from './methods/stories/send-story-reaction'
|
||||
import { togglePeerStoriesArchived } from './methods/stories/toggle-peer-stories-archived'
|
||||
import { toggleStoriesPinned } from './methods/stories/toggle-stories-pinned'
|
||||
import { enableUpdatesProcessing, makeParsedUpdateHandler, ParsedUpdateHandlerParams } from './methods/updates'
|
||||
} from './methods/parse-modes/parse-modes.js'
|
||||
import { changeCloudPassword } from './methods/password/change-cloud-password.js'
|
||||
import { enableCloudPassword } from './methods/password/enable-cloud-password.js'
|
||||
import { cancelPasswordEmail, resendPasswordEmail, verifyPasswordEmail } from './methods/password/password-email.js'
|
||||
import { removeCloudPassword } from './methods/password/remove-cloud-password.js'
|
||||
import { addStickerToSet } from './methods/stickers/add-sticker-to-set.js'
|
||||
import { createStickerSet } from './methods/stickers/create-sticker-set.js'
|
||||
import { deleteStickerFromSet } from './methods/stickers/delete-sticker-from-set.js'
|
||||
import { getCustomEmojis, getCustomEmojisFromMessages } from './methods/stickers/get-custom-emojis.js'
|
||||
import { getInstalledStickers } from './methods/stickers/get-installed-stickers.js'
|
||||
import { getStickerSet } from './methods/stickers/get-sticker-set.js'
|
||||
import { moveStickerInSet } from './methods/stickers/move-sticker-in-set.js'
|
||||
import { setChatStickerSet } from './methods/stickers/set-chat-sticker-set.js'
|
||||
import { setStickerSetThumb } from './methods/stickers/set-sticker-set-thumb.js'
|
||||
import { applyBoost } from './methods/stories/apply-boost.js'
|
||||
import { canApplyBoost, CanApplyBoostResult } from './methods/stories/can-apply-boost.js'
|
||||
import { canSendStory, CanSendStoryResult } from './methods/stories/can-send-story.js'
|
||||
import { deleteStories } from './methods/stories/delete-stories.js'
|
||||
import { editStory } from './methods/stories/edit-story.js'
|
||||
import { getAllStories } from './methods/stories/get-all-stories.js'
|
||||
import { getBoostStats } from './methods/stories/get-boost-stats.js'
|
||||
import { getBoosters } from './methods/stories/get-boosters.js'
|
||||
import { getPeerStories } from './methods/stories/get-peer-stories.js'
|
||||
import { getProfileStories } from './methods/stories/get-profile-stories.js'
|
||||
import { getStoriesById } from './methods/stories/get-stories-by-id.js'
|
||||
import { getStoriesInteractions } from './methods/stories/get-stories-interactions.js'
|
||||
import { getStoryLink } from './methods/stories/get-story-link.js'
|
||||
import { getStoryViewers } from './methods/stories/get-story-viewers.js'
|
||||
import { hideMyStoriesViews } from './methods/stories/hide-my-stories-views.js'
|
||||
import { incrementStoriesViews } from './methods/stories/increment-stories-views.js'
|
||||
import { iterAllStories } from './methods/stories/iter-all-stories.js'
|
||||
import { iterBoosters } from './methods/stories/iter-boosters.js'
|
||||
import { iterProfileStories } from './methods/stories/iter-profile-stories.js'
|
||||
import { iterStoryViewers } from './methods/stories/iter-story-viewers.js'
|
||||
import { readStories } from './methods/stories/read-stories.js'
|
||||
import { reportStory } from './methods/stories/report-story.js'
|
||||
import { sendStory } from './methods/stories/send-story.js'
|
||||
import { sendStoryReaction } from './methods/stories/send-story-reaction.js'
|
||||
import { togglePeerStoriesArchived } from './methods/stories/toggle-peer-stories-archived.js'
|
||||
import { toggleStoriesPinned } from './methods/stories/toggle-stories-pinned.js'
|
||||
import { enableUpdatesProcessing, makeParsedUpdateHandler, ParsedUpdateHandlerParams } from './methods/updates/index.js'
|
||||
import {
|
||||
catchUp,
|
||||
enableRps,
|
||||
|
@ -227,27 +211,28 @@ import {
|
|||
getCurrentRpsProcessing,
|
||||
startUpdatesLoop,
|
||||
stopUpdatesLoop,
|
||||
} from './methods/updates/manager'
|
||||
import { blockUser } from './methods/users/block-user'
|
||||
import { deleteProfilePhotos } from './methods/users/delete-profile-photos'
|
||||
import { editCloseFriends, editCloseFriendsRaw } from './methods/users/edit-close-friends'
|
||||
import { getCommonChats } from './methods/users/get-common-chats'
|
||||
import { getGlobalTtl } from './methods/users/get-global-ttl'
|
||||
import { getMe } from './methods/users/get-me'
|
||||
import { getMyUsername } from './methods/users/get-my-username'
|
||||
import { getProfilePhoto } from './methods/users/get-profile-photo'
|
||||
import { getProfilePhotos } from './methods/users/get-profile-photos'
|
||||
import { getUsers } from './methods/users/get-users'
|
||||
import { iterProfilePhotos } from './methods/users/iter-profile-photos'
|
||||
import { resolvePeer } from './methods/users/resolve-peer'
|
||||
import { resolvePeerMany } from './methods/users/resolve-peer-many'
|
||||
import { setEmojiStatus } from './methods/users/set-emoji-status'
|
||||
import { setGlobalTtl } from './methods/users/set-global-ttl'
|
||||
import { setOffline } from './methods/users/set-offline'
|
||||
import { setProfilePhoto } from './methods/users/set-profile-photo'
|
||||
import { setUsername } from './methods/users/set-username'
|
||||
import { unblockUser } from './methods/users/unblock-user'
|
||||
import { updateProfile } from './methods/users/update-profile'
|
||||
} from './methods/updates/manager.js'
|
||||
import { blockUser } from './methods/users/block-user.js'
|
||||
import { deleteProfilePhotos } from './methods/users/delete-profile-photos.js'
|
||||
import { editCloseFriends, editCloseFriendsRaw } from './methods/users/edit-close-friends.js'
|
||||
import { getCommonChats } from './methods/users/get-common-chats.js'
|
||||
import { getGlobalTtl } from './methods/users/get-global-ttl.js'
|
||||
import { getMe } from './methods/users/get-me.js'
|
||||
import { getMyUsername } from './methods/users/get-my-username.js'
|
||||
import { getProfilePhoto } from './methods/users/get-profile-photo.js'
|
||||
import { getProfilePhotos } from './methods/users/get-profile-photos.js'
|
||||
import { getUsers } from './methods/users/get-users.js'
|
||||
import { iterProfilePhotos } from './methods/users/iter-profile-photos.js'
|
||||
import { resolvePeer } from './methods/users/resolve-peer.js'
|
||||
import { resolvePeerMany } from './methods/users/resolve-peer-many.js'
|
||||
import { setEmojiStatus } from './methods/users/set-emoji-status.js'
|
||||
import { setGlobalTtl } from './methods/users/set-global-ttl.js'
|
||||
import { setOffline } from './methods/users/set-offline.js'
|
||||
import { setProfilePhoto } from './methods/users/set-profile-photo.js'
|
||||
import { setUsername } from './methods/users/set-username.js'
|
||||
import { unblockUser } from './methods/users/unblock-user.js'
|
||||
import { updateProfile } from './methods/users/update-profile.js'
|
||||
import { Conversation } from './types/conversation.js'
|
||||
import {
|
||||
AllStories,
|
||||
ArrayPaginated,
|
||||
|
@ -323,8 +308,7 @@ import {
|
|||
User,
|
||||
UserStatusUpdate,
|
||||
UserTypingUpdate,
|
||||
} from './types'
|
||||
import { Conversation } from './types/conversation'
|
||||
} from './types/index.js'
|
||||
|
||||
// from methods/_init.ts
|
||||
interface TelegramClientOptions extends BaseTelegramClientOptions {
|
||||
|
@ -484,8 +468,6 @@ export interface TelegramClient extends BaseTelegramClient {
|
|||
on(name: 'delete_story', handler: (upd: DeleteStoryUpdate) => void): this
|
||||
|
||||
getAuthState(): AuthState
|
||||
|
||||
_onAuthorization(auth: tl.auth.TypeAuthorization, bot?: boolean): User
|
||||
/**
|
||||
* Check your Two-Step verification password and log in
|
||||
*
|
||||
|
@ -928,7 +910,7 @@ export interface TelegramClient extends BaseTelegramClient {
|
|||
message: number
|
||||
|
||||
/** Data contained in the button */
|
||||
data: string | Buffer
|
||||
data: string | Uint8Array
|
||||
|
||||
/**
|
||||
* Timeout for the query in ms.
|
||||
|
@ -994,10 +976,6 @@ export interface TelegramClient extends BaseTelegramClient {
|
|||
*/
|
||||
langCode?: string
|
||||
}): 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)
|
||||
* **Available**: ✅ both users and bots
|
||||
|
@ -1997,8 +1975,6 @@ export interface TelegramClient extends BaseTelegramClient {
|
|||
*
|
||||
*/
|
||||
getFolders(): Promise<tl.TypeDialogFilter[]>
|
||||
|
||||
_normalizeInputFolder(folder: InputDialogFolder): Promise<tl.TypeDialogFilter>
|
||||
/**
|
||||
* Get dialogs with certain peers.
|
||||
*
|
||||
|
@ -2135,7 +2111,7 @@ export interface TelegramClient extends BaseTelegramClient {
|
|||
*
|
||||
* @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).
|
||||
* Promise will resolve once the download is complete.
|
||||
|
@ -2155,7 +2131,7 @@ export interface TelegramClient extends BaseTelegramClient {
|
|||
*
|
||||
* @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,
|
||||
* streaming file contents.
|
||||
|
@ -2165,16 +2141,6 @@ export interface TelegramClient extends BaseTelegramClient {
|
|||
* @param params File download parameters
|
||||
*/
|
||||
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`,
|
||||
* uploading it if needed.
|
||||
|
@ -3001,8 +2967,6 @@ export interface TelegramClient extends BaseTelegramClient {
|
|||
shouldDispatch?: true
|
||||
},
|
||||
): Promise<Message>
|
||||
|
||||
_findMessageInUpdate(res: tl.TypeUpdates, isEdit?: boolean, noDispatch?: boolean): Message
|
||||
/**
|
||||
* Forward one or more messages by their IDs.
|
||||
* You can forward no more than 100 messages at once.
|
||||
|
@ -3037,8 +3001,6 @@ export interface TelegramClient extends BaseTelegramClient {
|
|||
messages: Message[]
|
||||
},
|
||||
): Promise<Message[]>
|
||||
|
||||
_getDiscussionMessage(peer: InputPeerLike, message: number): Promise<[tl.TypeInputPeer, number]>
|
||||
// public version of the same method because why not
|
||||
/**
|
||||
* Get discussion message for some channel post.
|
||||
|
@ -3356,12 +3318,6 @@ export interface TelegramClient extends BaseTelegramClient {
|
|||
chunkSize?: number
|
||||
},
|
||||
): 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.
|
||||
*
|
||||
|
@ -3856,7 +3812,7 @@ export interface TelegramClient extends BaseTelegramClient {
|
|||
* representing them. In case of indexes, the poll will first
|
||||
* be requested from the server.
|
||||
*/
|
||||
options: null | MaybeArray<number | Buffer>
|
||||
options: null | MaybeArray<number | Uint8Array>
|
||||
},
|
||||
): Promise<Poll>
|
||||
/**
|
||||
|
@ -3928,8 +3884,6 @@ export interface TelegramClient extends BaseTelegramClient {
|
|||
*
|
||||
*/
|
||||
_normalizePrivacyRules(rules: InputPrivacyRule[]): Promise<tl.TypeInputPrivacyRule[]>
|
||||
|
||||
getParseModesState(): ParseModesState
|
||||
/**
|
||||
* Register a given {@link IMessageEntityParser} as a parse mode
|
||||
* for messages. When this method is first called, given parse
|
||||
|
@ -4344,8 +4298,6 @@ export interface TelegramClient extends BaseTelegramClient {
|
|||
*/
|
||||
privacyRules?: InputPrivacyRule[]
|
||||
}): Promise<Story>
|
||||
|
||||
_findStoryInUpdate(res: tl.TypeUpdates): Story
|
||||
/**
|
||||
* Get all stories (e.g. to load the top bar)
|
||||
* **Available**: ✅ both users and bots
|
||||
|
@ -5148,7 +5100,6 @@ export class TelegramClient extends BaseTelegramClient {
|
|||
}
|
||||
}
|
||||
getAuthState = getAuthState.bind(null, this)
|
||||
_onAuthorization = _onAuthorization.bind(null, this)
|
||||
checkPassword = checkPassword.bind(null, this)
|
||||
getPasswordHint = getPasswordHint.bind(null, this)
|
||||
logOut = logOut.bind(null, this)
|
||||
|
@ -5169,7 +5120,6 @@ export class TelegramClient extends BaseTelegramClient {
|
|||
getGameHighScores = getGameHighScores.bind(null, this)
|
||||
getInlineGameHighScores = getInlineGameHighScores.bind(null, this)
|
||||
getMyCommands = getMyCommands.bind(null, this)
|
||||
_normalizeCommandScope = _normalizeCommandScope.bind(null, this)
|
||||
setBotInfo = setBotInfo.bind(null, this)
|
||||
setBotMenuButton = setBotMenuButton.bind(null, this)
|
||||
setGameScore = setGameScore.bind(null, this)
|
||||
|
@ -5228,7 +5178,6 @@ export class TelegramClient extends BaseTelegramClient {
|
|||
editFolder = editFolder.bind(null, this)
|
||||
findFolder = findFolder.bind(null, this)
|
||||
getFolders = getFolders.bind(null, this)
|
||||
_normalizeInputFolder = _normalizeInputFolder.bind(null, this)
|
||||
getPeerDialogs = getPeerDialogs.bind(null, this)
|
||||
iterDialogs = iterDialogs.bind(null, this)
|
||||
setFoldersOrder = setFoldersOrder.bind(null, this)
|
||||
|
@ -5236,7 +5185,6 @@ export class TelegramClient extends BaseTelegramClient {
|
|||
downloadToFile = downloadToFile.bind(null, this)
|
||||
downloadAsIterable = downloadAsIterable.bind(null, this)
|
||||
downloadAsStream = downloadAsStream.bind(null, this)
|
||||
_normalizeFileToDocument = _normalizeFileToDocument.bind(null, this)
|
||||
_normalizeInputFile = _normalizeInputFile.bind(null, this)
|
||||
_normalizeInputMedia = _normalizeInputMedia.bind(null, this)
|
||||
uploadFile = uploadFile.bind(null, this)
|
||||
|
@ -5270,10 +5218,8 @@ export class TelegramClient extends BaseTelegramClient {
|
|||
deleteScheduledMessages = deleteScheduledMessages.bind(null, this)
|
||||
editInlineMessage = editInlineMessage.bind(null, this)
|
||||
editMessage = editMessage.bind(null, this)
|
||||
_findMessageInUpdate = _findMessageInUpdate.bind(null, this)
|
||||
forwardMessagesById = forwardMessagesById.bind(null, this)
|
||||
forwardMessages = forwardMessages.bind(null, this)
|
||||
_getDiscussionMessage = _getDiscussionMessage.bind(null, this)
|
||||
getDiscussionMessage = getDiscussionMessage.bind(null, this)
|
||||
getHistory = getHistory.bind(null, this)
|
||||
getMessageGroup = getMessageGroup.bind(null, this)
|
||||
|
@ -5288,7 +5234,6 @@ export class TelegramClient extends BaseTelegramClient {
|
|||
iterReactionUsers = iterReactionUsers.bind(null, this)
|
||||
iterSearchGlobal = iterSearchGlobal.bind(null, this)
|
||||
iterSearchMessages = iterSearchMessages.bind(null, this)
|
||||
_parseEntities = _parseEntities.bind(null, this)
|
||||
pinMessage = pinMessage.bind(null, this)
|
||||
readHistory = readHistory.bind(null, this)
|
||||
readReactions = readReactions.bind(null, this)
|
||||
|
@ -5318,7 +5263,6 @@ export class TelegramClient extends BaseTelegramClient {
|
|||
unpinMessage = unpinMessage.bind(null, this)
|
||||
initTakeoutSession = initTakeoutSession.bind(null, this)
|
||||
_normalizePrivacyRules = _normalizePrivacyRules.bind(null, this)
|
||||
getParseModesState = getParseModesState.bind(null, this)
|
||||
registerParseMode = registerParseMode.bind(null, this)
|
||||
unregisterParseMode = unregisterParseMode.bind(null, this)
|
||||
getParseMode = getParseMode.bind(null, this)
|
||||
|
@ -5344,7 +5288,6 @@ export class TelegramClient extends BaseTelegramClient {
|
|||
canSendStory = canSendStory.bind(null, this)
|
||||
deleteStories = deleteStories.bind(null, this)
|
||||
editStory = editStory.bind(null, this)
|
||||
_findStoryInUpdate = _findStoryInUpdate.bind(null, this)
|
||||
getAllStories = getAllStories.bind(null, this)
|
||||
getBoostStats = getBoostStats.bind(null, this)
|
||||
getBoosters = getBoosters.bind(null, this)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
export * from './client'
|
||||
export * from './types'
|
||||
export * from './utils/peer-utils'
|
||||
export { createDummyUpdate } from './utils/updates-utils'
|
||||
export * from './client.js'
|
||||
export * from './types/index.js'
|
||||
export * from './utils/peer-utils.js'
|
||||
export { createDummyUpdate } from './utils/updates-utils.js'
|
||||
export * from '@mtcute/core'
|
||||
|
|
|
@ -24,7 +24,7 @@ Example:
|
|||
|
||||
```typescript
|
||||
// @copy
|
||||
import { Something } from '../../somewhere'
|
||||
import { Something } from '../../somewhere.js'
|
||||
|
||||
// @copy
|
||||
interface SomeGreatInterface { ... }
|
||||
|
|
|
@ -83,4 +83,4 @@ import {
|
|||
User,
|
||||
UserStatusUpdate,
|
||||
UserTypingUpdate,
|
||||
} from '../types'
|
||||
} from '../types/index.js'
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
import { BaseTelegramClientOptions } from '@mtcute/core'
|
||||
|
||||
import { TelegramClient } from '../client'
|
||||
import { TelegramClient } from '../client.js'
|
||||
// @copy
|
||||
import { Conversation } from '../types/conversation'
|
||||
import { Conversation } from '../types/conversation.js'
|
||||
// @copy
|
||||
import { start } from './auth/start'
|
||||
import { start } from './auth/start.js'
|
||||
// @copy
|
||||
import { enableUpdatesProcessing, makeParsedUpdateHandler, ParsedUpdateHandlerParams } from './updates'
|
||||
import { enableUpdatesProcessing, makeParsedUpdateHandler, ParsedUpdateHandlerParams } from './updates/index.js'
|
||||
|
||||
// @copy
|
||||
interface TelegramClientOptions extends BaseTelegramClientOptions {
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
/* eslint-disable no-inner-declarations */
|
||||
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')
|
||||
/**
|
||||
* @internal
|
||||
* @exported
|
||||
*/
|
||||
/** @exported */
|
||||
export interface AuthState {
|
||||
// local copy of "self" in storage,
|
||||
// so we can use it w/out relying on storage.
|
||||
|
@ -20,7 +17,6 @@ export interface AuthState {
|
|||
selfChanged?: boolean
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function getAuthState(client: BaseTelegramClient): AuthState {
|
||||
// eslint-disable-next-line
|
||||
let state: AuthState = (client as any)[STATE_SYMBOL]
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { BaseTelegramClient } from '@mtcute/core'
|
||||
import { computeSrpParams } from '@mtcute/core/utils'
|
||||
import { computeSrpParams } from '@mtcute/core/utils.js'
|
||||
|
||||
import { User } from '../../types'
|
||||
import { _onAuthorization } from './_state'
|
||||
import { User } from '../../types/index.js'
|
||||
import { _onAuthorization } from './_state.js'
|
||||
|
||||
/**
|
||||
* Check your Two-Step verification password and log in
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
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.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { BaseTelegramClient } from '@mtcute/core'
|
||||
|
||||
import { User } from '../../types'
|
||||
import { _onAuthorization } from './_state'
|
||||
import { User } from '../../types/index.js'
|
||||
import { _onAuthorization } from './_state.js'
|
||||
|
||||
/**
|
||||
* Recover your password with a recovery code and log in.
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { BaseTelegramClient } from '@mtcute/core'
|
||||
import { assertTypeIs } from '@mtcute/core/utils'
|
||||
import { assertTypeIs } from '@mtcute/core/utils.js'
|
||||
|
||||
import { SentCode } from '../../types'
|
||||
import { normalizePhoneNumber } from '../../utils/misc-utils'
|
||||
import { SentCode } from '../../types/index.js'
|
||||
import { normalizePhoneNumber } from '../../utils/misc-utils.js'
|
||||
|
||||
/**
|
||||
* Re-send the confirmation code using a different type.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { BaseTelegramClient } from '@mtcute/core'
|
||||
|
||||
import { User } from '../../types'
|
||||
import { start } from './start'
|
||||
import { User } from '../../types/index.js'
|
||||
import { start } from './start.js'
|
||||
|
||||
/**
|
||||
* Simple wrapper that calls {@link start} and then
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { BaseTelegramClient } from '@mtcute/core'
|
||||
import { assertTypeIs } from '@mtcute/core/utils'
|
||||
import { assertTypeIs } from '@mtcute/core/utils.js'
|
||||
|
||||
import { SentCode } from '../../types'
|
||||
import { normalizePhoneNumber } from '../../utils/misc-utils'
|
||||
import { SentCode } from '../../types/index.js'
|
||||
import { normalizePhoneNumber } from '../../utils/misc-utils.js'
|
||||
|
||||
/**
|
||||
* Send the confirmation code to the given phone number
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { BaseTelegramClient } from '@mtcute/core'
|
||||
|
||||
import { User } from '../../types'
|
||||
import { _onAuthorization } from './_state'
|
||||
import { User } from '../../types/index.js'
|
||||
import { _onAuthorization } from './_state.js'
|
||||
|
||||
/**
|
||||
* Authorize a bot using its token issued by [@BotFather](//t.me/BotFather)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { BaseTelegramClient } from '@mtcute/core'
|
||||
|
||||
import { User } from '../../types'
|
||||
import { normalizePhoneNumber } from '../../utils/misc-utils'
|
||||
import { _onAuthorization } from './_state'
|
||||
import { User } from '../../types/index.js'
|
||||
import { normalizePhoneNumber } from '../../utils/misc-utils.js'
|
||||
import { _onAuthorization } from './_state.js'
|
||||
|
||||
/**
|
||||
* Authorize a user in Telegram with a valid confirmation code.
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { BaseTelegramClient, MtArgumentError } from '@mtcute/core'
|
||||
|
||||
import { User } from '../../types'
|
||||
import { logOut } from './log-out'
|
||||
import { start } from './start'
|
||||
import { User } from '../../types/index.js'
|
||||
import { logOut } from './log-out.js'
|
||||
import { start } from './start.js'
|
||||
|
||||
/**
|
||||
* Utility function to quickly authorize on test DC
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
/* eslint-disable no-console */
|
||||
import { BaseTelegramClient, MaybeAsync, MtArgumentError, tl } from '@mtcute/core'
|
||||
|
||||
import { MaybeDynamic, SentCode, User } from '../../types'
|
||||
import { normalizePhoneNumber, resolveMaybeDynamic } from '../../utils/misc-utils'
|
||||
import { getMe } from '../users/get-me'
|
||||
import { checkPassword } from './check-password'
|
||||
import { resendCode } from './resend-code'
|
||||
import { sendCode } from './send-code'
|
||||
import { signIn } from './sign-in'
|
||||
import { signInBot } from './sign-in-bot'
|
||||
import { MaybeDynamic, SentCode, User } from '../../types/index.js'
|
||||
import { normalizePhoneNumber, resolveMaybeDynamic } from '../../utils/misc-utils.js'
|
||||
import { getMe } from '../users/get-me.js'
|
||||
import { checkPassword } from './check-password.js'
|
||||
import { resendCode } from './resend-code.js'
|
||||
import { sendCode } from './send-code.js'
|
||||
import { signIn } from './sign-in.js'
|
||||
import { signInBot } from './sign-in-bot.js'
|
||||
|
||||
// @manual
|
||||
// @available=both
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
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.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
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.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
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.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { BaseTelegramClient, tl } from '@mtcute/core'
|
||||
|
||||
import { BotCommands } from '../../types'
|
||||
import { _normalizeCommandScope } from './normalize-command-scope'
|
||||
import { BotCommands } from '../../types/index.js'
|
||||
import { _normalizeCommandScope } from './normalize-command-scope.js'
|
||||
|
||||
/**
|
||||
* Delete commands for the current bot and the given scope.
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { BaseTelegramClient, tl } from '@mtcute/core'
|
||||
|
||||
import { InputPeerLike } from '../../types'
|
||||
import { normalizeToInputUser } from '../../utils/peer-utils'
|
||||
import { resolvePeer } from '../users/resolve-peer'
|
||||
import { InputPeerLike } from '../../types/index.js'
|
||||
import { normalizeToInputUser } from '../../utils/peer-utils.js'
|
||||
import { resolvePeer } from '../users/resolve-peer.js'
|
||||
|
||||
/**
|
||||
* Gets information about a bot the current uzer owns (or the current bot)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { BaseTelegramClient, tl } from '@mtcute/core'
|
||||
|
||||
import { InputPeerLike } from '../../types'
|
||||
import { normalizeToInputUser } from '../../utils/peer-utils'
|
||||
import { resolvePeer } from '../users/resolve-peer'
|
||||
import { InputPeerLike } from '../../types/index.js'
|
||||
import { normalizeToInputUser } from '../../utils/peer-utils.js'
|
||||
import { resolvePeer } from '../users/resolve-peer.js'
|
||||
|
||||
/**
|
||||
* Fetches the menu button set for the given user.
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
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 { resolvePeer } from '../users/resolve-peer'
|
||||
import { InputPeerLike } from '../../types/index.js'
|
||||
import { resolvePeer } from '../users/resolve-peer.js'
|
||||
|
||||
/**
|
||||
* Request a callback answer from a bot,
|
||||
|
@ -20,7 +20,7 @@ export async function getCallbackAnswer(
|
|||
message: number
|
||||
|
||||
/** Data contained in the button */
|
||||
data: string | Buffer
|
||||
data: string | Uint8Array
|
||||
|
||||
/**
|
||||
* Timeout for the query in ms.
|
||||
|
@ -57,7 +57,7 @@ export async function getCallbackAnswer(
|
|||
_: 'messages.getBotCallbackAnswer',
|
||||
peer: await resolvePeer(client, chatId),
|
||||
msgId: message,
|
||||
data: typeof data === 'string' ? Buffer.from(data) : data,
|
||||
data: typeof data === 'string' ? utf8EncodeToBuffer(data) : data,
|
||||
password,
|
||||
game: game,
|
||||
},
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { BaseTelegramClient, tl } from '@mtcute/core'
|
||||
|
||||
import { GameHighScore, InputMessageId, InputPeerLike, normalizeInputMessageId, PeersIndex } from '../../types'
|
||||
import { normalizeInlineId } from '../../utils/inline-utils'
|
||||
import { normalizeToInputUser } from '../../utils/peer-utils'
|
||||
import { resolvePeer } from '../users/resolve-peer'
|
||||
import { GameHighScore, InputMessageId, InputPeerLike, normalizeInputMessageId, PeersIndex } from '../../types/index.js'
|
||||
import { normalizeInlineId } from '../../utils/inline-utils.js'
|
||||
import { normalizeToInputUser } from '../../utils/peer-utils.js'
|
||||
import { resolvePeer } from '../users/resolve-peer.js'
|
||||
|
||||
/**
|
||||
* Get high scores of a game
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { BaseTelegramClient, tl } from '@mtcute/core'
|
||||
|
||||
import { BotCommands } from '../../types'
|
||||
import { _normalizeCommandScope } from './normalize-command-scope'
|
||||
import { BotCommands } from '../../types/index.js'
|
||||
import { _normalizeCommandScope } from './normalize-command-scope.js'
|
||||
|
||||
/**
|
||||
* Get a list of current bot's commands for the given command scope
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { assertNever, BaseTelegramClient, tl } from '@mtcute/core'
|
||||
|
||||
import { BotCommands } from '../../types'
|
||||
import { normalizeToInputUser } from '../../utils/peer-utils'
|
||||
import { resolvePeer } from '../users/resolve-peer'
|
||||
import { BotCommands } from '../../types/index.js'
|
||||
import { normalizeToInputUser } from '../../utils/peer-utils.js'
|
||||
import { resolvePeer } from '../users/resolve-peer.js'
|
||||
|
||||
/** @internal */
|
||||
export async function _normalizeCommandScope(
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { BaseTelegramClient } from '@mtcute/core'
|
||||
|
||||
import { InputPeerLike } from '../../types'
|
||||
import { normalizeToInputUser } from '../../utils/peer-utils'
|
||||
import { resolvePeer } from '../users/resolve-peer'
|
||||
import { InputPeerLike } from '../../types/index.js'
|
||||
import { normalizeToInputUser } from '../../utils/peer-utils.js'
|
||||
import { resolvePeer } from '../users/resolve-peer.js'
|
||||
|
||||
/**
|
||||
* Sets information about a bot the current uzer owns (or the current bot)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { BaseTelegramClient, tl } from '@mtcute/core'
|
||||
|
||||
import { InputPeerLike } from '../../types'
|
||||
import { normalizeToInputUser } from '../../utils/peer-utils'
|
||||
import { resolvePeer } from '../users/resolve-peer'
|
||||
import { InputPeerLike } from '../../types/index.js'
|
||||
import { normalizeToInputUser } from '../../utils/peer-utils.js'
|
||||
import { resolvePeer } from '../users/resolve-peer.js'
|
||||
|
||||
/**
|
||||
* Sets a menu button for the given user.
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { BaseTelegramClient, tl } from '@mtcute/core'
|
||||
|
||||
import { InputMessageId, InputPeerLike, Message, normalizeInputMessageId } from '../../types'
|
||||
import { normalizeInlineId } from '../../utils/inline-utils'
|
||||
import { normalizeToInputUser } from '../../utils/peer-utils'
|
||||
import { _findMessageInUpdate } from '../messages/find-in-update'
|
||||
import { resolvePeer } from '../users/resolve-peer'
|
||||
import { InputMessageId, InputPeerLike, Message, normalizeInputMessageId } from '../../types/index.js'
|
||||
import { normalizeInlineId } from '../../utils/inline-utils.js'
|
||||
import { normalizeToInputUser } from '../../utils/peer-utils.js'
|
||||
import { _findMessageInUpdate } from '../messages/find-in-update.js'
|
||||
import { resolvePeer } from '../users/resolve-peer.js'
|
||||
|
||||
/**
|
||||
* Set a score of a user in a game
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { BaseTelegramClient, tl } from '@mtcute/core'
|
||||
|
||||
import { BotCommands } from '../../types'
|
||||
import { _normalizeCommandScope } from './normalize-command-scope'
|
||||
import { BotCommands } from '../../types/index.js'
|
||||
import { _normalizeCommandScope } from './normalize-command-scope.js'
|
||||
|
||||
/**
|
||||
* Set or delete commands for the current bot and the given scope
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
import { BaseTelegramClient, MaybeArray } from '@mtcute/core'
|
||||
|
||||
import { InputPeerLike, MtInvalidPeerTypeError } from '../../types'
|
||||
import { InputPeerLike, MtInvalidPeerTypeError } from '../../types/index.js'
|
||||
import {
|
||||
isInputPeerChannel,
|
||||
isInputPeerChat,
|
||||
normalizeToInputChannel,
|
||||
normalizeToInputUser,
|
||||
} from '../../utils/peer-utils'
|
||||
import { resolvePeer } from '../users/resolve-peer'
|
||||
import { resolvePeerMany } from '../users/resolve-peer-many'
|
||||
} from '../../utils/peer-utils.js'
|
||||
import { resolvePeer } from '../users/resolve-peer.js'
|
||||
import { resolvePeerMany } from '../users/resolve-peer-many.js'
|
||||
|
||||
/**
|
||||
* Add one or more new members to a group, supergroup or channel.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { BaseTelegramClient, MaybeArray } from '@mtcute/core'
|
||||
|
||||
import { InputPeerLike } from '../../types'
|
||||
import { resolvePeerMany } from '../users/resolve-peer-many'
|
||||
import { InputPeerLike } from '../../types/index.js'
|
||||
import { resolvePeerMany } from '../users/resolve-peer-many.js'
|
||||
|
||||
/**
|
||||
* Archive one or more chats
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
import { BaseTelegramClient, MtTypeAssertionError } from '@mtcute/core'
|
||||
|
||||
import { InputPeerLike, Message, MtInvalidPeerTypeError } from '../../types'
|
||||
import { InputPeerLike, Message, MtInvalidPeerTypeError } from '../../types/index.js'
|
||||
import {
|
||||
isInputPeerChannel,
|
||||
isInputPeerChat,
|
||||
normalizeToInputChannel,
|
||||
normalizeToInputUser,
|
||||
} from '../../utils/peer-utils'
|
||||
import { _findMessageInUpdate } from '../messages/find-in-update'
|
||||
import { resolvePeer } from '../users/resolve-peer'
|
||||
} from '../../utils/peer-utils.js'
|
||||
import { _findMessageInUpdate } from '../messages/find-in-update.js'
|
||||
import { resolvePeer } from '../users/resolve-peer.js'
|
||||
|
||||
/**
|
||||
* Ban a user/channel from a legacy group, a supergroup or a channel.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { BaseTelegramClient } from '@mtcute/core'
|
||||
|
||||
import { Chat } from '../../types'
|
||||
import { assertIsUpdatesGroup } from '../../utils/updates-utils'
|
||||
import { Chat } from '../../types/index.js'
|
||||
import { assertIsUpdatesGroup } from '../../utils/updates-utils.js'
|
||||
|
||||
/**
|
||||
* Create a new broadcast channel
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { BaseTelegramClient, MaybeArray } from '@mtcute/core'
|
||||
|
||||
import { Chat, InputPeerLike } from '../../types'
|
||||
import { normalizeToInputUser } from '../../utils/peer-utils'
|
||||
import { assertIsUpdatesGroup } from '../../utils/updates-utils'
|
||||
import { resolvePeerMany } from '../users/resolve-peer-many'
|
||||
import { Chat, InputPeerLike } from '../../types/index.js'
|
||||
import { normalizeToInputUser } from '../../utils/peer-utils.js'
|
||||
import { assertIsUpdatesGroup } from '../../utils/updates-utils.js'
|
||||
import { resolvePeerMany } from '../users/resolve-peer-many.js'
|
||||
|
||||
/**
|
||||
* Create a legacy group chat
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { BaseTelegramClient } from '@mtcute/core'
|
||||
|
||||
import { Chat } from '../../types'
|
||||
import { assertIsUpdatesGroup } from '../../utils/updates-utils'
|
||||
import { Chat } from '../../types/index.js'
|
||||
import { assertIsUpdatesGroup } from '../../utils/updates-utils.js'
|
||||
|
||||
/**
|
||||
* Create a new supergroup
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { BaseTelegramClient } from '@mtcute/core'
|
||||
|
||||
import { InputPeerLike } from '../../types'
|
||||
import { normalizeToInputChannel } from '../../utils/peer-utils'
|
||||
import { resolvePeer } from '../users/resolve-peer'
|
||||
import { InputPeerLike } from '../../types/index.js'
|
||||
import { normalizeToInputChannel } from '../../utils/peer-utils.js'
|
||||
import { resolvePeer } from '../users/resolve-peer.js'
|
||||
|
||||
// @alias=deleteSupergroup
|
||||
/**
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { BaseTelegramClient } from '@mtcute/core'
|
||||
|
||||
import { InputPeerLike, MtInvalidPeerTypeError } from '../../types'
|
||||
import { isInputPeerChannel, isInputPeerChat, normalizeToInputChannel } from '../../utils/peer-utils'
|
||||
import { resolvePeer } from '../users/resolve-peer'
|
||||
import { InputPeerLike, MtInvalidPeerTypeError } from '../../types/index.js'
|
||||
import { isInputPeerChannel, isInputPeerChat, normalizeToInputChannel } from '../../utils/peer-utils.js'
|
||||
import { resolvePeer } from '../users/resolve-peer.js'
|
||||
|
||||
/**
|
||||
* Delete a chat photo
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { BaseTelegramClient } from '@mtcute/core'
|
||||
|
||||
import { InputPeerLike, MtInvalidPeerTypeError } from '../../types'
|
||||
import { isInputPeerChat } from '../../utils/peer-utils'
|
||||
import { resolvePeer } from '../users/resolve-peer'
|
||||
import { InputPeerLike, MtInvalidPeerTypeError } from '../../types/index.js'
|
||||
import { isInputPeerChat } from '../../utils/peer-utils.js'
|
||||
import { resolvePeer } from '../users/resolve-peer.js'
|
||||
|
||||
/**
|
||||
* Delete a legacy group chat for all members
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { BaseTelegramClient } from '@mtcute/core'
|
||||
|
||||
import { InputPeerLike } from '../../types'
|
||||
import { isInputPeerChannel } from '../../utils/peer-utils'
|
||||
import { createDummyUpdate } from '../../utils/updates-utils'
|
||||
import { resolvePeer } from '../users/resolve-peer'
|
||||
import { InputPeerLike } from '../../types/index.js'
|
||||
import { isInputPeerChannel } from '../../utils/peer-utils.js'
|
||||
import { createDummyUpdate } from '../../utils/updates-utils.js'
|
||||
import { resolvePeer } from '../users/resolve-peer.js'
|
||||
|
||||
/**
|
||||
* Delete communication history (for private chats and legacy groups)
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { BaseTelegramClient, tl } from '@mtcute/core'
|
||||
|
||||
import { InputPeerLike } from '../../types'
|
||||
import { normalizeToInputChannel } from '../../utils/peer-utils'
|
||||
import { createDummyUpdate } from '../../utils/updates-utils'
|
||||
import { resolvePeer } from '../users/resolve-peer'
|
||||
import { InputPeerLike } from '../../types/index.js'
|
||||
import { normalizeToInputChannel } from '../../utils/peer-utils.js'
|
||||
import { createDummyUpdate } from '../../utils/updates-utils.js'
|
||||
import { resolvePeer } from '../users/resolve-peer.js'
|
||||
|
||||
/**
|
||||
* Delete all messages of a user (or channel) in a supergroup
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { BaseTelegramClient, tl } from '@mtcute/core'
|
||||
|
||||
import { InputPeerLike } from '../../types'
|
||||
import { normalizeToInputChannel, normalizeToInputUser } from '../../utils/peer-utils'
|
||||
import { resolvePeer } from '../users/resolve-peer'
|
||||
import { InputPeerLike } from '../../types/index.js'
|
||||
import { normalizeToInputChannel, normalizeToInputUser } from '../../utils/peer-utils.js'
|
||||
import { resolvePeer } from '../users/resolve-peer.js'
|
||||
|
||||
/**
|
||||
* Edit supergroup/channel admin rights of a user.
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { BaseTelegramClient, Long, tl } from '@mtcute/core'
|
||||
|
||||
import { ChatEvent, InputPeerLike, PeersIndex } from '../../types'
|
||||
import { InputChatEventFilters, normalizeChatEventFilters } from '../../types/peers/chat-event/filters'
|
||||
import { normalizeToInputChannel, normalizeToInputUser } from '../../utils/peer-utils'
|
||||
import { resolvePeer } from '../users/resolve-peer'
|
||||
import { resolvePeerMany } from '../users/resolve-peer-many'
|
||||
import { ChatEvent, InputPeerLike, PeersIndex } from '../../types/index.js'
|
||||
import { InputChatEventFilters, normalizeChatEventFilters } from '../../types/peers/chat-event/filters.js'
|
||||
import { normalizeToInputChannel, normalizeToInputUser } from '../../utils/peer-utils.js'
|
||||
import { resolvePeer } from '../users/resolve-peer.js'
|
||||
import { resolvePeerMany } from '../users/resolve-peer-many.js'
|
||||
|
||||
/**
|
||||
* Get chat event log ("Recent actions" in official clients).
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
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 { isInputPeerChannel, isInputPeerChat, isInputPeerUser, normalizeToInputChannel } from '../../utils/peer-utils'
|
||||
import { resolvePeer } from '../users/resolve-peer'
|
||||
import { ChatMember, InputPeerLike, MtInvalidPeerTypeError, PeersIndex } from '../../types/index.js'
|
||||
import { isInputPeerChannel, isInputPeerChat, isInputPeerUser, normalizeToInputChannel } from '../../utils/peer-utils.js'
|
||||
import { resolvePeer } from '../users/resolve-peer.js'
|
||||
|
||||
/**
|
||||
* Get information about a single chat member
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
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 { makeArrayWithTotal } from '../../utils'
|
||||
import { isInputPeerChannel, isInputPeerChat, normalizeToInputChannel } from '../../utils/peer-utils'
|
||||
import { resolvePeer } from '../users/resolve-peer'
|
||||
import { ArrayWithTotal, ChatMember, InputPeerLike, MtInvalidPeerTypeError, PeersIndex } from '../../types/index.js'
|
||||
import { makeArrayWithTotal } from '../../utils/index.js'
|
||||
import { isInputPeerChannel, isInputPeerChat, normalizeToInputChannel } from '../../utils/peer-utils.js'
|
||||
import { resolvePeer } from '../users/resolve-peer.js'
|
||||
|
||||
/**
|
||||
* Get a chunk of members of some chat.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { BaseTelegramClient, MtArgumentError } from '@mtcute/core'
|
||||
|
||||
import { ChatPreview, MtPeerNotFoundError } from '../../types'
|
||||
import { INVITE_LINK_REGEX } from '../../utils/peer-utils'
|
||||
import { ChatPreview, MtPeerNotFoundError } from '../../types/index.js'
|
||||
import { INVITE_LINK_REGEX } from '../../utils/peer-utils.js'
|
||||
|
||||
/**
|
||||
* Get preview information about a private chat.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { BaseTelegramClient, MtArgumentError, tl } from '@mtcute/core'
|
||||
|
||||
import { Chat, InputPeerLike } from '../../types'
|
||||
import { Chat, InputPeerLike } from '../../types/index.js'
|
||||
import {
|
||||
INVITE_LINK_REGEX,
|
||||
isInputPeerChannel,
|
||||
|
@ -8,8 +8,8 @@ import {
|
|||
isInputPeerUser,
|
||||
normalizeToInputChannel,
|
||||
normalizeToInputUser,
|
||||
} from '../../utils/peer-utils'
|
||||
import { resolvePeer } from '../users/resolve-peer'
|
||||
} from '../../utils/peer-utils.js'
|
||||
import { resolvePeer } from '../users/resolve-peer.js'
|
||||
|
||||
// @available=both
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { BaseTelegramClient, MtArgumentError, tl } from '@mtcute/core'
|
||||
|
||||
import { Chat, InputPeerLike } from '../../types'
|
||||
import { Chat, InputPeerLike } from '../../types/index.js'
|
||||
import {
|
||||
INVITE_LINK_REGEX,
|
||||
isInputPeerChannel,
|
||||
|
@ -8,8 +8,8 @@ import {
|
|||
isInputPeerUser,
|
||||
normalizeToInputChannel,
|
||||
normalizeToInputUser,
|
||||
} from '../../utils/peer-utils'
|
||||
import { resolvePeer } from '../users/resolve-peer'
|
||||
} from '../../utils/peer-utils.js'
|
||||
import { resolvePeer } from '../users/resolve-peer.js'
|
||||
|
||||
// @available=both
|
||||
/**
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
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 { assertIsUpdatesGroup } from '../../utils/updates-utils'
|
||||
import { Chat } from '../../types/index.js'
|
||||
import { assertIsUpdatesGroup } from '../../utils/updates-utils.js'
|
||||
|
||||
/**
|
||||
* Get nearby chats
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { BaseTelegramClient, Long, tl } from '@mtcute/core'
|
||||
|
||||
import { ChatEvent, InputPeerLike } from '../../types'
|
||||
import { normalizeChatEventFilters } from '../../types/peers/chat-event/filters'
|
||||
import { normalizeToInputChannel, normalizeToInputUser } from '../../utils/peer-utils'
|
||||
import { resolvePeer } from '../users/resolve-peer'
|
||||
import { resolvePeerMany } from '../users/resolve-peer-many'
|
||||
import { getChatEventLog } from './get-chat-event-log'
|
||||
import { ChatEvent, InputPeerLike } from '../../types/index.js'
|
||||
import { normalizeChatEventFilters } from '../../types/peers/chat-event/filters.js'
|
||||
import { normalizeToInputChannel, normalizeToInputUser } from '../../utils/peer-utils.js'
|
||||
import { resolvePeer } from '../users/resolve-peer.js'
|
||||
import { resolvePeerMany } from '../users/resolve-peer-many.js'
|
||||
import { getChatEventLog } from './get-chat-event-log.js'
|
||||
|
||||
/**
|
||||
* Iterate over chat event log.
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { BaseTelegramClient } from '@mtcute/core'
|
||||
|
||||
import { ChatMember, InputPeerLike } from '../../types'
|
||||
import { isInputPeerChat } from '../../utils/peer-utils'
|
||||
import { resolvePeer } from '../users/resolve-peer'
|
||||
import { getChatMembers } from './get-chat-members'
|
||||
import { ChatMember, InputPeerLike } from '../../types/index.js'
|
||||
import { isInputPeerChat } from '../../utils/peer-utils.js'
|
||||
import { resolvePeer } from '../users/resolve-peer.js'
|
||||
import { getChatMembers } from './get-chat-members.js'
|
||||
|
||||
/**
|
||||
* Iterate through chat members
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { BaseTelegramClient } from '@mtcute/core'
|
||||
|
||||
import { Chat, InputPeerLike } from '../../types'
|
||||
import { INVITE_LINK_REGEX, normalizeToInputChannel } from '../../utils/peer-utils'
|
||||
import { assertIsUpdatesGroup } from '../../utils/updates-utils'
|
||||
import { resolvePeer } from '../users/resolve-peer'
|
||||
import { Chat, InputPeerLike } from '../../types/index.js'
|
||||
import { INVITE_LINK_REGEX, normalizeToInputChannel } from '../../utils/peer-utils.js'
|
||||
import { assertIsUpdatesGroup } from '../../utils/updates-utils.js'
|
||||
import { resolvePeer } from '../users/resolve-peer.js'
|
||||
|
||||
/**
|
||||
* Join a channel or supergroup
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { BaseTelegramClient } from '@mtcute/core'
|
||||
import { sleep } from '@mtcute/core/utils'
|
||||
import { sleep } from '@mtcute/core/utils.js'
|
||||
|
||||
import { InputPeerLike } from '../../types'
|
||||
import { isInputPeerChannel } from '../../utils/peer-utils'
|
||||
import { resolvePeer } from '../users/resolve-peer'
|
||||
import { banChatMember } from './ban-chat-member'
|
||||
import { unbanChatMember } from './unban-chat-member'
|
||||
import { InputPeerLike } from '../../types/index.js'
|
||||
import { isInputPeerChannel } from '../../utils/peer-utils.js'
|
||||
import { resolvePeer } from '../users/resolve-peer.js'
|
||||
import { banChatMember } from './ban-chat-member.js'
|
||||
import { unbanChatMember } from './unban-chat-member.js'
|
||||
|
||||
/**
|
||||
* Kick a user from a chat.
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { BaseTelegramClient } from '@mtcute/core'
|
||||
|
||||
import { InputPeerLike, MtInvalidPeerTypeError } from '../../types'
|
||||
import { isInputPeerChannel, isInputPeerChat, normalizeToInputChannel } from '../../utils/peer-utils'
|
||||
import { resolvePeer } from '../users/resolve-peer'
|
||||
import { deleteHistory } from './delete-history'
|
||||
import { InputPeerLike, MtInvalidPeerTypeError } from '../../types/index.js'
|
||||
import { isInputPeerChannel, isInputPeerChat, normalizeToInputChannel } from '../../utils/peer-utils.js'
|
||||
import { resolvePeer } from '../users/resolve-peer.js'
|
||||
import { deleteHistory } from './delete-history.js'
|
||||
|
||||
/**
|
||||
* Leave a group chat, supergroup or channel
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue