build: renamed to mtqt

This commit is contained in:
teidesu 2021-07-25 21:03:40 +03:00
parent 7775ff4eaa
commit 2f1c8548a0
275 changed files with 787 additions and 785 deletions

View file

@ -1,10 +1,10 @@
# MTCute # mtqt
![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://www.notion.so/teidesu/MTCute-development-cfccff4fddad4b218f3bea27f784b8b5) [🎯 Roadmap (notion.so)](https://teidesu.notion.site/mtqt-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/teidesu/mtcute git clone https://github.com/mtqt-dev/mtqt
cd mtcute cd mtqt
yarn install yarn install
npx lerna link npx lerna link
@ -44,6 +44,7 @@ yarn generate-code
Some parts were based on code from these projects: Some parts were based on code from these projects:
- [Pyrogram](https://pyrogram.org) - [TDLib](https://github.com/tdlib/td)
- [Pyrogram](https://github.com/pyrogram/pyrogram)
- [Telethon](https://github.com/LonamiWebs/Telethon) - [Telethon](https://github.com/LonamiWebs/Telethon)
- [TDesktop](https://github.com/telegramdesktop/tdesktop) - [TDesktop](https://github.com/telegramdesktop/tdesktop)

View file

@ -1,8 +1,8 @@
{ {
"name": "mtcute", "name": "mtqt",
"private": true, "private": true,
"version": "1.0.0", "version": "1.0.0",
"description": "Cute and type-safe library for MTProto (Telegram API) for browser and NodeJS", "description": "Type-safe library for MTProto (Telegram API) for browser and NodeJS",
"license": "LGPL-3.0", "license": "LGPL-3.0",
"author": "Alisa Sireneva <me@tei.su>", "author": "Alisa Sireneva <me@tei.su>",
"scripts": { "scripts": {

View file

@ -1,8 +1,8 @@
{ {
"name": "@mtcute/client", "name": "@mtqt/client",
"private": true, "private": true,
"version": "1.0.0", "version": "1.0.0",
"description": "High-level API over @mtcute/core", "description": "High-level API over @mtqt/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",
"@mtcute/tl": "~1.131.0", "@mtqt/tl": "~1.131.0",
"@mtcute/core": "^1.0.0", "@mtqt/core": "^1.0.0",
"@mtcute/file-id": "^1.0.0", "@mtqt/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 '@mtcute/core'\n" + "import { BaseTelegramClient } from '@mtqt/core'\n" +
"import { tl } from '@mtcute/tl'" "import { tl } from '@mtqt/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 '@mtcute/core' import { BaseTelegramClient } from '@mtqt/core'
import { tl } from '@mtcute/tl' import { tl } from '@mtqt/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'
@ -224,8 +224,8 @@ import {
MaybeArray, MaybeArray,
MaybeAsync, MaybeAsync,
TelegramConnection, TelegramConnection,
} from '@mtcute/core' } from '@mtqt/core'
import { tdFileId } from '@mtcute/file-id' import { tdFileId } from '@mtqt/file-id'
export interface TelegramClient extends BaseTelegramClient { export interface TelegramClient extends BaseTelegramClient {
/** /**
@ -1198,8 +1198,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 MtCuteArgumentError In case invite link has invalid format * @throws MtqtArgumentError In case invite link has invalid format
* @throws MtCuteNotFoundError * @throws MtqtNotFoundError
* 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.
*/ */
@ -1208,7 +1208,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 MtCuteArgumentError * @throws MtqtArgumentError
* 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.
*/ */
@ -1217,7 +1217,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 MtCuteArgumentError * @throws MtqtArgumentError
* 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.
*/ */
@ -1625,7 +1625,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 MtCuteArgumentError} is thrown * {@link MtqtArgumentError} is thrown
* *
* By default fetches from "All" folder * By default fetches from "All" folder
*/ */
@ -3005,7 +3005,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 MtCuteError When the parse mode with a given name is already registered. * @throws MtqtError When the parse mode with a given name is already registered.
*/ */
registerParseMode(parseMode: IMessageEntityParser): void registerParseMode(parseMode: IMessageEntityParser): void
/** /**
@ -3021,15 +3021,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 MtCuteError When the provided parse mode is not registered * @throws MtqtError When the provided parse mode is not registered
* @throws MtCuteError When `name` is omitted and there is no default parse mode * @throws MtqtError 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 MtCuteError When given parse mode is not registered. * @throws MtqtError When given parse mode is not registered.
*/ */
setDefaultParseMode(name: string): void setDefaultParseMode(name: string): void
/** /**
@ -3280,7 +3280,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 MtCuteInvalidPeerTypeError * @throws MtqtInvalidPeerTypeError
*/ */
getCommonChats(userId: InputPeerLike): Promise<Chat[]> getCommonChats(userId: InputPeerLike): Promise<Chat[]>
/** /**

View file

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

View file

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

View file

@ -1,5 +1,5 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { MtCuteTypeAssertionError } from '../../types' import { MtqtTypeAssertionError } from '../../types'
/** /**
* Accept the given TOS * Accept the given TOS
@ -20,7 +20,7 @@ export async function acceptTos(
}) })
if (!res) if (!res)
throw new MtCuteTypeAssertionError( throw new MtqtTypeAssertionError(
'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 '@mtcute/core' import { computeSrpParams } from '@mtqt/core'
import { assertTypeIs } from '../../utils/type-assertion' import { assertTypeIs } from '../../utils/type-assertion'
/** /**

View file

@ -1,4 +1,4 @@
import { MaybeDynamic, MtCuteArgumentError, User } from '../../types' import { MaybeDynamic, MtqtArgumentError, 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 MtCuteArgumentError( throw new MtqtArgumentError(
`${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 MtCuteArgumentError(`${phone} has invalid DC ID (${id})`) throw new MtqtArgumentError(`${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 MtCuteArgumentError(`DC ID is invalid (${dcId})`) throw new MtqtArgumentError(`DC ID is invalid (${dcId})`)
dcId = params.dcId dcId = params.dcId
} }

View file

@ -1,6 +1,6 @@
import { import {
MaybeDynamic, MaybeDynamic,
MtCuteArgumentError, MtqtArgumentError,
SentCode, SentCode,
TermsOfService, TermsOfService,
User, User,
@ -19,7 +19,7 @@ import {
PhoneCodeHashEmptyError, PhoneCodeHashEmptyError,
PhoneCodeInvalidError, PhoneCodeInvalidError,
SessionPasswordNeededError, SessionPasswordNeededError,
} from '@mtcute/tl/errors' } from '@mtqt/tl/errors'
/** /**
* Start the client in an interactive and declarative manner, * Start the client in an interactive and declarative manner,
@ -163,7 +163,7 @@ export async function start(
} }
if (!params.phone && !params.botToken) if (!params.phone && !params.botToken)
throw new MtCuteArgumentError( throw new MtqtArgumentError(
'Neither phone nor bot token were provided' 'Neither phone nor bot token were provided'
) )
@ -172,13 +172,13 @@ export async function start(
phone = normalizePhoneNumber(phone) phone = normalizePhoneNumber(phone)
if (!params.code) if (!params.code)
throw new MtCuteArgumentError('You must pass `code` to use `phone`') throw new MtqtArgumentError('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 MtCuteArgumentError( throw new MtqtArgumentError(
'Either bot token or phone number must be provided' 'Either bot token or phone number must be provided'
) )
@ -217,7 +217,7 @@ export async function start(
e instanceof PhoneCodeInvalidError e instanceof PhoneCodeInvalidError
) { ) {
if (typeof params.code !== 'function') { if (typeof params.code !== 'function') {
throw new MtCuteArgumentError('Provided code was invalid') throw new MtqtArgumentError('Provided code was invalid')
} }
if (params.invalidCodeCallback) { if (params.invalidCodeCallback) {
@ -236,7 +236,7 @@ export async function start(
if (has2fa) { if (has2fa) {
if (!params.password) if (!params.password)
throw new MtCuteArgumentError( throw new MtqtArgumentError(
'2FA is enabled, but `password` was not provided.' '2FA is enabled, but `password` was not provided.'
) )
@ -247,7 +247,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 MtCuteArgumentError( throw new MtqtArgumentError(
'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 '@mtcute/tl' import { tl } from '@mtqt/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 '@mtcute/tl' import { tl } from '@mtqt/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 '@mtcute/tl' import { tl } from '@mtqt/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 '@mtcute/tl' import { tl } from '@mtqt/tl'
import { computeSrpParams } from '@mtcute/core' import { computeSrpParams } from '@mtqt/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,
MtCuteInvalidPeerTypeError, MtqtInvalidPeerTypeError,
GameHighScore, GameHighScore,
} from '../../types' } from '../../types'
import { tl } from '@mtcute/tl' import { tl } from '@mtqt/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 MtCuteInvalidPeerTypeError(userId, 'user') if (!res) throw new MtqtInvalidPeerTypeError(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 MtCuteInvalidPeerTypeError(userId, 'user') if (!res) throw new MtqtInvalidPeerTypeError(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 '@mtcute/tl' import { tl } from '@mtqt/tl'
import { BotCommands } from '../../types' import { BotCommands } from '../../types'
/** /**

View file

@ -1,5 +1,5 @@
import { tl } from '@mtcute/tl' import { tl } from '@mtqt/tl'
import { BotCommands, MtCuteInvalidPeerTypeError } from '../../types' import { BotCommands, MtqtInvalidPeerTypeError } 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 MtCuteInvalidPeerTypeError(scope.user, 'user') throw new MtqtInvalidPeerTypeError(scope.user, 'user')
return { return {
_: 'botCommandScopePeerUser', _: 'botCommandScopePeerUser',

View file

@ -1,7 +1,7 @@
import { InputPeerLike, Message, MtCuteInvalidPeerTypeError } from '../../types' import { InputPeerLike, Message, MtqtInvalidPeerTypeError } 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 '@mtcute/tl' import { tl } from '@mtqt/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 MtCuteInvalidPeerTypeError(userId, 'user') if (!user) throw new MtqtInvalidPeerTypeError(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 MtCuteInvalidPeerTypeError(userId, 'user') if (!user) throw new MtqtInvalidPeerTypeError(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 '@mtcute/tl' import { tl } from '@mtqt/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, MtCuteInvalidPeerTypeError } from '../../types' import { InputPeerLike, MtqtInvalidPeerTypeError } from '../../types'
import { MaybeArray } from '@mtcute/core' import { MaybeArray } from '@mtqt/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 MtCuteInvalidPeerTypeError(chatId, 'chat or channel') } else throw new MtqtInvalidPeerTypeError(chatId, 'chat or channel')
} }

View file

@ -1,7 +1,7 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { MaybeArray } from '@mtcute/core' import { MaybeArray } from '@mtqt/core'
import { InputPeerLike } from '../../types' import { InputPeerLike } from '../../types'
import { tl } from '@mtcute/tl' import { tl } from '@mtqt/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,
MtCuteInvalidPeerTypeError, MtqtInvalidPeerTypeError,
MtCuteTypeAssertionError, MtqtTypeAssertionError,
} 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 MtCuteInvalidPeerTypeError(userId, 'user') if (!normUser) throw new MtqtInvalidPeerTypeError(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 MtCuteInvalidPeerTypeError(chatId, 'chat or channel') } else throw new MtqtInvalidPeerTypeError(chatId, 'chat or channel')
try { try {
return this._findMessageInUpdate(res) return this._findMessageInUpdate(res)
} catch (e) { } catch (e) {
if ( if (
e instanceof MtCuteTypeAssertionError && e instanceof MtqtTypeAssertionError &&
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, MtCuteTypeAssertionError } from '../../types' import { Chat, MtqtTypeAssertionError } 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 '@mtcute/core' import { MaybeArray } from '@mtqt/core'
import { Chat, InputPeerLike, MtCuteTypeAssertionError } from '../../types' import { Chat, InputPeerLike, MtqtTypeAssertionError } from '../../types'
import { normalizeToInputUser } from '../../utils/peer-utils' import { normalizeToInputUser } from '../../utils/peer-utils'
import { tl } from '@mtcute/tl' import { tl } from '@mtqt/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, MtCuteTypeAssertionError } from '../../types' import { Chat, MtqtTypeAssertionError } from '../../types'
import { assertIsUpdatesGroup } from '../../utils/updates-utils' import { assertIsUpdatesGroup } from '../../utils/updates-utils'
/** /**

View file

@ -1,4 +1,4 @@
import { InputPeerLike, MtCuteInvalidPeerTypeError } from '../../types' import { InputPeerLike, MtqtInvalidPeerTypeError } 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 MtCuteInvalidPeerTypeError(chatId, 'channel') if (!peer) throw new MtqtInvalidPeerTypeError(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, MtCuteInvalidPeerTypeError } from '../../types' import { InputPeerLike, MtqtInvalidPeerTypeError } 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 MtCuteInvalidPeerTypeError(chatId, 'chat or channel') } else throw new MtqtInvalidPeerTypeError(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, MtCuteInvalidPeerTypeError } from '../../types' import { InputPeerLike, MtqtInvalidPeerTypeError } 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 MtCuteInvalidPeerTypeError(chatId, 'chat') throw new MtqtInvalidPeerTypeError(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 '@mtcute/tl' import { tl } from '@mtqt/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, MtCuteInvalidPeerTypeError } from '../../types' import { InputPeerLike, MtqtInvalidPeerTypeError } from '../../types'
import { import {
normalizeToInputChannel, normalizeToInputChannel,
normalizeToInputUser, normalizeToInputUser,
} from '../../utils/peer-utils' } from '../../utils/peer-utils'
import { tl } from '@mtcute/tl' import { tl } from '@mtqt/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 MtCuteInvalidPeerTypeError(chatId, 'channel') if (!channel) throw new MtqtInvalidPeerTypeError(chatId, 'channel')
const user = normalizeToInputUser(await this.resolvePeer(userId)) const user = normalizeToInputUser(await this.resolvePeer(userId))
if (!user) throw new MtCuteInvalidPeerTypeError(userId, 'user') if (!user) throw new MtqtInvalidPeerTypeError(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, MtCuteInvalidPeerTypeError } from '../../types' import { InputPeerLike, MtqtInvalidPeerTypeError } from '../../types'
import { tl } from '@mtcute/tl' import { tl } from '@mtqt/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 MtCuteInvalidPeerTypeError(chatId, 'channel') if (!chat) throw new MtqtInvalidPeerTypeError(chatId, 'channel')
const user = normalizeToInputUser(await this.resolvePeer(userId)) const user = normalizeToInputUser(await this.resolvePeer(userId))
if (!user) throw new MtCuteInvalidPeerTypeError(userId, 'user') if (!user) throw new MtqtInvalidPeerTypeError(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,
MtCuteInvalidPeerTypeError, MtqtInvalidPeerTypeError,
ChatEvent, ChatEvent,
} from '../../types' } from '../../types'
import { tl } from '@mtcute/tl' import { tl } from '@mtqt/tl'
import { MaybeArray } from '@mtcute/core' import { MaybeArray } from '@mtqt/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 MtCuteInvalidPeerTypeError(chatId, 'channel') if (!channel) throw new MtqtInvalidPeerTypeError(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, MtCuteInvalidPeerTypeError } from '../../types' import { InputPeerLike, MtqtInvalidPeerTypeError } 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 '@mtcute/tl' import { tl } from '@mtqt/tl'
import { ChatMember } from '../../types' import { ChatMember } from '../../types'
import { UserNotParticipantError } from '@mtcute/tl/errors' import { UserNotParticipantError } from '@mtqt/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 MtCuteInvalidPeerTypeError(userId, 'user') throw new MtqtInvalidPeerTypeError(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 MtCuteInvalidPeerTypeError(chatId, 'chat or channel') } else throw new MtqtInvalidPeerTypeError(chatId, 'chat or channel')
} }

View file

@ -1,7 +1,7 @@
import { import {
ChatMember, ChatMember,
InputPeerLike, InputPeerLike,
MtCuteInvalidPeerTypeError, MtqtInvalidPeerTypeError,
} 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 '@mtcute/tl' import { tl } from '@mtqt/tl'
import { ArrayWithTotal } from '../../types' import { ArrayWithTotal } from '../../types'
/** /**
@ -156,5 +156,5 @@ export async function getChatMembers(
return ret return ret
} }
throw new MtCuteInvalidPeerTypeError(chatId, 'chat or channel') throw new MtqtInvalidPeerTypeError(chatId, 'chat or channel')
} }

View file

@ -1,4 +1,4 @@
import { MtCuteArgumentError, MtCuteNotFoundError } from '../../types' import { MtqtArgumentError, MtqtNotFoundError } 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 MtCuteArgumentError In case invite link has invalid format * @throws MtqtArgumentError In case invite link has invalid format
* @throws MtCuteNotFoundError * @throws MtqtNotFoundError
* 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 MtCuteArgumentError('Invalid invite link') if (!m) throw new MtqtArgumentError('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 MtCuteNotFoundError(`You have already joined this chat!`) throw new MtqtNotFoundError(`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, MtCuteArgumentError } from '../../types' import { Chat, InputPeerLike, MtqtArgumentError } 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 '@mtcute/tl' import { tl } from '@mtqt/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 MtCuteArgumentError * @throws MtqtArgumentError
* 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 MtCuteArgumentError( throw new MtqtArgumentError(
`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, MtCuteArgumentError } from '../../types' import { Chat, InputPeerLike, MtqtArgumentError } 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 '@mtcute/tl' import { tl } from '@mtqt/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 MtCuteArgumentError * @throws MtqtArgumentError
* 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 MtCuteArgumentError( throw new MtqtArgumentError(
`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, MtCuteTypeAssertionError } from '../../types' import { Chat, MtqtTypeAssertionError } from '../../types'
import { assertTypeIs } from '../../utils/type-assertion' import { assertTypeIs } from '../../utils/type-assertion'
import { getMarkedPeerId } from '@mtcute/core' import { getMarkedPeerId } from '@mtqt/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,
MtCuteNotFoundError, MtqtNotFoundError,
MtCuteTypeAssertionError, MtqtTypeAssertionError,
} 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 MtCuteNotFoundError() if (!peer) throw new MtqtNotFoundError()
const res = await this.call({ const res = await this.call({
_: 'channels.joinChannel', _: 'channels.joinChannel',

View file

@ -1,4 +1,4 @@
import { InputPeerLike, MtCuteInvalidPeerTypeError } from '../../types' import { InputPeerLike, MtqtInvalidPeerTypeError } 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 MtCuteInvalidPeerTypeError(chatId, 'chat or channel') } else throw new MtqtInvalidPeerTypeError(chatId, 'chat or channel')
} }

View file

@ -1,10 +1,10 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { InputPeerLike, MtCuteInvalidPeerTypeError } from '../../types' import { InputPeerLike, MtqtInvalidPeerTypeError } from '../../types'
import { import {
isInputPeerChannel, isInputPeerChannel,
normalizeToInputChannel, normalizeToInputChannel,
} from '../../utils/peer-utils' } from '../../utils/peer-utils'
import { tl } from '@mtcute/tl' import { tl } from '@mtqt/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 MtCuteInvalidPeerTypeError(chatId, 'channel') throw new MtqtInvalidPeerTypeError(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 '@mtcute/tl' import { tl } from '@mtqt/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, MtCuteTypeAssertionError } from '../../types' import { Chat, InputPeerLike, MtqtTypeAssertionError } from '../../types'
import { tl } from '@mtcute/tl' import { tl } from '@mtqt/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,
MtCuteArgumentError, MtqtArgumentError,
MtCuteInvalidPeerTypeError, MtqtInvalidPeerTypeError,
} from '../../types' } from '../../types'
import { import {
isInputPeerChannel, isInputPeerChannel,
isInputPeerChat, isInputPeerChat,
normalizeToInputChannel, normalizeToInputChannel,
} from '../../utils/peer-utils' } from '../../utils/peer-utils'
import { tl } from '@mtcute/tl' import { tl } from '@mtqt/tl'
import { fileIdToInputPhoto, tdFileId } from '@mtcute/file-id' import { fileIdToInputPhoto, tdFileId } from '@mtqt/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 MtCuteInvalidPeerTypeError(chatId, 'chat or channel') throw new MtqtInvalidPeerTypeError(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 MtCuteArgumentError("Chat photo can't be external") throw new MtqtArgumentError("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 MtCuteArgumentError("Chat photo can't be InputMedia") } else throw new MtqtArgumentError("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, MtCuteInvalidPeerTypeError } from '../../types' import { InputPeerLike, MtqtInvalidPeerTypeError } 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 MtCuteInvalidPeerTypeError(chatId, 'chat or channel') } else throw new MtqtInvalidPeerTypeError(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, MtCuteInvalidPeerTypeError } from '../../types' import { InputPeerLike, MtqtInvalidPeerTypeError } 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 MtCuteInvalidPeerTypeError(chatId, 'channel') if (!chat) throw new MtqtInvalidPeerTypeError(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, MtCuteInvalidPeerTypeError } from '../../types' import { InputPeerLike, MtqtInvalidPeerTypeError } 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 MtCuteInvalidPeerTypeError(chatId, 'channel') if (!chat) throw new MtqtInvalidPeerTypeError(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 '@mtcute/core' import { MaybeArray } from '@mtqt/core'
import { InputPeerLike } from '../../types' import { InputPeerLike } from '../../types'
import { tl } from '@mtcute/tl' import { tl } from '@mtqt/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, MtCuteInvalidPeerTypeError } from '../../types' import { InputPeerLike, MtqtInvalidPeerTypeError } 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 MtCuteInvalidPeerTypeError(chatId, 'chat or channel') } else throw new MtqtInvalidPeerTypeError(chatId, 'chat or channel')
} }

View file

@ -1,12 +1,12 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { import {
InputPeerLike, InputPeerLike,
MtCuteInvalidPeerTypeError, MtqtInvalidPeerTypeError,
MtCuteTypeAssertionError, MtqtTypeAssertionError,
User, User,
} from '../../types' } from '../../types'
import { normalizeToInputUser } from '../../utils/peer-utils' import { normalizeToInputUser } from '../../utils/peer-utils'
import { tl } from '@mtcute/tl' import { tl } from '@mtqt/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 MtCuteInvalidPeerTypeError(userId, 'user') if (!peer) throw new MtqtInvalidPeerTypeError(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 '@mtcute/core' import { MaybeArray } from '@mtqt/core'
import { import {
InputPeerLike, InputPeerLike,
MtCuteInvalidPeerTypeError, MtqtInvalidPeerTypeError,
MtCuteTypeAssertionError, MtqtTypeAssertionError,
User, User,
} from '../../types' } from '../../types'
import { normalizeToInputUser } from '../../utils/peer-utils' import { normalizeToInputUser } from '../../utils/peer-utils'
import { tl } from '@mtcute/tl' import { tl } from '@mtqt/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 MtCuteInvalidPeerTypeError( throw new MtqtInvalidPeerTypeError(
(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 '@mtcute/tl' import { tl } from '@mtqt/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 '@mtcute/tl' import { tl } from '@mtqt/tl'
import { PartialOnly } from '@mtcute/core' import { PartialOnly } from '@mtqt/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 '@mtcute/core' import { getMarkedPeerId } from '@mtqt/core'
// @extension // @extension
interface ConversationsState { interface ConversationsState {

View file

@ -1,6 +1,6 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { tl } from '@mtcute/tl' import { tl } from '@mtqt/tl'
import { PartialExcept } from '@mtcute/core' import { PartialExcept } from '@mtqt/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 '@mtcute/tl' import { tl } from '@mtqt/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 '@mtcute/tl' import { tl } from '@mtqt/tl'
import { MtCuteArgumentError } from '../../types' import { MtqtArgumentError } 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 MtCuteArgumentError(`Could not find a folder ${folder}`) throw new MtqtArgumentError(`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 '@mtcute/tl' import { tl } from '@mtqt/tl'
import { MtCuteArgumentError } from '../../types' import { MtqtArgumentError } 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 MtCuteArgumentError('One of search parameters must be passed') throw new MtqtArgumentError('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,
MtCuteArgumentError, MtqtArgumentError,
MtCuteTypeAssertionError, MtqtTypeAssertionError,
} 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 '@mtcute/tl' import { tl } from '@mtqt/tl'
import { getMarkedPeerId } from '@mtcute/core' import { getMarkedPeerId } from '@mtqt/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 MtCuteArgumentError} is thrown * {@link MtqtArgumentError} 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 MtCuteArgumentError( throw new MtqtArgumentError(
`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 '@mtcute/tl' import { tl } from '@mtqt/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 '@mtcute/core' import { MaybeArray } from '@mtqt/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 '@mtcute/tl' import { tl } from '@mtqt/tl'
import { Dialog, MtCuteTypeAssertionError } from '../../types' import { Dialog, MtqtTypeAssertionError } from '../../types'
import { createUsersChatsIndex } from '../../utils/peer-utils' import { createUsersChatsIndex } from '../../utils/peer-utils'
import { getMarkedPeerId } from '@mtcute/core' import { getMarkedPeerId } from '@mtqt/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 MtCuteTypeAssertionError( throw new MtqtTypeAssertionError(
'messages.getPeerDialogs', 'messages.getPeerDialogs',
'!messages.dialogsNotModified', '!messages.dialogsNotModified',
'messages.dialogsNotModified' 'messages.dialogsNotModified'

View file

@ -1,4 +1,4 @@
import { TelegramConnection } from '@mtcute/core' import { TelegramConnection } from '@mtqt/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 {
MtCuteUnsupportedError, MtqtUnsupportedError,
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 MtCuteUnsupportedError( throw new MtqtUnsupportedError(
'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 '@mtcute/tl' import { tl } from '@mtqt/tl'
import { FileMigrateError, FilerefUpgradeNeededError } from '@mtcute/tl/errors' import { FileMigrateError, FilerefUpgradeNeededError } from '@mtqt/tl/errors'
import { import {
MtCuteArgumentError, MtqtArgumentError,
MtCuteUnsupportedError, MtqtUnsupportedError,
FileDownloadParameters, FileDownloadParameters,
FileLocation, FileLocation,
} from '../../types' } from '../../types'
@ -12,7 +12,7 @@ import {
fileIdToInputFileLocation, fileIdToInputFileLocation,
fileIdToInputWebFileLocation, fileIdToInputWebFileLocation,
parseFileId, parseFileId,
} from '@mtcute/file-id' } from '@mtqt/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 MtCuteArgumentError( throw new MtqtArgumentError(
`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 MtCuteArgumentError( throw new MtqtArgumentError(
`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 MtCuteUnsupportedError('File ref expired!') throw new MtqtUnsupportedError('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 MtCuteUnsupportedError( throw new MtqtUnsupportedError(
'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 '@mtcute/tl' import { tl } from '@mtqt/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, MtCuteArgumentError } from '../../types' import { InputFileLike, isUploadedFile, MtqtArgumentError } from '../../types'
import { tl } from '@mtcute/tl' import { tl } from '@mtqt/tl'
import { tdFileId } from '@mtcute/file-id' import { tdFileId } from '@mtqt/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 MtCuteArgumentError( throw new MtqtArgumentError(
"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 MtCuteArgumentError( throw new MtqtArgumentError(
"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,
MtCuteArgumentError, MtqtArgumentError,
UploadFileLike, UploadFileLike,
} from '../../types' } from '../../types'
import { tl } from '@mtcute/tl' import { tl } from '@mtqt/tl'
import { import {
fileIdToInputDocument, fileIdToInputDocument,
fileIdToInputPhoto, fileIdToInputPhoto,
parseFileId, parseFileId,
tdFileId, tdFileId,
} from '@mtcute/file-id' } from '@mtqt/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 '@mtcute/tl' import { tl } from '@mtqt/tl'
import { MtCuteArgumentError, UploadFileLike, UploadedFile } from '../../types' import { MtqtArgumentError, 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')('mtcute:upload') const debug = require('debug')('mtqt: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 MtCuteArgumentError( throw new MtqtArgumentError(
'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 MtCuteArgumentError('Fetch response contains `null` body') throw new MtqtArgumentError('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 MtCuteArgumentError( throw new MtqtArgumentError(
'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 MtCuteArgumentError(`Invalid part size: ${partSizeKb}KB`) throw new MtqtArgumentError(`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 MtCuteArgumentError( throw new MtqtArgumentError(
`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 MtCuteArgumentError(`Part ${idx} was not a Buffer!`) throw new MtqtArgumentError(`Part ${idx} was not a Buffer!`)
if (part.length > partSize) if (part.length > partSize)
throw new MtCuteArgumentError( throw new MtqtArgumentError(
`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,
MtCuteArgumentError, MtqtArgumentError,
MtCuteTypeAssertionError, MtqtTypeAssertionError,
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 MtCuteArgumentError("This media can't be uploaded") throw new MtqtArgumentError("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 MtCuteTypeAssertionError( throw new MtqtTypeAssertionError(
'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 '@mtcute/tl' import { tl } from '@mtqt/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,
MtCuteInvalidPeerTypeError, MtqtInvalidPeerTypeError,
} from '../../types' } from '../../types'
import { import {
createUsersChatsIndex, createUsersChatsIndex,
normalizeToInputUser, normalizeToInputUser,
} from '../../utils/peer-utils' } from '../../utils/peer-utils'
import { tl } from '@mtcute/tl' import { tl } from '@mtqt/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 MtCuteInvalidPeerTypeError(adminId, 'user') if (!admin) throw new MtqtInvalidPeerTypeError(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,
MtCuteTypeAssertionError, MtqtTypeAssertionError,
} 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 MtCuteTypeAssertionError( throw new MtqtTypeAssertionError(
'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, MtCuteTypeAssertionError, Poll } from '../../types' import { InputPeerLike, MtqtTypeAssertionError, 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 MtCuteTypeAssertionError( throw new MtqtTypeAssertionError(
'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 '@mtcute/core' import { MaybeArray } from '@mtqt/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 '@mtcute/core' import { MaybeArray } from '@mtqt/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 '@mtcute/tl' import { tl } from '@mtqt/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 '@mtcute/tl' import { tl } from '@mtqt/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 '@mtcute/tl' import { tl } from '@mtqt/tl'
import { Message, MtCuteTypeAssertionError } from '../../types' import { Message, MtqtTypeAssertionError } 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 MtCuteTypeAssertionError( throw new MtqtTypeAssertionError(
'_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,
MtCuteArgumentError, MtqtArgumentError,
MtCuteTypeAssertionError, MtqtTypeAssertionError,
} from '../../types' } from '../../types'
import { MaybeArray } from '@mtcute/core' import { MaybeArray } from '@mtqt/core'
import { tl } from '@mtcute/tl' import { tl } from '@mtqt/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 MtCuteArgumentError( throw new MtqtArgumentError(
'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 MtCuteArgumentError( throw new MtqtArgumentError(
'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 '@mtcute/tl' import { tl } from '@mtqt/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, MtCuteTypeAssertionError } from '../../types' import { InputPeerLike, Message, MtqtTypeAssertionError } 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 MtCuteTypeAssertionError( throw new MtqtTypeAssertionError(
'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, MtCuteArgumentError, Message } from '../../types' import { InputPeerLike, MtqtArgumentError, 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 MtCuteArgumentError('This message is not grouped') if (!groupedId) throw new MtqtArgumentError('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 '@mtcute/core' import { MaybeArray } from '@mtqt/core'
import { import {
createUsersChatsIndex, createUsersChatsIndex,
} from '../../utils/peer-utils' } from '../../utils/peer-utils'
import { tl } from '@mtcute/tl' import { tl } from '@mtqt/tl'
import { Message, MtCuteTypeAssertionError } from '../../types' import { Message, MtqtTypeAssertionError } 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 MtCuteTypeAssertionError( throw new MtqtTypeAssertionError(
'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 '@mtcute/core' import { MaybeArray } from '@mtqt/core'
import { import {
createUsersChatsIndex, createUsersChatsIndex,
isInputPeerChannel, isInputPeerChannel,
normalizeToInputChannel, normalizeToInputChannel,
} from '../../utils/peer-utils' } from '../../utils/peer-utils'
import { tl } from '@mtcute/tl' import { tl } from '@mtqt/tl'
import { Message, InputPeerLike, MtCuteTypeAssertionError } from '../../types' import { Message, InputPeerLike, MtqtTypeAssertionError } 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 MtCuteTypeAssertionError( throw new MtqtTypeAssertionError(
'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 '@mtcute/core' import { MaybeArray } from '@mtqt/core'
import { import {
createUsersChatsIndex, createUsersChatsIndex,
isInputPeerChannel, isInputPeerChannel,
normalizeToInputChannel, normalizeToInputChannel,
} from '../../utils/peer-utils' } from '../../utils/peer-utils'
import { tl } from '@mtcute/tl' import { tl } from '@mtqt/tl'
import { Message, InputPeerLike, MtCuteTypeAssertionError } from '../../types' import { Message, InputPeerLike, MtqtTypeAssertionError } 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 MtCuteTypeAssertionError( throw new MtqtTypeAssertionError(
'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 '@mtcute/tl' import { tl } from '@mtqt/tl'
import { TelegramConnection } from '@mtcute/core' import { TelegramConnection } from '@mtqt/core'
import { parseInlineMessageId } from '../../utils/inline-utils' import { parseInlineMessageId } from '../../utils/inline-utils'
// @extension // @extension

View file

@ -1,7 +1,7 @@
import { tl } from '@mtcute/tl' import { tl } from '@mtqt/tl'
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { normalizeToInputUser } from '../../utils/peer-utils' import { normalizeToInputUser } from '../../utils/peer-utils'
import { FormattedString, MtCuteError } from '../../types' import { FormattedString, MtqtError } 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 MtCuteError(`Parse mode ${mode} is not registered.`) throw new MtqtError(`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, MtCuteTypeAssertionError } from '../../types' import { Message, MtqtTypeAssertionError } from '../../types'
import { tl } from '@mtcute/tl' import { tl } from '@mtqt/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 MtCuteTypeAssertionError( throw new MtqtTypeAssertionError(
'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, MtCuteTypeAssertionError } from '../../types' import { InputPeerLike, Message, MtqtTypeAssertionError } from '../../types'
import { tl } from '@mtcute/tl' import { tl } from '@mtqt/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 MtCuteTypeAssertionError( throw new MtqtTypeAssertionError(
'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 '@mtcute/tl' import { tl } from '@mtqt/tl'
import { MessageNotFoundError } from '@mtcute/tl/errors' import { MessageNotFoundError } from '@mtqt/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, MtCuteArgumentError, Message, MtqtArgumentError,
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 '@mtcute/tl' import { tl } from '@mtqt/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 '@mtcute/tl/errors' import { MessageNotFoundError } from '@mtqt/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 MtCuteArgumentError( throw new MtqtArgumentError(
'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, MtCuteArgumentError, Message, MtqtArgumentError,
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 '@mtcute/tl' import { tl } from '@mtqt/tl'
import { MessageNotFoundError } from '@mtcute/tl/errors' import { MessageNotFoundError } from '@mtqt/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 MtCuteArgumentError( throw new MtqtArgumentError(
'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 '@mtcute/core' import { MaybeArray } from '@mtqt/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 '@mtcute/tl' import { tl } from '@mtqt/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,
MtCuteTypeAssertionError, MtqtTypeAssertionError,
ChatsIndex, ChatsIndex,
MtCuteArgumentError, FormattedString, MtqtArgumentError, FormattedString,
} from '../../types' } from '../../types'
import { getMarkedPeerId, MessageNotFoundError } from '@mtcute/core' import { getMarkedPeerId, MessageNotFoundError } from '@mtqt/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 MtCuteArgumentError( throw new MtqtArgumentError(
'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 MtCuteTypeAssertionError( throw new MtqtTypeAssertionError(
'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 MtCuteTypeAssertionError( throw new MtqtTypeAssertionError(
'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 '@mtcute/tl' import { tl } from '@mtqt/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,
MtCuteArgumentError, MtqtArgumentError,
MtCuteTypeAssertionError, MtqtTypeAssertionError,
Poll, Poll,
} from '../../types' } from '../../types'
import { MaybeArray, MessageNotFoundError } from '@mtcute/core' import { MaybeArray, MessageNotFoundError } from '@mtqt/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 MtCuteArgumentError( throw new MtqtArgumentError(
'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 MtCuteTypeAssertionError( throw new MtqtTypeAssertionError(
'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 '@mtcute/tl' import { tl } from '@mtqt/tl'
import { TakeoutSession } from '../../types' import { TakeoutSession } from '../../types'
/** /**

View file

@ -1,5 +1,5 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { MtCuteError, IMessageEntityParser } from '../../types' import { MtqtError, 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 { MtCuteError, 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 MtCuteError When the parse mode with a given name is already registered. * @throws MtqtError 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 MtCuteError( throw new MtqtError(
`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 MtCuteError When the provided parse mode is not registered * @throws MtqtError When the provided parse mode is not registered
* @throws MtCuteError When `name` is omitted and there is no default parse mode * @throws MtqtError 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 MtCuteError('There is no default parse mode') throw new MtqtError('There is no default parse mode')
name = this._defaultParseMode name = this._defaultParseMode
} }
if (!(name in this._parseModes)) { if (!(name in this._parseModes)) {
throw new MtCuteError(`Parse mode ${name} is not registered.`) throw new MtqtError(`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 MtCuteError When given parse mode is not registered. * @throws MtqtError 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 MtCuteError(`Parse mode ${name} is not registered.`) throw new MtqtError(`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