rename back to mtcute

idk lol
This commit is contained in:
teidesu 2021-08-05 20:38:24 +03:00
parent b7751f0a57
commit 4b22ee5b25
276 changed files with 768 additions and 768 deletions

View file

@ -1,10 +1,10 @@
# mtqt # MTCute
![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat) ![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)
Work-in-progress library for MTProto in TypeScript. Work-in-progress library for MTProto in TypeScript.
[🎯 Roadmap (notion.so)](https://teidesu.notion.site/mtqt-development-cfccff4fddad4b218f3bea27f784b8b5) [🎯 Roadmap (notion.so)](https://teidesu.notion.site/MTCute-development-cfccff4fddad4b218f3bea27f784b8b5)
| [📦 TL Reference](https://mt.tei.su/tl) | [📦 TL Reference](https://mt.tei.su/tl)
> ⚠️ **Warning**: While this library is WIP, storage > ⚠️ **Warning**: While this library is WIP, storage
@ -30,8 +30,8 @@ What is not done yet:
## Setting up for development: ## Setting up for development:
```bash ```bash
git clone https://github.com/mtqt-dev/mtqt git clone https://github.com/mtcute/mtcute
cd mtqt cd mtcute
yarn install yarn install
npx lerna link npx lerna link

View file

@ -1,5 +1,5 @@
{ {
"name": "mtqt", "name": "mtcute",
"private": true, "private": true,
"version": "1.0.0", "version": "1.0.0",
"description": "Type-safe library for MTProto (Telegram API) for browser and NodeJS", "description": "Type-safe library for MTProto (Telegram API) for browser and NodeJS",

View file

@ -1,8 +1,8 @@
{ {
"name": "@mtqt/client", "name": "@mtcute/client",
"private": true, "private": true,
"version": "1.0.0", "version": "1.0.0",
"description": "High-level API over @mtqt/core", "description": "High-level API over @mtcute/core",
"author": "Alisa Sireneva <me@tei.su>", "author": "Alisa Sireneva <me@tei.su>",
"license": "LGPL-3.0", "license": "LGPL-3.0",
"main": "src/index.ts", "main": "src/index.ts",
@ -13,9 +13,9 @@
}, },
"dependencies": { "dependencies": {
"@types/node": "^15.12.1", "@types/node": "^15.12.1",
"@mtqt/tl": "~1.131.0", "@mtcute/tl": "~1.131.0",
"@mtqt/core": "^1.0.0", "@mtcute/core": "^1.0.0",
"@mtqt/file-id": "^1.0.0", "@mtcute/file-id": "^1.0.0",
"eager-async-pool": "^1.0.0", "eager-async-pool": "^1.0.0",
"file-type": "^16.2.0", "file-type": "^16.2.0",
"big-integer": "1.6.48", "big-integer": "1.6.48",

View file

@ -281,8 +281,8 @@ async function main() {
output.write( output.write(
'/* THIS FILE WAS AUTO-GENERATED */\n' + '/* THIS FILE WAS AUTO-GENERATED */\n' +
"import { BaseTelegramClient } from '@mtqt/core'\n" + "import { BaseTelegramClient } from '@mtcute/core'\n" +
"import { tl } from '@mtqt/tl'" "import { tl } from '@mtcute/tl'"
) )
Object.entries(state.imports).forEach(([module, items]) => { Object.entries(state.imports).forEach(([module, items]) => {
items = [...items] items = [...items]

View file

@ -1,6 +1,6 @@
/* THIS FILE WAS AUTO-GENERATED */ /* THIS FILE WAS AUTO-GENERATED */
import { BaseTelegramClient } from '@mtqt/core' import { BaseTelegramClient } from '@mtcute/core'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { acceptTos } from './methods/auth/accept-tos' import { acceptTos } from './methods/auth/accept-tos'
import { checkPassword } from './methods/auth/check-password' import { checkPassword } from './methods/auth/check-password'
import { getPasswordHint } from './methods/auth/get-password-hint' import { getPasswordHint } from './methods/auth/get-password-hint'
@ -226,8 +226,8 @@ import {
MaybeArray, MaybeArray,
MaybeAsync, MaybeAsync,
TelegramConnection, TelegramConnection,
} from '@mtqt/core' } from '@mtcute/core'
import { tdFileId } from '@mtqt/file-id' import { tdFileId } from '@mtcute/file-id'
export interface TelegramClient extends BaseTelegramClient { export interface TelegramClient extends BaseTelegramClient {
/** /**
@ -1209,8 +1209,8 @@ export interface TelegramClient extends BaseTelegramClient {
* Get preview information about a private chat. * Get preview information about a private chat.
* *
* @param inviteLink Invite link * @param inviteLink Invite link
* @throws MtqtArgumentError In case invite link has invalid format * @throws MtArgumentError In case invite link has invalid format
* @throws MtqtNotFoundError * @throws MtNotFoundError
* In case you are trying to get info about private chat that you have already joined. * In case you are trying to get info about private chat that you have already joined.
* Use {@link getChat} or {@link getFullChat} instead. * Use {@link getChat} or {@link getFullChat} instead.
*/ */
@ -1219,7 +1219,7 @@ export interface TelegramClient extends BaseTelegramClient {
* Get basic information about a chat. * Get basic information about a chat.
* *
* @param chatId ID of the chat, its username or invite link * @param chatId ID of the chat, its username or invite link
* @throws MtqtArgumentError * @throws MtArgumentError
* In case you are trying to get info about private chat that you haven't joined. * In case you are trying to get info about private chat that you haven't joined.
* Use {@link getChatPreview} instead. * Use {@link getChatPreview} instead.
*/ */
@ -1228,7 +1228,7 @@ export interface TelegramClient extends BaseTelegramClient {
* Get full information about a chat. * Get full information about a chat.
* *
* @param chatId ID of the chat, its username or invite link * @param chatId ID of the chat, its username or invite link
* @throws MtqtArgumentError * @throws MtArgumentError
* In case you are trying to get info about private chat that you haven't joined. * In case you are trying to get info about private chat that you haven't joined.
* Use {@link getChatPreview} instead. * Use {@link getChatPreview} instead.
*/ */
@ -1636,7 +1636,7 @@ export interface TelegramClient extends BaseTelegramClient {
* use {@link Dialog.filterFolder} instead. * use {@link Dialog.filterFolder} instead.
* *
* When a folder with given ID or title is not found, * When a folder with given ID or title is not found,
* {@link MtqtArgumentError} is thrown * {@link MtArgumentError} is thrown
* *
* By default fetches from "All" folder * By default fetches from "All" folder
*/ */
@ -3016,7 +3016,7 @@ export interface TelegramClient extends BaseTelegramClient {
* mode is also set as default. * mode is also set as default.
* *
* @param parseMode Parse mode to register * @param parseMode Parse mode to register
* @throws MtqtError When the parse mode with a given name is already registered. * @throws MtClientError When the parse mode with a given name is already registered.
*/ */
registerParseMode(parseMode: IMessageEntityParser): void registerParseMode(parseMode: IMessageEntityParser): void
/** /**
@ -3032,15 +3032,15 @@ export interface TelegramClient extends BaseTelegramClient {
* Get a {@link IMessageEntityParser} registered under a given name (or a default one). * Get a {@link IMessageEntityParser} registered under a given name (or a default one).
* *
* @param name Name of the parse mode which parser to get. * @param name Name of the parse mode which parser to get.
* @throws MtqtError When the provided parse mode is not registered * @throws MtClientError When the provided parse mode is not registered
* @throws MtqtError When `name` is omitted and there is no default parse mode * @throws MtClientError When `name` is omitted and there is no default parse mode
*/ */
getParseMode(name?: string | null): IMessageEntityParser getParseMode(name?: string | null): IMessageEntityParser
/** /**
* Set a given parse mode as a default one. * Set a given parse mode as a default one.
* *
* @param name Name of the parse mode * @param name Name of the parse mode
* @throws MtqtError When given parse mode is not registered. * @throws MtClientError When given parse mode is not registered.
*/ */
setDefaultParseMode(name: string): void setDefaultParseMode(name: string): void
/** /**
@ -3291,7 +3291,7 @@ export interface TelegramClient extends BaseTelegramClient {
* Get a list of common chats you have with a given user * Get a list of common chats you have with a given user
* *
* @param userId User's ID, username or phone number * @param userId User's ID, username or phone number
* @throws MtqtInvalidPeerTypeError * @throws MtInvalidPeerTypeError
*/ */
getCommonChats(userId: InputPeerLike): Promise<Chat[]> getCommonChats(userId: InputPeerLike): Promise<Chat[]>
/** /**

View file

@ -4,8 +4,8 @@ export {
LocalstorageStorage, LocalstorageStorage,
tl, tl,
defaultDcs defaultDcs
} from '@mtqt/core' } from '@mtcute/core'
export * from '@mtqt/tl/errors' export * from '@mtcute/tl/errors'
export * from './types' export * from './types'
export * from './client' export * from './client'

View file

@ -62,7 +62,7 @@ import {
MaybeAsync, MaybeAsync,
TelegramConnection, TelegramConnection,
AsyncLock, AsyncLock,
} from '@mtqt/core' } from '@mtcute/core'
// @copy // @copy
import { tdFileId } from '@mtqt/file-id' import { tdFileId } from '@mtcute/file-id'

View file

@ -1,5 +1,5 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { MtqtTypeAssertionError } from '../../types' import { MtTypeAssertionError } from '../../types'
/** /**
* Accept the given TOS * Accept the given TOS
@ -20,7 +20,7 @@ export async function acceptTos(
}) })
if (!res) if (!res)
throw new MtqtTypeAssertionError( throw new MtTypeAssertionError(
'help.acceptTermsOfService', 'help.acceptTermsOfService',
'true', 'true',
'false' 'false'

View file

@ -1,6 +1,6 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { User } from '../../types' import { User } from '../../types'
import { computeSrpParams } from '@mtqt/core' import { computeSrpParams } from '@mtcute/core'
import { assertTypeIs } from '../../utils/type-assertion' import { assertTypeIs } from '../../utils/type-assertion'
/** /**

View file

@ -1,4 +1,4 @@
import { MaybeDynamic, MtqtArgumentError, User } from '../../types' import { MaybeDynamic, MtArgumentError, User } from '../../types'
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
/** /**
@ -68,17 +68,17 @@ export async function startTest(
let phone = params.phone let phone = params.phone
if (phone) { if (phone) {
if (!phone.match(/^99966\d{5}/)) if (!phone.match(/^99966\d{5}/))
throw new MtqtArgumentError( throw new MtArgumentError(
`${phone} is an invalid test phone number` `${phone} is an invalid test phone number`
) )
const id = parseInt(phone[5]) const id = parseInt(phone[5])
if (!availableDcs.find((dc) => dc.id === id)) if (!availableDcs.find((dc) => dc.id === id))
throw new MtqtArgumentError(`${phone} has invalid DC ID (${id})`) throw new MtArgumentError(`${phone} has invalid DC ID (${id})`)
} else { } else {
let dcId = this._primaryDc.id let dcId = this._primaryDc.id
if (params.dcId) { if (params.dcId) {
if (!availableDcs.find((dc) => dc.id === params!.dcId)) if (!availableDcs.find((dc) => dc.id === params!.dcId))
throw new MtqtArgumentError(`DC ID is invalid (${dcId})`) throw new MtArgumentError(`DC ID is invalid (${dcId})`)
dcId = params.dcId dcId = params.dcId
} }

View file

@ -1,6 +1,6 @@
import { import {
MaybeDynamic, MaybeDynamic,
MtqtArgumentError, MtArgumentError,
SentCode, SentCode,
TermsOfService, TermsOfService,
User, User,
@ -19,7 +19,7 @@ import {
PhoneCodeHashEmptyError, PhoneCodeHashEmptyError,
PhoneCodeInvalidError, PhoneCodeInvalidError,
SessionPasswordNeededError, SessionPasswordNeededError,
} from '@mtqt/tl/errors' } from '@mtcute/tl/errors'
/** /**
* Start the client in an interactive and declarative manner, * Start the client in an interactive and declarative manner,
@ -165,7 +165,7 @@ export async function start(
} }
if (!params.phone && !params.botToken) if (!params.phone && !params.botToken)
throw new MtqtArgumentError( throw new MtArgumentError(
'Neither phone nor bot token were provided' 'Neither phone nor bot token were provided'
) )
@ -174,13 +174,13 @@ export async function start(
phone = normalizePhoneNumber(phone) phone = normalizePhoneNumber(phone)
if (!params.code) if (!params.code)
throw new MtqtArgumentError('You must pass `code` to use `phone`') throw new MtArgumentError('You must pass `code` to use `phone`')
} else { } else {
const botToken = params.botToken const botToken = params.botToken
? await resolveMaybeDynamic(params.botToken) ? await resolveMaybeDynamic(params.botToken)
: null : null
if (!botToken) if (!botToken)
throw new MtqtArgumentError( throw new MtArgumentError(
'Either bot token or phone number must be provided' 'Either bot token or phone number must be provided'
) )
@ -219,7 +219,7 @@ export async function start(
e instanceof PhoneCodeInvalidError e instanceof PhoneCodeInvalidError
) { ) {
if (typeof params.code !== 'function') { if (typeof params.code !== 'function') {
throw new MtqtArgumentError('Provided code was invalid') throw new MtArgumentError('Provided code was invalid')
} }
if (params.invalidCodeCallback) { if (params.invalidCodeCallback) {
@ -238,7 +238,7 @@ export async function start(
if (has2fa) { if (has2fa) {
if (!params.password) if (!params.password)
throw new MtqtArgumentError( throw new MtArgumentError(
'2FA is enabled, but `password` was not provided.' '2FA is enabled, but `password` was not provided.'
) )
@ -249,7 +249,7 @@ export async function start(
result = await this.checkPassword(password) result = await this.checkPassword(password)
} catch (e) { } catch (e) {
if (typeof params.password !== 'function') { if (typeof params.password !== 'function') {
throw new MtqtArgumentError( throw new MtArgumentError(
'Provided password was invalid' 'Provided password was invalid'
) )
} }

View file

@ -1,5 +1,5 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
/** /**
* Send an answer to a callback query. * Send an answer to a callback query.

View file

@ -1,5 +1,5 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { BotInline, InputInlineResult } from '../../types' import { BotInline, InputInlineResult } from '../../types'
/** /**

View file

@ -1,5 +1,5 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { BotCommands } from '../../types' import { BotCommands } from '../../types'
/** /**

View file

@ -1,7 +1,7 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { InputPeerLike } from '../../types' import { InputPeerLike } from '../../types'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { computeSrpParams } from '@mtqt/core' import { computeSrpParams } from '@mtcute/core'
/** /**
* Request a callback answer from a bot, * Request a callback answer from a bot,

View file

@ -1,10 +1,10 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { import {
InputPeerLike, InputPeerLike,
MtqtInvalidPeerTypeError, MtInvalidPeerTypeError,
GameHighScore, GameHighScore,
} from '../../types' } from '../../types'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { import {
createUsersChatsIndex, createUsersChatsIndex,
normalizeToInputUser, normalizeToInputUser,
@ -29,7 +29,7 @@ export async function getGameHighScores(
let user: tl.TypeInputUser let user: tl.TypeInputUser
if (userId) { if (userId) {
const res = normalizeToInputUser(await this.resolvePeer(userId)) const res = normalizeToInputUser(await this.resolvePeer(userId))
if (!res) throw new MtqtInvalidPeerTypeError(userId, 'user') if (!res) throw new MtInvalidPeerTypeError(userId, 'user')
user = res user = res
} else { } else {
@ -65,7 +65,7 @@ export async function getInlineGameHighScores(
let user: tl.TypeInputUser let user: tl.TypeInputUser
if (userId) { if (userId) {
const res = normalizeToInputUser(await this.resolvePeer(userId)) const res = normalizeToInputUser(await this.resolvePeer(userId))
if (!res) throw new MtqtInvalidPeerTypeError(userId, 'user') if (!res) throw new MtInvalidPeerTypeError(userId, 'user')
user = res user = res
} else { } else {

View file

@ -1,5 +1,5 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { BotCommands } from '../../types' import { BotCommands } from '../../types'
/** /**

View file

@ -1,5 +1,5 @@
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { BotCommands, MtqtInvalidPeerTypeError } from '../../types' import { BotCommands, MtInvalidPeerTypeError } from '../../types'
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { normalizeToInputUser } from '../../utils/peer-utils' import { normalizeToInputUser } from '../../utils/peer-utils'
@ -25,7 +25,7 @@ export async function _normalizeCommandScope(
const user = normalizeToInputUser(await this.resolvePeer(scope.user)) const user = normalizeToInputUser(await this.resolvePeer(scope.user))
if (!user) if (!user)
throw new MtqtInvalidPeerTypeError(scope.user, 'user') throw new MtInvalidPeerTypeError(scope.user, 'user')
return { return {
_: 'botCommandScopePeerUser', _: 'botCommandScopePeerUser',

View file

@ -1,7 +1,7 @@
import { InputPeerLike, Message, MtqtInvalidPeerTypeError } from '../../types' import { InputPeerLike, Message, MtInvalidPeerTypeError } from '../../types'
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { normalizeToInputUser } from '../../utils/peer-utils' import { normalizeToInputUser } from '../../utils/peer-utils'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
/** /**
* Set a score of a user in a game * Set a score of a user in a game
@ -38,7 +38,7 @@ export async function setGameScore(
const chat = await this.resolvePeer(chatId) const chat = await this.resolvePeer(chatId)
const user = normalizeToInputUser(await this.resolvePeer(userId)) const user = normalizeToInputUser(await this.resolvePeer(userId))
if (!user) throw new MtqtInvalidPeerTypeError(userId, 'user') if (!user) throw new MtInvalidPeerTypeError(userId, 'user')
const res = await this.call({ const res = await this.call({
_: 'messages.setGameScore', _: 'messages.setGameScore',
@ -85,7 +85,7 @@ export async function setInlineGameScore(
if (!params) params = {} if (!params) params = {}
const user = normalizeToInputUser(await this.resolvePeer(userId)) const user = normalizeToInputUser(await this.resolvePeer(userId))
if (!user) throw new MtqtInvalidPeerTypeError(userId, 'user') if (!user) throw new MtInvalidPeerTypeError(userId, 'user')
const [id, connection] = await this._normalizeInline(messageId) const [id, connection] = await this._normalizeInline(messageId)

View file

@ -1,5 +1,5 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { BotCommands } from '../../types' import { BotCommands } from '../../types'
/** /**

View file

@ -1,6 +1,6 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { InputPeerLike, MtqtInvalidPeerTypeError } from '../../types' import { InputPeerLike, MtInvalidPeerTypeError } from '../../types'
import { MaybeArray } from '@mtqt/core' import { MaybeArray } from '@mtcute/core'
import { import {
isInputPeerChannel, isInputPeerChannel,
isInputPeerChat, isInputPeerChat,
@ -52,5 +52,5 @@ export async function addChatMembers(
fwdLimit: forwardCount, fwdLimit: forwardCount,
}) })
this._handleUpdate(updates) this._handleUpdate(updates)
} else throw new MtqtInvalidPeerTypeError(chatId, 'chat or channel') } else throw new MtInvalidPeerTypeError(chatId, 'chat or channel')
} }

View file

@ -1,7 +1,7 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { MaybeArray } from '@mtqt/core' import { MaybeArray } from '@mtcute/core'
import { InputPeerLike } from '../../types' import { InputPeerLike } from '../../types'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
/** /**
* Archive one or more chats * Archive one or more chats

View file

@ -2,8 +2,8 @@ import { TelegramClient } from '../../client'
import { import {
InputPeerLike, InputPeerLike,
Message, Message,
MtqtInvalidPeerTypeError, MtInvalidPeerTypeError,
MtqtTypeAssertionError, MtTypeAssertionError,
} from '../../types' } from '../../types'
import { import {
isInputPeerChannel, isInputPeerChannel,
@ -45,20 +45,20 @@ export async function banChatMember(
}) })
} else if (isInputPeerChat(chat)) { } else if (isInputPeerChat(chat)) {
const normUser = normalizeToInputUser(user) const normUser = normalizeToInputUser(user)
if (!normUser) throw new MtqtInvalidPeerTypeError(userId, 'user') if (!normUser) throw new MtInvalidPeerTypeError(userId, 'user')
res = await this.call({ res = await this.call({
_: 'messages.deleteChatUser', _: 'messages.deleteChatUser',
chatId: chat.chatId, chatId: chat.chatId,
userId: normUser, userId: normUser,
}) })
} else throw new MtqtInvalidPeerTypeError(chatId, 'chat or channel') } else throw new MtInvalidPeerTypeError(chatId, 'chat or channel')
try { try {
return this._findMessageInUpdate(res) return this._findMessageInUpdate(res)
} catch (e) { } catch (e) {
if ( if (
e instanceof MtqtTypeAssertionError && e instanceof MtTypeAssertionError &&
e.context === '_findInUpdate (@ .updates[*])' e.context === '_findInUpdate (@ .updates[*])'
) { ) {
// no service message // no service message

View file

@ -1,5 +1,5 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { Chat, MtqtTypeAssertionError } from '../../types' import { Chat, MtTypeAssertionError } from '../../types'
import { assertIsUpdatesGroup } from '../../utils/updates-utils' import { assertIsUpdatesGroup } from '../../utils/updates-utils'
/** /**

View file

@ -1,8 +1,8 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { MaybeArray } from '@mtqt/core' import { MaybeArray } from '@mtcute/core'
import { Chat, InputPeerLike, MtqtTypeAssertionError } from '../../types' import { Chat, InputPeerLike, MtTypeAssertionError } from '../../types'
import { normalizeToInputUser } from '../../utils/peer-utils' import { normalizeToInputUser } from '../../utils/peer-utils'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { assertIsUpdatesGroup } from '../../utils/updates-utils' import { assertIsUpdatesGroup } from '../../utils/updates-utils'
/** /**

View file

@ -1,5 +1,5 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { Chat, MtqtTypeAssertionError } from '../../types' import { Chat, MtTypeAssertionError } from '../../types'
import { assertIsUpdatesGroup } from '../../utils/updates-utils' import { assertIsUpdatesGroup } from '../../utils/updates-utils'
/** /**

View file

@ -1,4 +1,4 @@
import { InputPeerLike, MtqtInvalidPeerTypeError } from '../../types' import { InputPeerLike, MtInvalidPeerTypeError } from '../../types'
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { normalizeToInputChannel } from '../../utils/peer-utils' import { normalizeToInputChannel } from '../../utils/peer-utils'
@ -14,7 +14,7 @@ export async function deleteChannel(
chatId: InputPeerLike chatId: InputPeerLike
): Promise<void> { ): Promise<void> {
const peer = normalizeToInputChannel(await this.resolvePeer(chatId)) const peer = normalizeToInputChannel(await this.resolvePeer(chatId))
if (!peer) throw new MtqtInvalidPeerTypeError(chatId, 'channel') if (!peer) throw new MtInvalidPeerTypeError(chatId, 'channel')
const res = await this.call({ const res = await this.call({
_: 'channels.deleteChannel', _: 'channels.deleteChannel',

View file

@ -1,5 +1,5 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { InputPeerLike, MtqtInvalidPeerTypeError } from '../../types' import { InputPeerLike, MtInvalidPeerTypeError } from '../../types'
import { import {
isInputPeerChannel, isInputPeerChannel,
isInputPeerChat, isInputPeerChat,
@ -33,7 +33,7 @@ export async function deleteChatPhoto(
channel: normalizeToInputChannel(chat), channel: normalizeToInputChannel(chat),
photo: { _: 'inputChatPhotoEmpty' }, photo: { _: 'inputChatPhotoEmpty' },
}) })
} else throw new MtqtInvalidPeerTypeError(chatId, 'chat or channel') } else throw new MtInvalidPeerTypeError(chatId, 'chat or channel')
this._handleUpdate(res) this._handleUpdate(res)
} }

View file

@ -1,5 +1,5 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { InputPeerLike, MtqtInvalidPeerTypeError } from '../../types' import { InputPeerLike, MtInvalidPeerTypeError } from '../../types'
import { isInputPeerChat } from '../../utils/peer-utils' import { isInputPeerChat } from '../../utils/peer-utils'
/** /**
@ -14,7 +14,7 @@ export async function deleteGroup(
): Promise<void> { ): Promise<void> {
const chat = await this.resolvePeer(chatId) const chat = await this.resolvePeer(chatId)
if (!isInputPeerChat(chat)) if (!isInputPeerChat(chat))
throw new MtqtInvalidPeerTypeError(chatId, 'chat') throw new MtInvalidPeerTypeError(chatId, 'chat')
const res = await this.call({ const res = await this.call({
_: 'messages.deleteChatUser', _: 'messages.deleteChatUser',

View file

@ -2,7 +2,7 @@ import { TelegramClient } from '../../client'
import { InputPeerLike } from '../../types' import { InputPeerLike } from '../../types'
import { normalizeToInputChannel } from '../../utils/peer-utils' import { normalizeToInputChannel } from '../../utils/peer-utils'
import { createDummyUpdate } from '../../utils/updates-utils' import { createDummyUpdate } from '../../utils/updates-utils'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
/** /**
* Delete communication history (for private chats * Delete communication history (for private chats

View file

@ -1,10 +1,10 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { InputPeerLike, MtqtInvalidPeerTypeError } from '../../types' import { InputPeerLike, MtInvalidPeerTypeError } from '../../types'
import { import {
normalizeToInputChannel, normalizeToInputChannel,
normalizeToInputUser, normalizeToInputUser,
} from '../../utils/peer-utils' } from '../../utils/peer-utils'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { createDummyUpdate } from '../../utils/updates-utils' import { createDummyUpdate } from '../../utils/updates-utils'
/** /**
@ -20,10 +20,10 @@ export async function deleteUserHistory(
userId: InputPeerLike userId: InputPeerLike
): Promise<void> { ): Promise<void> {
const channel = normalizeToInputChannel(await this.resolvePeer(chatId)) const channel = normalizeToInputChannel(await this.resolvePeer(chatId))
if (!channel) throw new MtqtInvalidPeerTypeError(chatId, 'channel') if (!channel) throw new MtInvalidPeerTypeError(chatId, 'channel')
const user = normalizeToInputUser(await this.resolvePeer(userId)) const user = normalizeToInputUser(await this.resolvePeer(userId))
if (!user) throw new MtqtInvalidPeerTypeError(userId, 'user') if (!user) throw new MtInvalidPeerTypeError(userId, 'user')
const res = await this.call({ const res = await this.call({
_: 'channels.deleteUserHistory', _: 'channels.deleteUserHistory',

View file

@ -1,6 +1,6 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { InputPeerLike, MtqtInvalidPeerTypeError } from '../../types' import { InputPeerLike, MtInvalidPeerTypeError } from '../../types'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { import {
normalizeToInputChannel, normalizeToInputChannel,
normalizeToInputUser, normalizeToInputUser,
@ -23,10 +23,10 @@ export async function editAdminRights(
rank = '' rank = ''
): Promise<void> { ): Promise<void> {
const chat = normalizeToInputChannel(await this.resolvePeer(chatId)) const chat = normalizeToInputChannel(await this.resolvePeer(chatId))
if (!chat) throw new MtqtInvalidPeerTypeError(chatId, 'channel') if (!chat) throw new MtInvalidPeerTypeError(chatId, 'channel')
const user = normalizeToInputUser(await this.resolvePeer(userId)) const user = normalizeToInputUser(await this.resolvePeer(userId))
if (!user) throw new MtqtInvalidPeerTypeError(userId, 'user') if (!user) throw new MtInvalidPeerTypeError(userId, 'user')
const res = await this.call({ const res = await this.call({
_: 'channels.editAdmin', _: 'channels.editAdmin',

View file

@ -1,11 +1,11 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { import {
InputPeerLike, InputPeerLike,
MtqtInvalidPeerTypeError, MtInvalidPeerTypeError,
ChatEvent, ChatEvent,
} from '../../types' } from '../../types'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { MaybeArray } from '@mtqt/core' import { MaybeArray } from '@mtcute/core'
import bigInt from 'big-integer' import bigInt from 'big-integer'
import { import {
createUsersChatsIndex, createUsersChatsIndex,
@ -86,7 +86,7 @@ export async function* getChatEventLog(
if (!params) params = {} if (!params) params = {}
const channel = normalizeToInputChannel(await this.resolvePeer(chatId)) const channel = normalizeToInputChannel(await this.resolvePeer(chatId))
if (!channel) throw new MtqtInvalidPeerTypeError(chatId, 'channel') if (!channel) throw new MtInvalidPeerTypeError(chatId, 'channel')
let current = 0 let current = 0
let maxId = params.maxId ?? bigInt.zero let maxId = params.maxId ?? bigInt.zero

View file

@ -1,5 +1,5 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { InputPeerLike, MtqtInvalidPeerTypeError } from '../../types' import { InputPeerLike, MtInvalidPeerTypeError } from '../../types'
import { import {
createUsersChatsIndex, createUsersChatsIndex,
isInputPeerChannel, isInputPeerChannel,
@ -8,9 +8,9 @@ import {
normalizeToInputChannel, normalizeToInputChannel,
} from '../../utils/peer-utils' } from '../../utils/peer-utils'
import { assertTypeIs } from '../../utils/type-assertion' import { assertTypeIs } from '../../utils/type-assertion'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { ChatMember } from '../../types' import { ChatMember } from '../../types'
import { UserNotParticipantError } from '@mtqt/tl/errors' import { UserNotParticipantError } from '@mtcute/tl/errors'
/** /**
* Get information about a single chat member * Get information about a single chat member
@ -30,7 +30,7 @@ export async function getChatMember(
if (isInputPeerChat(chat)) { if (isInputPeerChat(chat)) {
if (!isInputPeerUser(user)) if (!isInputPeerUser(user))
throw new MtqtInvalidPeerTypeError(userId, 'user') throw new MtInvalidPeerTypeError(userId, 'user')
const res = await this.call({ const res = await this.call({
_: 'messages.getFullChat', _: 'messages.getFullChat',
@ -71,5 +71,5 @@ export async function getChatMember(
const { users } = createUsersChatsIndex(res) const { users } = createUsersChatsIndex(res)
return new ChatMember(this, res.participant, users) return new ChatMember(this, res.participant, users)
} else throw new MtqtInvalidPeerTypeError(chatId, 'chat or channel') } else throw new MtInvalidPeerTypeError(chatId, 'chat or channel')
} }

View file

@ -1,7 +1,7 @@
import { import {
ChatMember, ChatMember,
InputPeerLike, InputPeerLike,
MtqtInvalidPeerTypeError, MtInvalidPeerTypeError,
} from '../../types' } from '../../types'
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { import {
@ -11,7 +11,7 @@ import {
normalizeToInputChannel, normalizeToInputChannel,
} from '../../utils/peer-utils' } from '../../utils/peer-utils'
import { assertTypeIs } from '../../utils/type-assertion' import { assertTypeIs } from '../../utils/type-assertion'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { ArrayWithTotal } from '../../types' import { ArrayWithTotal } from '../../types'
/** /**
@ -156,5 +156,5 @@ export async function getChatMembers(
return ret return ret
} }
throw new MtqtInvalidPeerTypeError(chatId, 'chat or channel') throw new MtInvalidPeerTypeError(chatId, 'chat or channel')
} }

View file

@ -1,4 +1,4 @@
import { MtqtArgumentError, MtqtNotFoundError } from '../../types' import { MtArgumentError, MtNotFoundError } from '../../types'
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { INVITE_LINK_REGEX } from '../../utils/peer-utils' import { INVITE_LINK_REGEX } from '../../utils/peer-utils'
import { ChatPreview } from '../../types' import { ChatPreview } from '../../types'
@ -7,8 +7,8 @@ import { ChatPreview } from '../../types'
* Get preview information about a private chat. * Get preview information about a private chat.
* *
* @param inviteLink Invite link * @param inviteLink Invite link
* @throws MtqtArgumentError In case invite link has invalid format * @throws MtArgumentError In case invite link has invalid format
* @throws MtqtNotFoundError * @throws MtNotFoundError
* In case you are trying to get info about private chat that you have already joined. * In case you are trying to get info about private chat that you have already joined.
* Use {@link getChat} or {@link getFullChat} instead. * Use {@link getChat} or {@link getFullChat} instead.
* @internal * @internal
@ -18,7 +18,7 @@ export async function getChatPreview(
inviteLink: string inviteLink: string
): Promise<ChatPreview> { ): Promise<ChatPreview> {
const m = inviteLink.match(INVITE_LINK_REGEX) const m = inviteLink.match(INVITE_LINK_REGEX)
if (!m) throw new MtqtArgumentError('Invalid invite link') if (!m) throw new MtArgumentError('Invalid invite link')
const res = await this.call({ const res = await this.call({
_: 'messages.checkChatInvite', _: 'messages.checkChatInvite',
@ -26,7 +26,7 @@ export async function getChatPreview(
}) })
if (res._ !== 'chatInvite') { if (res._ !== 'chatInvite') {
throw new MtqtNotFoundError(`You have already joined this chat!`) throw new MtNotFoundError(`You have already joined this chat!`)
} }
return new ChatPreview(this, res, inviteLink) return new ChatPreview(this, res, inviteLink)

View file

@ -1,4 +1,4 @@
import { Chat, InputPeerLike, MtqtArgumentError } from '../../types' import { Chat, InputPeerLike, MtArgumentError } from '../../types'
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { import {
INVITE_LINK_REGEX, INVITE_LINK_REGEX,
@ -8,13 +8,13 @@ import {
normalizeToInputChannel, normalizeToInputChannel,
normalizeToInputUser, normalizeToInputUser,
} from '../../utils/peer-utils' } from '../../utils/peer-utils'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
/** /**
* Get basic information about a chat. * Get basic information about a chat.
* *
* @param chatId ID of the chat, its username or invite link * @param chatId ID of the chat, its username or invite link
* @throws MtqtArgumentError * @throws MtArgumentError
* In case you are trying to get info about private chat that you haven't joined. * In case you are trying to get info about private chat that you haven't joined.
* Use {@link getChatPreview} instead. * Use {@link getChatPreview} instead.
* @internal * @internal
@ -32,7 +32,7 @@ export async function getChat(
}) })
if (res._ === 'chatInvite') { if (res._ === 'chatInvite') {
throw new MtqtArgumentError( throw new MtArgumentError(
`You haven't joined ${JSON.stringify(res.title)}` `You haven't joined ${JSON.stringify(res.title)}`
) )
} }

View file

@ -1,4 +1,4 @@
import { Chat, InputPeerLike, MtqtArgumentError } from '../../types' import { Chat, InputPeerLike, MtArgumentError } from '../../types'
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { import {
INVITE_LINK_REGEX, INVITE_LINK_REGEX,
@ -8,13 +8,13 @@ import {
normalizeToInputChannel, normalizeToInputChannel,
normalizeToInputUser, normalizeToInputUser,
} from '../../utils/peer-utils' } from '../../utils/peer-utils'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
/** /**
* Get full information about a chat. * Get full information about a chat.
* *
* @param chatId ID of the chat, its username or invite link * @param chatId ID of the chat, its username or invite link
* @throws MtqtArgumentError * @throws MtArgumentError
* In case you are trying to get info about private chat that you haven't joined. * In case you are trying to get info about private chat that you haven't joined.
* Use {@link getChatPreview} instead. * Use {@link getChatPreview} instead.
* @internal * @internal
@ -32,7 +32,7 @@ export async function getFullChat(
}) })
if (res._ === 'chatInvite') { if (res._ === 'chatInvite') {
throw new MtqtArgumentError( throw new MtArgumentError(
`You haven't joined ${JSON.stringify(res.title)}` `You haven't joined ${JSON.stringify(res.title)}`
) )
} }

View file

@ -1,7 +1,7 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { Chat, MtqtTypeAssertionError } from '../../types' import { Chat, MtTypeAssertionError } from '../../types'
import { assertTypeIs } from '../../utils/type-assertion' import { assertTypeIs } from '../../utils/type-assertion'
import { getMarkedPeerId } from '@mtqt/core' import { getMarkedPeerId } from '@mtcute/core'
import { tl } from 'packages/tl' import { tl } from 'packages/tl'
import { assertIsUpdatesGroup } from '../../utils/updates-utils' import { assertIsUpdatesGroup } from '../../utils/updates-utils'

View file

@ -2,8 +2,8 @@ import { TelegramClient } from '../../client'
import { import {
Chat, Chat,
InputPeerLike, InputPeerLike,
MtqtNotFoundError, MtNotFoundError,
MtqtTypeAssertionError, MtTypeAssertionError,
} from '../../types' } from '../../types'
import { import {
INVITE_LINK_REGEX, INVITE_LINK_REGEX,
@ -39,7 +39,7 @@ export async function joinChat(
} }
const peer = normalizeToInputChannel(await this.resolvePeer(chatId)) const peer = normalizeToInputChannel(await this.resolvePeer(chatId))
if (!peer) throw new MtqtNotFoundError() if (!peer) throw new MtNotFoundError()
const res = await this.call({ const res = await this.call({
_: 'channels.joinChannel', _: 'channels.joinChannel',

View file

@ -1,4 +1,4 @@
import { InputPeerLike, MtqtInvalidPeerTypeError } from '../../types' import { InputPeerLike, MtInvalidPeerTypeError } from '../../types'
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { import {
isInputPeerChannel, isInputPeerChannel,
@ -37,5 +37,5 @@ export async function leaveChat(
if (clear) { if (clear) {
await this.deleteHistory(chat) await this.deleteHistory(chat)
} }
} else throw new MtqtInvalidPeerTypeError(chatId, 'chat or channel') } else throw new MtInvalidPeerTypeError(chatId, 'chat or channel')
} }

View file

@ -1,10 +1,10 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { InputPeerLike, MtqtInvalidPeerTypeError } from '../../types' import { InputPeerLike, MtInvalidPeerTypeError } from '../../types'
import { import {
isInputPeerChannel, isInputPeerChannel,
normalizeToInputChannel, normalizeToInputChannel,
} from '../../utils/peer-utils' } from '../../utils/peer-utils'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { normalizeDate } from '../../utils/misc-utils' import { normalizeDate } from '../../utils/misc-utils'
/** /**
@ -33,7 +33,7 @@ export async function restrictChatMember(
): Promise<void> { ): Promise<void> {
const chat = await this.resolvePeer(chatId) const chat = await this.resolvePeer(chatId)
if (!isInputPeerChannel(chat)) if (!isInputPeerChannel(chat))
throw new MtqtInvalidPeerTypeError(chatId, 'channel') throw new MtInvalidPeerTypeError(chatId, 'channel')
const user = await this.resolvePeer(userId) const user = await this.resolvePeer(userId)

View file

@ -1,6 +1,6 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { InputPeerLike } from '../../types' import { InputPeerLike } from '../../types'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
/** /**
* Save or delete a draft message associated with some chat * Save or delete a draft message associated with some chat

View file

@ -1,6 +1,6 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { Chat, InputPeerLike, MtqtTypeAssertionError } from '../../types' import { Chat, InputPeerLike, MtTypeAssertionError } from '../../types'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { assertIsUpdatesGroup } from '../../utils/updates-utils' import { assertIsUpdatesGroup } from '../../utils/updates-utils'
/** /**

View file

@ -3,16 +3,16 @@ import {
InputFileLike, InputFileLike,
InputPeerLike, InputPeerLike,
isUploadedFile, isUploadedFile,
MtqtArgumentError, MtArgumentError,
MtqtInvalidPeerTypeError, MtInvalidPeerTypeError,
} from '../../types' } from '../../types'
import { import {
isInputPeerChannel, isInputPeerChannel,
isInputPeerChat, isInputPeerChat,
normalizeToInputChannel, normalizeToInputChannel,
} from '../../utils/peer-utils' } from '../../utils/peer-utils'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { fileIdToInputPhoto, tdFileId } from '@mtqt/file-id' import { fileIdToInputPhoto, tdFileId } from '@mtcute/file-id'
/** /**
* Set a new chat photo or video. * Set a new chat photo or video.
@ -36,14 +36,14 @@ export async function setChatPhoto(
): Promise<void> { ): Promise<void> {
const chat = await this.resolvePeer(chatId) const chat = await this.resolvePeer(chatId)
if (!(isInputPeerChannel(chat) || isInputPeerChat(chat))) if (!(isInputPeerChannel(chat) || isInputPeerChat(chat)))
throw new MtqtInvalidPeerTypeError(chatId, 'chat or channel') throw new MtInvalidPeerTypeError(chatId, 'chat or channel')
let photo: tl.TypeInputChatPhoto | undefined = undefined let photo: tl.TypeInputChatPhoto | undefined = undefined
let inputFile: tl.TypeInputFile let inputFile: tl.TypeInputFile
if (tdFileId.isFileIdLike(media)) { if (tdFileId.isFileIdLike(media)) {
if (typeof media === 'string' && media.match(/^https?:\/\//)) if (typeof media === 'string' && media.match(/^https?:\/\//))
throw new MtqtArgumentError("Chat photo can't be external") throw new MtArgumentError("Chat photo can't be external")
if (typeof media === 'string' && media.match(/^file:/)) { if (typeof media === 'string' && media.match(/^file:/)) {
const uploaded = await this.uploadFile({ const uploaded = await this.uploadFile({
file: media.substr(5), file: media.substr(5),
@ -62,7 +62,7 @@ export async function setChatPhoto(
_: 'inputChatPhoto', _: 'inputChatPhoto',
id: media.id, id: media.id,
} }
} else throw new MtqtArgumentError("Chat photo can't be InputMedia") } else throw new MtArgumentError("Chat photo can't be InputMedia")
} else if (isUploadedFile(media)) { } else if (isUploadedFile(media)) {
inputFile = media.inputFile inputFile = media.inputFile
} else if (typeof media === 'object' && tl.isAnyInputFile(media)) { } else if (typeof media === 'object' && tl.isAnyInputFile(media)) {

View file

@ -1,5 +1,5 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { InputPeerLike, MtqtInvalidPeerTypeError } from '../../types' import { InputPeerLike, MtInvalidPeerTypeError } from '../../types'
import { import {
isInputPeerChannel, isInputPeerChannel,
isInputPeerChat, isInputPeerChat,
@ -35,7 +35,7 @@ export async function setChatTitle(
channel: normalizeToInputChannel(chat), channel: normalizeToInputChannel(chat),
title, title,
}) })
} else throw new MtqtInvalidPeerTypeError(chatId, 'chat or channel') } else throw new MtInvalidPeerTypeError(chatId, 'chat or channel')
this._handleUpdate(res) this._handleUpdate(res)
} }

View file

@ -1,5 +1,5 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { InputPeerLike, MtqtInvalidPeerTypeError } from '../../types' import { InputPeerLike, MtInvalidPeerTypeError } from '../../types'
import { normalizeToInputChannel } from '../../utils/peer-utils' import { normalizeToInputChannel } from '../../utils/peer-utils'
/** /**
@ -17,7 +17,7 @@ export async function setChatUsername(
username: string | null username: string | null
): Promise<void> { ): Promise<void> {
const chat = normalizeToInputChannel(await this.resolvePeer(chatId)) const chat = normalizeToInputChannel(await this.resolvePeer(chatId))
if (!chat) throw new MtqtInvalidPeerTypeError(chatId, 'channel') if (!chat) throw new MtInvalidPeerTypeError(chatId, 'channel')
await this.call({ await this.call({
_: 'channels.updateUsername', _: 'channels.updateUsername',

View file

@ -1,5 +1,5 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { InputPeerLike, MtqtInvalidPeerTypeError } from '../../types' import { InputPeerLike, MtInvalidPeerTypeError } from '../../types'
import { normalizeToInputChannel } from '../../utils/peer-utils' import { normalizeToInputChannel } from '../../utils/peer-utils'
/** /**
@ -18,7 +18,7 @@ export async function setSlowMode(
seconds = 0 seconds = 0
): Promise<void> { ): Promise<void> {
const chat = normalizeToInputChannel(await this.resolvePeer(chatId)) const chat = normalizeToInputChannel(await this.resolvePeer(chatId))
if (!chat) throw new MtqtInvalidPeerTypeError(chatId, 'channel') if (!chat) throw new MtInvalidPeerTypeError(chatId, 'channel')
const res = await this.call({ const res = await this.call({
_: 'channels.toggleSlowMode', _: 'channels.toggleSlowMode',

View file

@ -1,7 +1,7 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { MaybeArray } from '@mtqt/core' import { MaybeArray } from '@mtcute/core'
import { InputPeerLike } from '../../types' import { InputPeerLike } from '../../types'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
/** /**
* Unarchive one or more chats * Unarchive one or more chats

View file

@ -1,5 +1,5 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { InputPeerLike, MtqtInvalidPeerTypeError } from '../../types' import { InputPeerLike, MtInvalidPeerTypeError } from '../../types'
import { import {
isInputPeerChannel, isInputPeerChannel,
isInputPeerChat, isInputPeerChat,
@ -41,5 +41,5 @@ export async function unbanChatMember(
this._handleUpdate(res) this._handleUpdate(res)
} else if (isInputPeerChat(chat)) { } else if (isInputPeerChat(chat)) {
// no-op // // no-op //
} else throw new MtqtInvalidPeerTypeError(chatId, 'chat or channel') } else throw new MtInvalidPeerTypeError(chatId, 'chat or channel')
} }

View file

@ -1,12 +1,12 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { import {
InputPeerLike, InputPeerLike,
MtqtInvalidPeerTypeError, MtInvalidPeerTypeError,
MtqtTypeAssertionError, MtTypeAssertionError,
User, User,
} from '../../types' } from '../../types'
import { normalizeToInputUser } from '../../utils/peer-utils' import { normalizeToInputUser } from '../../utils/peer-utils'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { assertIsUpdatesGroup } from '../../utils/updates-utils' import { assertIsUpdatesGroup } from '../../utils/updates-utils'
/** /**
@ -43,7 +43,7 @@ export async function addContact(
} }
): Promise<User> { ): Promise<User> {
const peer = normalizeToInputUser(await this.resolvePeer(userId)) const peer = normalizeToInputUser(await this.resolvePeer(userId))
if (!peer) throw new MtqtInvalidPeerTypeError(userId, 'user') if (!peer) throw new MtInvalidPeerTypeError(userId, 'user')
const res = await this.call({ const res = await this.call({
_: 'contacts.addContact', _: 'contacts.addContact',

View file

@ -1,13 +1,13 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { MaybeArray } from '@mtqt/core' import { MaybeArray } from '@mtcute/core'
import { import {
InputPeerLike, InputPeerLike,
MtqtInvalidPeerTypeError, MtInvalidPeerTypeError,
MtqtTypeAssertionError, MtTypeAssertionError,
User, User,
} from '../../types' } from '../../types'
import { normalizeToInputUser } from '../../utils/peer-utils' import { normalizeToInputUser } from '../../utils/peer-utils'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { assertIsUpdatesGroup } from '../../utils/updates-utils' import { assertIsUpdatesGroup } from '../../utils/updates-utils'
/** /**
@ -52,7 +52,7 @@ export async function deleteContacts(
) )
if (single && !inputPeers.length) if (single && !inputPeers.length)
throw new MtqtInvalidPeerTypeError( throw new MtInvalidPeerTypeError(
(userIds as InputPeerLike[])[0], (userIds as InputPeerLike[])[0],
'user' 'user'
) )

View file

@ -1,7 +1,7 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { User } from '../../types' import { User } from '../../types'
import { assertTypeIs } from '../../utils/type-assertion' import { assertTypeIs } from '../../utils/type-assertion'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
/** /**
* Get list of contacts from your Telegram contacts list. * Get list of contacts from your Telegram contacts list.

View file

@ -1,6 +1,6 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { PartialOnly } from '@mtqt/core' import { PartialOnly } from '@mtcute/core'
import bigInt from 'big-integer' import bigInt from 'big-integer'
/** /**

View file

@ -1,6 +1,6 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { Conversation, Message } from '../../types' import { Conversation, Message } from '../../types'
import { getMarkedPeerId } from '@mtqt/core' import { getMarkedPeerId } from '@mtcute/core'
// @extension // @extension
interface ConversationsState { interface ConversationsState {

View file

@ -1,6 +1,6 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { PartialExcept } from '@mtqt/core' import { PartialExcept } from '@mtcute/core'
/** /**
* Create a folder from given parameters * Create a folder from given parameters

View file

@ -1,5 +1,5 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
/** /**
* Delete a folder by its ID * Delete a folder by its ID

View file

@ -1,6 +1,6 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { MtqtArgumentError } from '../../types' import { MtArgumentError } from '../../types'
/** /**
* Edit a folder with given modification * Edit a folder with given modification
@ -23,7 +23,7 @@ export async function editFolder(
const old = await this.getFolders() const old = await this.getFolders()
const found = old.find((it) => it.id === folder || it.title === folder) const found = old.find((it) => it.id === folder || it.title === folder)
if (!found) if (!found)
throw new MtqtArgumentError(`Could not find a folder ${folder}`) throw new MtArgumentError(`Could not find a folder ${folder}`)
folder = found folder = found
} }

View file

@ -1,6 +1,6 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { MtqtArgumentError } from '../../types' import { MtArgumentError } from '../../types'
/** /**
* Find a folder by its parameter. * Find a folder by its parameter.
@ -21,7 +21,7 @@ export async function findFolder(
} }
): Promise<tl.RawDialogFilter | null> { ): Promise<tl.RawDialogFilter | null> {
if (!params.title && !params.emoji && !params.id) if (!params.title && !params.emoji && !params.id)
throw new MtqtArgumentError('One of search parameters must be passed') throw new MtArgumentError('One of search parameters must be passed')
const folders = await this.getFolders() const folders = await this.getFolders()

View file

@ -1,13 +1,13 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { import {
Dialog, Dialog,
MtqtArgumentError, MtArgumentError,
MtqtTypeAssertionError, MtTypeAssertionError,
} from '../../types' } from '../../types'
import { normalizeDate } from '../../utils/misc-utils' import { normalizeDate } from '../../utils/misc-utils'
import { createUsersChatsIndex } from '../../utils/peer-utils' import { createUsersChatsIndex } from '../../utils/peer-utils'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { getMarkedPeerId } from '@mtqt/core' import { getMarkedPeerId } from '@mtcute/core'
/** /**
* Iterate over dialogs. * Iterate over dialogs.
@ -103,7 +103,7 @@ export async function* getDialogs(
* use {@link Dialog.filterFolder} instead. * use {@link Dialog.filterFolder} instead.
* *
* When a folder with given ID or title is not found, * When a folder with given ID or title is not found,
* {@link MtqtArgumentError} is thrown * {@link MtArgumentError} is thrown
* *
* By default fetches from "All" folder * By default fetches from "All" folder
*/ */
@ -132,7 +132,7 @@ export async function* getDialogs(
(it) => it.id === params!.folder || it.title === params!.folder (it) => it.id === params!.folder || it.title === params!.folder
) )
if (!found) if (!found)
throw new MtqtArgumentError( throw new MtArgumentError(
`Could not find folder ${params.folder}` `Could not find folder ${params.folder}`
) )

View file

@ -1,5 +1,5 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
/** /**
* Get list of folders. * Get list of folders.

View file

@ -3,7 +3,7 @@ import {
Dialog, Dialog,
InputPeerLike, InputPeerLike,
} from '../../types' } from '../../types'
import { MaybeArray } from '@mtqt/core' import { MaybeArray } from '@mtcute/core'
/** /**
* Get dialogs with certain peers. * Get dialogs with certain peers.

View file

@ -1,8 +1,8 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { Dialog, MtqtTypeAssertionError } from '../../types' import { Dialog, MtTypeAssertionError } from '../../types'
import { createUsersChatsIndex } from '../../utils/peer-utils' import { createUsersChatsIndex } from '../../utils/peer-utils'
import { getMarkedPeerId } from '@mtqt/core' import { getMarkedPeerId } from '@mtcute/core'
/** @internal */ /** @internal */
export function _parseDialogs( export function _parseDialogs(
@ -10,7 +10,7 @@ export function _parseDialogs(
res: tl.messages.TypeDialogs | tl.messages.TypePeerDialogs res: tl.messages.TypeDialogs | tl.messages.TypePeerDialogs
): Dialog[] { ): Dialog[] {
if (res._ === 'messages.dialogsNotModified') if (res._ === 'messages.dialogsNotModified')
throw new MtqtTypeAssertionError( throw new MtTypeAssertionError(
'messages.getPeerDialogs', 'messages.getPeerDialogs',
'!messages.dialogsNotModified', '!messages.dialogsNotModified',
'messages.dialogsNotModified' 'messages.dialogsNotModified'

View file

@ -1,4 +1,4 @@
import { TelegramConnection } from '@mtqt/core' import { TelegramConnection } from '@mtcute/core'
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'

View file

@ -1,6 +1,6 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { import {
MtqtUnsupportedError, MtUnsupportedError,
FileDownloadParameters, FileDownloadParameters,
FileLocation, FileLocation,
} from '../../types' } from '../../types'
@ -24,7 +24,7 @@ export function downloadToFile(
params: FileDownloadParameters params: FileDownloadParameters
): Promise<void> { ): Promise<void> {
if (!fs) if (!fs)
throw new MtqtUnsupportedError( throw new MtUnsupportedError(
'Downloading to file is only supported in NodeJS' 'Downloading to file is only supported in NodeJS'
) )

View file

@ -1,10 +1,10 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { determinePartSize } from '../../utils/file-utils' import { determinePartSize } from '../../utils/file-utils'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { FileMigrateError, FilerefUpgradeNeededError } from '@mtqt/tl/errors' import { FileMigrateError, FilerefUpgradeNeededError } from '@mtcute/tl/errors'
import { import {
MtqtArgumentError, MtArgumentError,
MtqtUnsupportedError, MtUnsupportedError,
FileDownloadParameters, FileDownloadParameters,
FileLocation, FileLocation,
} from '../../types' } from '../../types'
@ -12,7 +12,7 @@ import {
fileIdToInputFileLocation, fileIdToInputFileLocation,
fileIdToInputWebFileLocation, fileIdToInputWebFileLocation,
parseFileId, parseFileId,
} from '@mtqt/file-id' } from '@mtcute/file-id'
/** /**
* Download a file and return it as an iterable, which yields file contents * Download a file and return it as an iterable, which yields file contents
@ -30,13 +30,13 @@ export async function* downloadAsIterable(
params.partSize ?? params.partSize ??
(params.fileSize ? determinePartSize(params.fileSize) : 64) (params.fileSize ? determinePartSize(params.fileSize) : 64)
if (partSizeKb % 4 !== 0) if (partSizeKb % 4 !== 0)
throw new MtqtArgumentError( throw new MtArgumentError(
`Invalid part size: ${partSizeKb}. Must be divisible by 4.` `Invalid part size: ${partSizeKb}. Must be divisible by 4.`
) )
let offset = params.offset ?? 0 let offset = params.offset ?? 0
if (offset % 4096 !== 0) if (offset % 4096 !== 0)
throw new MtqtArgumentError( throw new MtArgumentError(
`Invalid offset: ${offset}. Must be divisible by 4096` `Invalid offset: ${offset}. Must be divisible by 4096`
) )
@ -112,7 +112,7 @@ export async function* downloadAsIterable(
} else if (e.constructor === FilerefUpgradeNeededError) { } else if (e.constructor === FilerefUpgradeNeededError) {
// todo: implement someday // todo: implement someday
// see: https://github.com/LonamiWebs/Telethon/blob/0e8bd8248cc649637b7c392616887c50986427a0/telethon/client/downloads.py#L99 // see: https://github.com/LonamiWebs/Telethon/blob/0e8bd8248cc649637b7c392616887c50986427a0/telethon/client/downloads.py#L99
throw new MtqtUnsupportedError('File ref expired!') throw new MtUnsupportedError('File ref expired!')
} else throw e } else throw e
} }
@ -120,7 +120,7 @@ export async function* downloadAsIterable(
// we shouldnt receive them since cdnSupported is not set in the getFile request. // we shouldnt receive them since cdnSupported is not set in the getFile request.
// also, i couldnt find any media that would be downloaded from cdn, so even if // also, i couldnt find any media that would be downloaded from cdn, so even if
// i implemented that, i wouldnt be able to test that, so :shrug: // i implemented that, i wouldnt be able to test that, so :shrug:
throw new MtqtUnsupportedError( throw new MtUnsupportedError(
'Received CDN redirect, which is not supported (yet)' 'Received CDN redirect, which is not supported (yet)'
) )
} }

View file

@ -1,6 +1,6 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { InputFileLike } from '../../types' import { InputFileLike } from '../../types'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { assertTypeIs } from '../../utils/type-assertion' import { assertTypeIs } from '../../utils/type-assertion'
/** /**

View file

@ -1,7 +1,7 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { InputFileLike, isUploadedFile, MtqtArgumentError } from '../../types' import { InputFileLike, isUploadedFile, MtArgumentError } from '../../types'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { tdFileId } from '@mtqt/file-id' import { tdFileId } from '@mtcute/file-id'
/** /**
* Normalize a {@link InputFileLike} to `InputFile`, * Normalize a {@link InputFileLike} to `InputFile`,
@ -20,7 +20,7 @@ export async function _normalizeInputFile(
} }
): Promise<tl.TypeInputFile> { ): Promise<tl.TypeInputFile> {
if (typeof input === 'object' && tl.isAnyInputMedia(input)) { if (typeof input === 'object' && tl.isAnyInputMedia(input)) {
throw new MtqtArgumentError( throw new MtArgumentError(
"InputFile can't be created from an InputMedia" "InputFile can't be created from an InputMedia"
) )
} else if (tdFileId.isFileIdLike(input)) { } else if (tdFileId.isFileIdLike(input)) {
@ -31,7 +31,7 @@ export async function _normalizeInputFile(
}) })
return uploaded.inputFile return uploaded.inputFile
} else { } else {
throw new MtqtArgumentError( throw new MtArgumentError(
"InputFile can't be created from an URL or a File ID" "InputFile can't be created from an URL or a File ID"
) )
} }

View file

@ -2,16 +2,16 @@ import { TelegramClient } from '../../client'
import { import {
InputMediaLike, InputMediaLike,
isUploadedFile, isUploadedFile,
MtqtArgumentError, MtArgumentError,
UploadFileLike, UploadFileLike,
} from '../../types' } from '../../types'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { import {
fileIdToInputDocument, fileIdToInputDocument,
fileIdToInputPhoto, fileIdToInputPhoto,
parseFileId, parseFileId,
tdFileId, tdFileId,
} from '@mtqt/file-id' } from '@mtcute/file-id'
import { extractFileName } from '../../utils/file-utils' import { extractFileName } from '../../utils/file-utils'
import { assertTypeIs } from '../../utils/type-assertion' import { assertTypeIs } from '../../utils/type-assertion'
import bigInt from 'big-integer' import bigInt from 'big-integer'

View file

@ -9,8 +9,8 @@ import { Readable } from 'stream'
import { determinePartSize, isProbablyPlainText } from '../../utils/file-utils' import { determinePartSize, isProbablyPlainText } from '../../utils/file-utils'
import { randomUlong } from '../../utils/misc-utils' import { randomUlong } from '../../utils/misc-utils'
import { fromBuffer } from 'file-type' import { fromBuffer } from 'file-type'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { MtqtArgumentError, UploadFileLike, UploadedFile } from '../../types' import { MtArgumentError, UploadFileLike, UploadedFile } from '../../types'
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
let fs: any = null let fs: any = null
@ -20,7 +20,7 @@ try {
path = require('path') path = require('path')
} catch (e) {} } catch (e) {}
const debug = require('debug')('mtqt:upload') const debug = require('debug')('mtcute:upload')
const OVERRIDE_MIME: Record<string, string> = { const OVERRIDE_MIME: Record<string, string> = {
// tg doesn't interpret `audio/opus` files as voice messages for some reason // tg doesn't interpret `audio/opus` files as voice messages for some reason
@ -109,7 +109,7 @@ export async function uploadFile(
if (typeof file === 'string') { if (typeof file === 'string') {
if (!fs) if (!fs)
throw new MtqtArgumentError( throw new MtArgumentError(
'Local paths are only supported for NodeJS!' 'Local paths are only supported for NodeJS!'
) )
file = fs.createReadStream(file) file = fs.createReadStream(file)
@ -163,7 +163,7 @@ export async function uploadFile(
} }
if (!file.body) if (!file.body)
throw new MtqtArgumentError('Fetch response contains `null` body') throw new MtArgumentError('Fetch response contains `null` body')
if ( if (
typeof ReadableStream !== 'undefined' && typeof ReadableStream !== 'undefined' &&
@ -188,13 +188,13 @@ export async function uploadFile(
} }
if (!(file instanceof Readable)) if (!(file instanceof Readable))
throw new MtqtArgumentError( throw new MtArgumentError(
'Could not convert input `file` to stream!' 'Could not convert input `file` to stream!'
) )
const partSizeKb = params.partSize ?? determinePartSize(fileSize) const partSizeKb = params.partSize ?? determinePartSize(fileSize)
if (partSizeKb > 512) if (partSizeKb > 512)
throw new MtqtArgumentError(`Invalid part size: ${partSizeKb}KB`) throw new MtArgumentError(`Invalid part size: ${partSizeKb}KB`)
const partSize = partSizeKb * 1024 const partSize = partSizeKb * 1024
const isBig = fileSize > 10485760 // 10 MB const isBig = fileSize > 10485760 // 10 MB
@ -216,14 +216,14 @@ export async function uploadFile(
for (let idx = 0; idx < partCount; idx++) { for (let idx = 0; idx < partCount; idx++) {
const part = await readBytesFromStream(file, partSize) const part = await readBytesFromStream(file, partSize)
if (!part) if (!part)
throw new MtqtArgumentError( throw new MtArgumentError(
`Unexpected EOS (there were only ${idx} parts, but expected ${partCount})` `Unexpected EOS (there were only ${idx} parts, but expected ${partCount})`
) )
if (!Buffer.isBuffer(part)) if (!Buffer.isBuffer(part))
throw new MtqtArgumentError(`Part ${idx} was not a Buffer!`) throw new MtArgumentError(`Part ${idx} was not a Buffer!`)
if (part.length > partSize) if (part.length > partSize)
throw new MtqtArgumentError( throw new MtArgumentError(
`Part ${idx} had invalid size (expected ${partSize}, got ${part.length})` `Part ${idx} had invalid size (expected ${partSize}, got ${part.length})`
) )

View file

@ -2,8 +2,8 @@ import {
InputMediaLike, InputMediaLike,
InputPeerLike, InputPeerLike,
MessageMedia, MessageMedia,
MtqtArgumentError, MtArgumentError,
MtqtTypeAssertionError, MtTypeAssertionError,
Photo, RawDocument, Photo, RawDocument,
} from '../../types' } from '../../types'
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
@ -53,7 +53,7 @@ export async function uploadMedia(
case 'inputMediaInvoice': case 'inputMediaInvoice':
case 'inputMediaPoll': case 'inputMediaPoll':
case 'inputMediaDice': case 'inputMediaDice':
throw new MtqtArgumentError("This media can't be uploaded") throw new MtArgumentError("This media can't be uploaded")
} }
const res = await this.call({ const res = await this.call({
@ -67,7 +67,7 @@ export async function uploadMedia(
}) })
if (res._ === 'messageMediaEmpty') { if (res._ === 'messageMediaEmpty') {
throw new MtqtTypeAssertionError( throw new MtTypeAssertionError(
'uploadMedia', 'uploadMedia',
'not messageMediaEmpty', 'not messageMediaEmpty',
'messageMediaEmpty' 'messageMediaEmpty'

View file

@ -1,7 +1,7 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { ChatInviteLink, InputPeerLike, User } from '../../types' import { ChatInviteLink, InputPeerLike, User } from '../../types'
import { createUsersChatsIndex } from '../../utils/peer-utils' import { createUsersChatsIndex } from '../../utils/peer-utils'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
/** /**
* Iterate over users who have joined * Iterate over users who have joined

View file

@ -2,13 +2,13 @@ import { TelegramClient } from '../../client'
import { import {
ChatInviteLink, ChatInviteLink,
InputPeerLike, InputPeerLike,
MtqtInvalidPeerTypeError, MtInvalidPeerTypeError,
} from '../../types' } from '../../types'
import { import {
createUsersChatsIndex, createUsersChatsIndex,
normalizeToInputUser, normalizeToInputUser,
} from '../../utils/peer-utils' } from '../../utils/peer-utils'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
/** /**
* Get invite links created by some administrator in the chat. * Get invite links created by some administrator in the chat.
@ -55,7 +55,7 @@ export async function* getInviteLinks(
const peer = await this.resolvePeer(chatId) const peer = await this.resolvePeer(chatId)
const admin = normalizeToInputUser(await this.resolvePeer(adminId)) const admin = normalizeToInputUser(await this.resolvePeer(adminId))
if (!admin) throw new MtqtInvalidPeerTypeError(adminId, 'user') if (!admin) throw new MtInvalidPeerTypeError(adminId, 'user')
let offsetDate: number | undefined = undefined let offsetDate: number | undefined = undefined
let offsetLink: string | undefined = undefined let offsetLink: string | undefined = undefined

View file

@ -2,7 +2,7 @@ import { TelegramClient } from '../../client'
import { import {
ChatInviteLink, ChatInviteLink,
InputPeerLike, InputPeerLike,
MtqtTypeAssertionError, MtTypeAssertionError,
} from '../../types' } from '../../types'
import { createUsersChatsIndex } from '../../utils/peer-utils' import { createUsersChatsIndex } from '../../utils/peer-utils'
@ -25,7 +25,7 @@ export async function getPrimaryInviteLink(
}) })
if (!res.invites[0]?.permanent) if (!res.invites[0]?.permanent)
throw new MtqtTypeAssertionError( throw new MtTypeAssertionError(
'messages.getExportedChatInvites (@ .invites[0].permanent)', 'messages.getExportedChatInvites (@ .invites[0].permanent)',
'true', 'true',
'false' 'false'

View file

@ -1,5 +1,5 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { InputPeerLike, MtqtTypeAssertionError, Poll } from '../../types' import { InputPeerLike, MtTypeAssertionError, Poll } from '../../types'
import { createUsersChatsIndex } from '../../utils/peer-utils' import { createUsersChatsIndex } from '../../utils/peer-utils'
import bigInt from 'big-integer' import bigInt from 'big-integer'
import { assertTypeIs } from '../../utils/type-assertion' import { assertTypeIs } from '../../utils/type-assertion'
@ -47,7 +47,7 @@ export async function closePoll(
'updateMessagePoll' 'updateMessagePoll'
) )
if (!upd.poll) { if (!upd.poll) {
throw new MtqtTypeAssertionError( throw new MtTypeAssertionError(
'messages.editMessage (@ .updates[0].poll)', 'messages.editMessage (@ .updates[0].poll)',
'poll', 'poll',
'undefined' 'undefined'

View file

@ -1,6 +1,6 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { InputPeerLike } from '../../types' import { InputPeerLike } from '../../types'
import { MaybeArray } from '@mtqt/core' import { MaybeArray } from '@mtcute/core'
import { import {
isInputPeerChannel, isInputPeerChannel,
normalizeToInputChannel, normalizeToInputChannel,

View file

@ -1,6 +1,6 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { InputPeerLike } from '../../types' import { InputPeerLike } from '../../types'
import { MaybeArray } from '@mtqt/core' import { MaybeArray } from '@mtcute/core'
import { import {
isInputPeerChannel, isInputPeerChannel,
normalizeToInputChannel, normalizeToInputChannel,

View file

@ -1,6 +1,6 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { BotKeyboard, FormattedString, InputMediaLike, ReplyMarkup } from '../../types' import { BotKeyboard, FormattedString, InputMediaLike, ReplyMarkup } from '../../types'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
/** /**
* Edit sent inline message text, media and reply markup. * Edit sent inline message text, media and reply markup.

View file

@ -6,7 +6,7 @@ import {
Message, Message,
ReplyMarkup, ReplyMarkup,
} from '../../types' } from '../../types'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
/** /**
* Edit message text, media, reply markup and schedule date. * Edit message text, media, reply markup and schedule date.

View file

@ -1,6 +1,6 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { Message, MtqtTypeAssertionError } from '../../types' import { Message, MtTypeAssertionError } from '../../types'
import { createUsersChatsIndex } from '../../utils/peer-utils' import { createUsersChatsIndex } from '../../utils/peer-utils'
import { assertIsUpdatesGroup } from '../../utils/updates-utils' import { assertIsUpdatesGroup } from '../../utils/updates-utils'
@ -36,7 +36,7 @@ export function _findMessageInUpdate(
} }
} }
throw new MtqtTypeAssertionError( throw new MtTypeAssertionError(
'_findInUpdate (@ .updates[*])', '_findInUpdate (@ .updates[*])',
'updateNewMessage | updateNewChannelMessage | updateNewScheduledMessage', 'updateNewMessage | updateNewChannelMessage | updateNewScheduledMessage',
'none' 'none'

View file

@ -4,11 +4,11 @@ import {
InputMediaLike, InputMediaLike,
InputPeerLike, InputPeerLike,
Message, Message,
MtqtArgumentError, MtArgumentError,
MtqtTypeAssertionError, MtTypeAssertionError,
} from '../../types' } from '../../types'
import { MaybeArray } from '@mtqt/core' import { MaybeArray } from '@mtcute/core'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { createUsersChatsIndex } from '../../utils/peer-utils' import { createUsersChatsIndex } from '../../utils/peer-utils'
import { normalizeDate, randomUlong } from '../../utils/misc-utils' import { normalizeDate, randomUlong } from '../../utils/misc-utils'
import { assertIsUpdatesGroup } from '../../utils/updates-utils' import { assertIsUpdatesGroup } from '../../utils/updates-utils'
@ -197,7 +197,7 @@ export async function forwardMessages(
// error, instead only first 100 IDs will be forwarded, // error, instead only first 100 IDs will be forwarded,
// which is definitely not the best outcome. // which is definitely not the best outcome.
if ((messages as number[]).length > 100) if ((messages as number[]).length > 100)
throw new MtqtArgumentError( throw new MtArgumentError(
'You can forward no more than 100 messages at once' 'You can forward no more than 100 messages at once'
) )
@ -206,7 +206,7 @@ export async function forwardMessages(
let captionMessage: Message | null = null let captionMessage: Message | null = null
if (params.caption) { if (params.caption) {
if (params.captionMedia) if (params.captionMedia)
throw new MtqtArgumentError( throw new MtArgumentError(
'You can either pass `caption` or `captionMedia`' 'You can either pass `caption` or `captionMedia`'
) )

View file

@ -1,6 +1,6 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { InputPeerLike, Message } from '../../types' import { InputPeerLike, Message } from '../../types'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { createUsersChatsIndex } from '../../utils/peer-utils' import { createUsersChatsIndex } from '../../utils/peer-utils'
/** @internal */ /** @internal */

View file

@ -1,5 +1,5 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { InputPeerLike, Message, MtqtTypeAssertionError } from '../../types' import { InputPeerLike, Message, MtTypeAssertionError } from '../../types'
import { createUsersChatsIndex } from '../../utils/peer-utils' import { createUsersChatsIndex } from '../../utils/peer-utils'
import { normalizeDate } from '../../utils/misc-utils' import { normalizeDate } from '../../utils/misc-utils'
@ -74,7 +74,7 @@ export async function getHistory(
}) })
if (res._ === 'messages.messagesNotModified') if (res._ === 'messages.messagesNotModified')
throw new MtqtTypeAssertionError( throw new MtTypeAssertionError(
'messages.getHistory', 'messages.getHistory',
'!messages.messagesNotModified', '!messages.messagesNotModified',
res._ res._

View file

@ -1,5 +1,5 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { InputPeerLike, MtqtArgumentError, Message } from '../../types' import { InputPeerLike, MtArgumentError, Message } from '../../types'
import { isInputPeerChannel } from '../../utils/peer-utils' import { isInputPeerChannel } from '../../utils/peer-utils'
/** /**
@ -32,7 +32,7 @@ export async function getMessageGroup(
const messages = await this.getMessages(chatId, ids) const messages = await this.getMessages(chatId, ids)
const groupedId = messages.find((it) => it?.id === message)!.groupedId const groupedId = messages.find((it) => it?.id === message)!.groupedId
if (!groupedId) throw new MtqtArgumentError('This message is not grouped') if (!groupedId) throw new MtArgumentError('This message is not grouped')
return messages.filter( return messages.filter(
(it) => it && it.groupedId?.eq(groupedId) (it) => it && it.groupedId?.eq(groupedId)

View file

@ -1,10 +1,10 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { MaybeArray } from '@mtqt/core' import { MaybeArray } from '@mtcute/core'
import { import {
createUsersChatsIndex, createUsersChatsIndex,
} from '../../utils/peer-utils' } from '../../utils/peer-utils'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { Message, MtqtTypeAssertionError } from '../../types' import { Message, MtTypeAssertionError } from '../../types'
/** /**
* Get a single message from PM or legacy group by its ID. * Get a single message from PM or legacy group by its ID.
@ -67,7 +67,7 @@ export async function getMessagesUnsafe(
}) })
if (res._ === 'messages.messagesNotModified') if (res._ === 'messages.messagesNotModified')
throw new MtqtTypeAssertionError( throw new MtTypeAssertionError(
'getMessages', 'getMessages',
'!messages.messagesNotModified', '!messages.messagesNotModified',
res._ res._

View file

@ -1,12 +1,12 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { MaybeArray } from '@mtqt/core' import { MaybeArray } from '@mtcute/core'
import { import {
createUsersChatsIndex, createUsersChatsIndex,
isInputPeerChannel, isInputPeerChannel,
normalizeToInputChannel, normalizeToInputChannel,
} from '../../utils/peer-utils' } from '../../utils/peer-utils'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { Message, InputPeerLike, MtqtTypeAssertionError } from '../../types' import { Message, InputPeerLike, MtTypeAssertionError } from '../../types'
/** /**
* Get a single message in chat by its ID * Get a single message in chat by its ID
@ -78,7 +78,7 @@ export async function getMessages(
) )
if (res._ === 'messages.messagesNotModified') if (res._ === 'messages.messagesNotModified')
throw new MtqtTypeAssertionError( throw new MtTypeAssertionError(
'getMessages', 'getMessages',
'!messages.messagesNotModified', '!messages.messagesNotModified',
res._ res._

View file

@ -1,12 +1,12 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { MaybeArray } from '@mtqt/core' import { MaybeArray } from '@mtcute/core'
import { import {
createUsersChatsIndex, createUsersChatsIndex,
isInputPeerChannel, isInputPeerChannel,
normalizeToInputChannel, normalizeToInputChannel,
} from '../../utils/peer-utils' } from '../../utils/peer-utils'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { Message, InputPeerLike, MtqtTypeAssertionError } from '../../types' import { Message, InputPeerLike, MtTypeAssertionError } from '../../types'
/** /**
* Get a single scheduled message in chat by its ID * Get a single scheduled message in chat by its ID
@ -54,7 +54,7 @@ export async function getScheduledMessages(
}) })
if (res._ === 'messages.messagesNotModified') if (res._ === 'messages.messagesNotModified')
throw new MtqtTypeAssertionError( throw new MtTypeAssertionError(
'getMessages', 'getMessages',
'!messages.messagesNotModified', '!messages.messagesNotModified',
res._ res._

View file

@ -1,6 +1,6 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { TelegramConnection } from '@mtqt/core' import { TelegramConnection } from '@mtcute/core'
import { parseInlineMessageId } from '../../utils/inline-utils' import { parseInlineMessageId } from '../../utils/inline-utils'
// @extension // @extension

View file

@ -1,7 +1,7 @@
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { normalizeToInputUser } from '../../utils/peer-utils' import { normalizeToInputUser } from '../../utils/peer-utils'
import { FormattedString, MtqtError } from '../../types' import { FormattedString, MtClientError } from '../../types'
const empty: [string, undefined] = ['', undefined] const empty: [string, undefined] = ['', undefined]
@ -29,7 +29,7 @@ export async function _parseEntities(
if (!mode) return [text, []] if (!mode) return [text, []]
if (!(mode in this._parseModes)) { if (!(mode in this._parseModes)) {
throw new MtqtError(`Parse mode ${mode} is not registered.`) throw new MtClientError(`Parse mode ${mode} is not registered.`)
} }
;[text, entities] = await this._parseModes[mode].parse(text) ;[text, entities] = await this._parseModes[mode].parse(text)

View file

@ -1,6 +1,6 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { Message, MtqtTypeAssertionError } from '../../types' import { Message, MtTypeAssertionError } from '../../types'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { createUsersChatsIndex } from '../../utils/peer-utils' import { createUsersChatsIndex } from '../../utils/peer-utils'
import { SearchFilters } from '../../types' import { SearchFilters } from '../../types'
@ -71,7 +71,7 @@ export async function* searchGlobal(
}) })
if (res._ === 'messages.messagesNotModified') if (res._ === 'messages.messagesNotModified')
throw new MtqtTypeAssertionError( throw new MtTypeAssertionError(
'messages.searchGlobal', 'messages.searchGlobal',
'!messages.messagesNotModified', '!messages.messagesNotModified',
res._ res._

View file

@ -1,6 +1,6 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { InputPeerLike, Message, MtqtTypeAssertionError } from '../../types' import { InputPeerLike, Message, MtTypeAssertionError } from '../../types'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { createUsersChatsIndex } from '../../utils/peer-utils' import { createUsersChatsIndex } from '../../utils/peer-utils'
import { SearchFilters } from '../../types' import { SearchFilters } from '../../types'
@ -92,7 +92,7 @@ export async function* searchMessages(
}) })
if (res._ === 'messages.messagesNotModified') if (res._ === 'messages.messagesNotModified')
throw new MtqtTypeAssertionError( throw new MtTypeAssertionError(
'messages.search', 'messages.search',
'!messages.messagesNotModified', '!messages.messagesNotModified',
res._ res._

View file

@ -1,7 +1,7 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { InputPeerLike, Message, FormattedString, ReplyMarkup } from '../../types' import { InputPeerLike, Message, FormattedString, ReplyMarkup } from '../../types'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { MessageNotFoundError } from '@mtqt/tl/errors' import { MessageNotFoundError } from '@mtcute/tl/errors'
/** /**
* Copy a message (i.e. send the same message, * Copy a message (i.e. send the same message,

View file

@ -3,7 +3,7 @@ import {
BotKeyboard, InputFileLike, BotKeyboard, InputFileLike,
InputMediaLike, InputMediaLike,
InputPeerLike, InputPeerLike,
Message, MtqtArgumentError, Message, MtArgumentError,
ReplyMarkup, ReplyMarkup,
} from '../../types' } from '../../types'
import { import {
@ -11,10 +11,10 @@ import {
normalizeMessageId, normalizeMessageId,
randomUlong, randomUlong,
} from '../../utils/misc-utils' } from '../../utils/misc-utils'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { assertIsUpdatesGroup } from '../../utils/updates-utils' import { assertIsUpdatesGroup } from '../../utils/updates-utils'
import { createUsersChatsIndex } from '../../utils/peer-utils' import { createUsersChatsIndex } from '../../utils/peer-utils'
import { MessageNotFoundError } from '@mtqt/tl/errors' import { MessageNotFoundError } from '@mtcute/tl/errors'
/** /**
* Send a group of media. * Send a group of media.
@ -124,7 +124,7 @@ export async function sendMediaGroup(
if (params.mustReply) { if (params.mustReply) {
if (!replyTo) if (!replyTo)
throw new MtqtArgumentError( throw new MtArgumentError(
'mustReply used, but replyTo was not passed' 'mustReply used, but replyTo was not passed'
) )

View file

@ -3,7 +3,7 @@ import {
BotKeyboard, FormattedString, BotKeyboard, FormattedString,
InputMediaLike, InputMediaLike,
InputPeerLike, InputPeerLike,
Message, MtqtArgumentError, Message, MtArgumentError,
ReplyMarkup, ReplyMarkup,
} from '../../types' } from '../../types'
import { import {
@ -11,8 +11,8 @@ import {
normalizeMessageId, normalizeMessageId,
randomUlong, randomUlong,
} from '../../utils/misc-utils' } from '../../utils/misc-utils'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { MessageNotFoundError } from '@mtqt/tl/errors' import { MessageNotFoundError } from '@mtcute/tl/errors'
/** /**
* Send a single media (a photo or a document-based media) * Send a single media (a photo or a document-based media)
@ -151,7 +151,7 @@ export async function sendMedia(
if (params.mustReply) { if (params.mustReply) {
if (!replyTo) if (!replyTo)
throw new MtqtArgumentError( throw new MtArgumentError(
'mustReply used, but replyTo was not passed' 'mustReply used, but replyTo was not passed'
) )

View file

@ -1,5 +1,5 @@
import { InputPeerLike, Message } from '../../types' import { InputPeerLike, Message } from '../../types'
import { MaybeArray } from '@mtqt/core' import { MaybeArray } from '@mtcute/core'
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { assertIsUpdatesGroup } from '../../utils/updates-utils' import { assertIsUpdatesGroup } from '../../utils/updates-utils'
import { createUsersChatsIndex } from '../../utils/peer-utils' import { createUsersChatsIndex } from '../../utils/peer-utils'

View file

@ -1,5 +1,5 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { inputPeerToPeer } from '../../utils/peer-utils' import { inputPeerToPeer } from '../../utils/peer-utils'
import { import {
normalizeDate, normalizeDate,
@ -12,11 +12,11 @@ import {
BotKeyboard, BotKeyboard,
ReplyMarkup, ReplyMarkup,
UsersIndex, UsersIndex,
MtqtTypeAssertionError, MtTypeAssertionError,
ChatsIndex, ChatsIndex,
MtqtArgumentError, FormattedString, MtArgumentError, FormattedString,
} from '../../types' } from '../../types'
import { getMarkedPeerId, MessageNotFoundError } from '@mtqt/core' import { getMarkedPeerId, MessageNotFoundError } from '@mtcute/core'
import { createDummyUpdate } from '../../utils/updates-utils' import { createDummyUpdate } from '../../utils/updates-utils'
/** /**
@ -127,7 +127,7 @@ export async function sendText(
if (params.mustReply) { if (params.mustReply) {
if (!replyTo) if (!replyTo)
throw new MtqtArgumentError( throw new MtArgumentError(
'mustReply used, but replyTo was not passed' 'mustReply used, but replyTo was not passed'
) )
@ -197,7 +197,7 @@ export async function sendText(
} }
if (!cached) { if (!cached) {
throw new MtqtTypeAssertionError( throw new MtTypeAssertionError(
'sendText (@ getFullPeerById)', 'sendText (@ getFullPeerById)',
'user | chat', 'user | chat',
'null' 'null'
@ -215,7 +215,7 @@ export async function sendText(
chats[cached.id] = cached chats[cached.id] = cached
break break
default: default:
throw new MtqtTypeAssertionError( throw new MtTypeAssertionError(
'sendText (@ users.getUsers)', 'sendText (@ users.getUsers)',
'user | chat | channel', // not very accurate, but good enough 'user | chat | channel', // not very accurate, but good enough
cached._ cached._

View file

@ -1,5 +1,5 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { InputPeerLike, TypingStatus } from '../../types' import { InputPeerLike, TypingStatus } from '../../types'
/** /**

View file

@ -1,11 +1,11 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { import {
InputPeerLike, InputPeerLike,
MtqtArgumentError, MtArgumentError,
MtqtTypeAssertionError, MtTypeAssertionError,
Poll, Poll,
} from '../../types' } from '../../types'
import { MaybeArray, MessageNotFoundError } from '@mtqt/core' import { MaybeArray, MessageNotFoundError } from '@mtcute/core'
import { createUsersChatsIndex } from '../../utils/peer-utils' import { createUsersChatsIndex } from '../../utils/peer-utils'
import { assertTypeIs } from '../../utils/type-assertion' import { assertTypeIs } from '../../utils/type-assertion'
import { assertIsUpdatesGroup } from '../../utils/updates-utils' import { assertIsUpdatesGroup } from '../../utils/updates-utils'
@ -40,7 +40,7 @@ export async function sendVote(
if (!msg) throw new MessageNotFoundError() if (!msg) throw new MessageNotFoundError()
if (!(msg.media instanceof Poll)) if (!(msg.media instanceof Poll))
throw new MtqtArgumentError( throw new MtArgumentError(
'This message does not contain a poll' 'This message does not contain a poll'
) )
@ -67,7 +67,7 @@ export async function sendVote(
const upd = res.updates[0] const upd = res.updates[0]
assertTypeIs('messages.sendVote (@ .updates[0])', upd, 'updateMessagePoll') assertTypeIs('messages.sendVote (@ .updates[0])', upd, 'updateMessagePoll')
if (!upd.poll) { if (!upd.poll) {
throw new MtqtTypeAssertionError( throw new MtTypeAssertionError(
'messages.sendVote (@ .updates[0].poll)', 'messages.sendVote (@ .updates[0].poll)',
'poll', 'poll',
'undefined' 'undefined'

View file

@ -1,5 +1,5 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { tl } from '@mtqt/tl' import { tl } from '@mtcute/tl'
import { TakeoutSession } from '../../types' import { TakeoutSession } from '../../types'
/** /**

View file

@ -1,5 +1,5 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { MtqtError, IMessageEntityParser } from '../../types' import { MtClientError, IMessageEntityParser } from '../../types'
/** /**
* Register a given {@link IMessageEntityParser} as a parse mode * Register a given {@link IMessageEntityParser} as a parse mode
@ -7,7 +7,7 @@ import { MtqtError, IMessageEntityParser } from '../../types'
* mode is also set as default. * mode is also set as default.
* *
* @param parseMode Parse mode to register * @param parseMode Parse mode to register
* @throws MtqtError When the parse mode with a given name is already registered. * @throws MtClientError When the parse mode with a given name is already registered.
* @internal * @internal
*/ */
export function registerParseMode( export function registerParseMode(
@ -17,7 +17,7 @@ export function registerParseMode(
const name = parseMode.name const name = parseMode.name
if (name in this._parseModes) { if (name in this._parseModes) {
throw new MtqtError( throw new MtClientError(
`Parse mode ${name} is already registered. Unregister it first!` `Parse mode ${name} is already registered. Unregister it first!`
) )
} }
@ -49,8 +49,8 @@ export function unregisterParseMode(this: TelegramClient, name: string): void {
* Get a {@link IMessageEntityParser} registered under a given name (or a default one). * Get a {@link IMessageEntityParser} registered under a given name (or a default one).
* *
* @param name Name of the parse mode which parser to get. * @param name Name of the parse mode which parser to get.
* @throws MtqtError When the provided parse mode is not registered * @throws MtClientError When the provided parse mode is not registered
* @throws MtqtError When `name` is omitted and there is no default parse mode * @throws MtClientError When `name` is omitted and there is no default parse mode
* @internal * @internal
*/ */
export function getParseMode( export function getParseMode(
@ -59,13 +59,13 @@ export function getParseMode(
): IMessageEntityParser { ): IMessageEntityParser {
if (!name) { if (!name) {
if (!this._defaultParseMode) if (!this._defaultParseMode)
throw new MtqtError('There is no default parse mode') throw new MtClientError('There is no default parse mode')
name = this._defaultParseMode name = this._defaultParseMode
} }
if (!(name in this._parseModes)) { if (!(name in this._parseModes)) {
throw new MtqtError(`Parse mode ${name} is not registered.`) throw new MtClientError(`Parse mode ${name} is not registered.`)
} }
return this._parseModes[name] return this._parseModes[name]
@ -75,12 +75,12 @@ export function getParseMode(
* Set a given parse mode as a default one. * Set a given parse mode as a default one.
* *
* @param name Name of the parse mode * @param name Name of the parse mode
* @throws MtqtError When given parse mode is not registered. * @throws MtClientError When given parse mode is not registered.
* @internal * @internal
*/ */
export function setDefaultParseMode(this: TelegramClient, name: string): void { export function setDefaultParseMode(this: TelegramClient, name: string): void {
if (!(name in this._parseModes)) { if (!(name in this._parseModes)) {
throw new MtqtError(`Parse mode ${name} is not registered.`) throw new MtClientError(`Parse mode ${name} is not registered.`)
} }
this._defaultParseMode = name this._defaultParseMode = name

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