diff --git a/README.md b/README.md index 91c08d5d..97eb28a5 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -# mtqt +# MTCute ![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat) Work-in-progress library for MTProto in TypeScript. -[🎯 Roadmap (notion.so)](https://teidesu.notion.site/mtqt-development-cfccff4fddad4b218f3bea27f784b8b5) +[🎯 Roadmap (notion.so)](https://teidesu.notion.site/MTCute-development-cfccff4fddad4b218f3bea27f784b8b5) | [📦 TL Reference](https://mt.tei.su/tl) > ⚠️ **Warning**: While this library is WIP, storage @@ -30,8 +30,8 @@ What is not done yet: ## Setting up for development: ```bash -git clone https://github.com/mtqt-dev/mtqt -cd mtqt +git clone https://github.com/mtcute/mtcute +cd mtcute yarn install npx lerna link diff --git a/package.json b/package.json index 4e724e56..2285df9c 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "mtqt", + "name": "mtcute", "private": true, "version": "1.0.0", "description": "Type-safe library for MTProto (Telegram API) for browser and NodeJS", diff --git a/packages/client/package.json b/packages/client/package.json index de5ad49a..e6748038 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,8 +1,8 @@ { - "name": "@mtqt/client", + "name": "@mtcute/client", "private": true, "version": "1.0.0", - "description": "High-level API over @mtqt/core", + "description": "High-level API over @mtcute/core", "author": "Alisa Sireneva ", "license": "LGPL-3.0", "main": "src/index.ts", @@ -13,9 +13,9 @@ }, "dependencies": { "@types/node": "^15.12.1", - "@mtqt/tl": "~1.131.0", - "@mtqt/core": "^1.0.0", - "@mtqt/file-id": "^1.0.0", + "@mtcute/tl": "~1.131.0", + "@mtcute/core": "^1.0.0", + "@mtcute/file-id": "^1.0.0", "eager-async-pool": "^1.0.0", "file-type": "^16.2.0", "big-integer": "1.6.48", diff --git a/packages/client/scripts/generate-client.js b/packages/client/scripts/generate-client.js index e54512be..da42643e 100644 --- a/packages/client/scripts/generate-client.js +++ b/packages/client/scripts/generate-client.js @@ -281,8 +281,8 @@ async function main() { output.write( '/* THIS FILE WAS AUTO-GENERATED */\n' + - "import { BaseTelegramClient } from '@mtqt/core'\n" + - "import { tl } from '@mtqt/tl'" + "import { BaseTelegramClient } from '@mtcute/core'\n" + + "import { tl } from '@mtcute/tl'" ) Object.entries(state.imports).forEach(([module, items]) => { items = [...items] diff --git a/packages/client/src/client.ts b/packages/client/src/client.ts index 6f978547..b58724f5 100644 --- a/packages/client/src/client.ts +++ b/packages/client/src/client.ts @@ -1,6 +1,6 @@ /* THIS FILE WAS AUTO-GENERATED */ -import { BaseTelegramClient } from '@mtqt/core' -import { tl } from '@mtqt/tl' +import { BaseTelegramClient } from '@mtcute/core' +import { tl } from '@mtcute/tl' import { acceptTos } from './methods/auth/accept-tos' import { checkPassword } from './methods/auth/check-password' import { getPasswordHint } from './methods/auth/get-password-hint' @@ -226,8 +226,8 @@ import { MaybeArray, MaybeAsync, TelegramConnection, -} from '@mtqt/core' -import { tdFileId } from '@mtqt/file-id' +} from '@mtcute/core' +import { tdFileId } from '@mtcute/file-id' export interface TelegramClient extends BaseTelegramClient { /** @@ -1209,8 +1209,8 @@ export interface TelegramClient extends BaseTelegramClient { * Get preview information about a private chat. * * @param inviteLink Invite link - * @throws MtqtArgumentError In case invite link has invalid format - * @throws MtqtNotFoundError + * @throws MtArgumentError In case invite link has invalid format + * @throws MtNotFoundError * In case you are trying to get info about private chat that you have already joined. * Use {@link getChat} or {@link getFullChat} instead. */ @@ -1219,7 +1219,7 @@ export interface TelegramClient extends BaseTelegramClient { * Get basic information about a chat. * * @param chatId ID of the chat, its username or invite link - * @throws MtqtArgumentError + * @throws MtArgumentError * In case you are trying to get info about private chat that you haven't joined. * Use {@link getChatPreview} instead. */ @@ -1228,7 +1228,7 @@ export interface TelegramClient extends BaseTelegramClient { * Get full information about a chat. * * @param chatId ID of the chat, its username or invite link - * @throws MtqtArgumentError + * @throws MtArgumentError * In case you are trying to get info about private chat that you haven't joined. * Use {@link getChatPreview} instead. */ @@ -1636,7 +1636,7 @@ export interface TelegramClient extends BaseTelegramClient { * use {@link Dialog.filterFolder} instead. * * When a folder with given ID or title is not found, - * {@link MtqtArgumentError} is thrown + * {@link MtArgumentError} is thrown * * By default fetches from "All" folder */ @@ -3016,7 +3016,7 @@ export interface TelegramClient extends BaseTelegramClient { * mode is also set as default. * * @param parseMode Parse mode to register - * @throws MtqtError When the parse mode with a given name is already registered. + * @throws MtClientError When the parse mode with a given name is already registered. */ registerParseMode(parseMode: IMessageEntityParser): void /** @@ -3032,15 +3032,15 @@ export interface TelegramClient extends BaseTelegramClient { * Get a {@link IMessageEntityParser} registered under a given name (or a default one). * * @param name Name of the parse mode which parser to get. - * @throws MtqtError When the provided parse mode is not registered - * @throws MtqtError When `name` is omitted and there is no default parse mode + * @throws MtClientError When the provided parse mode is not registered + * @throws MtClientError When `name` is omitted and there is no default parse mode */ getParseMode(name?: string | null): IMessageEntityParser /** * Set a given parse mode as a default one. * * @param name Name of the parse mode - * @throws MtqtError When given parse mode is not registered. + * @throws MtClientError When given parse mode is not registered. */ setDefaultParseMode(name: string): void /** @@ -3291,7 +3291,7 @@ export interface TelegramClient extends BaseTelegramClient { * Get a list of common chats you have with a given user * * @param userId User's ID, username or phone number - * @throws MtqtInvalidPeerTypeError + * @throws MtInvalidPeerTypeError */ getCommonChats(userId: InputPeerLike): Promise /** diff --git a/packages/client/src/index.ts b/packages/client/src/index.ts index ba47c7e8..6d193bd4 100644 --- a/packages/client/src/index.ts +++ b/packages/client/src/index.ts @@ -4,8 +4,8 @@ export { LocalstorageStorage, tl, defaultDcs -} from '@mtqt/core' -export * from '@mtqt/tl/errors' +} from '@mtcute/core' +export * from '@mtcute/tl/errors' export * from './types' export * from './client' diff --git a/packages/client/src/methods/_imports.ts b/packages/client/src/methods/_imports.ts index 635818e9..65e303ed 100644 --- a/packages/client/src/methods/_imports.ts +++ b/packages/client/src/methods/_imports.ts @@ -62,7 +62,7 @@ import { MaybeAsync, TelegramConnection, AsyncLock, -} from '@mtqt/core' +} from '@mtcute/core' // @copy -import { tdFileId } from '@mtqt/file-id' +import { tdFileId } from '@mtcute/file-id' diff --git a/packages/client/src/methods/auth/accept-tos.ts b/packages/client/src/methods/auth/accept-tos.ts index 777f43df..4b0dfe8c 100644 --- a/packages/client/src/methods/auth/accept-tos.ts +++ b/packages/client/src/methods/auth/accept-tos.ts @@ -1,5 +1,5 @@ import { TelegramClient } from '../../client' -import { MtqtTypeAssertionError } from '../../types' +import { MtTypeAssertionError } from '../../types' /** * Accept the given TOS @@ -20,7 +20,7 @@ export async function acceptTos( }) if (!res) - throw new MtqtTypeAssertionError( + throw new MtTypeAssertionError( 'help.acceptTermsOfService', 'true', 'false' diff --git a/packages/client/src/methods/auth/check-password.ts b/packages/client/src/methods/auth/check-password.ts index 7710d862..e0f4b7b9 100644 --- a/packages/client/src/methods/auth/check-password.ts +++ b/packages/client/src/methods/auth/check-password.ts @@ -1,6 +1,6 @@ import { TelegramClient } from '../../client' import { User } from '../../types' -import { computeSrpParams } from '@mtqt/core' +import { computeSrpParams } from '@mtcute/core' import { assertTypeIs } from '../../utils/type-assertion' /** diff --git a/packages/client/src/methods/auth/start-test.ts b/packages/client/src/methods/auth/start-test.ts index 772e07a9..4c7d148b 100644 --- a/packages/client/src/methods/auth/start-test.ts +++ b/packages/client/src/methods/auth/start-test.ts @@ -1,4 +1,4 @@ -import { MaybeDynamic, MtqtArgumentError, User } from '../../types' +import { MaybeDynamic, MtArgumentError, User } from '../../types' import { TelegramClient } from '../../client' /** @@ -68,17 +68,17 @@ export async function startTest( let phone = params.phone if (phone) { if (!phone.match(/^99966\d{5}/)) - throw new MtqtArgumentError( + throw new MtArgumentError( `${phone} is an invalid test phone number` ) const id = parseInt(phone[5]) if (!availableDcs.find((dc) => dc.id === id)) - throw new MtqtArgumentError(`${phone} has invalid DC ID (${id})`) + throw new MtArgumentError(`${phone} has invalid DC ID (${id})`) } else { let dcId = this._primaryDc.id if (params.dcId) { if (!availableDcs.find((dc) => dc.id === params!.dcId)) - throw new MtqtArgumentError(`DC ID is invalid (${dcId})`) + throw new MtArgumentError(`DC ID is invalid (${dcId})`) dcId = params.dcId } diff --git a/packages/client/src/methods/auth/start.ts b/packages/client/src/methods/auth/start.ts index 75f19242..cdbd2cae 100644 --- a/packages/client/src/methods/auth/start.ts +++ b/packages/client/src/methods/auth/start.ts @@ -1,6 +1,6 @@ import { MaybeDynamic, - MtqtArgumentError, + MtArgumentError, SentCode, TermsOfService, User, @@ -19,7 +19,7 @@ import { PhoneCodeHashEmptyError, PhoneCodeInvalidError, SessionPasswordNeededError, -} from '@mtqt/tl/errors' +} from '@mtcute/tl/errors' /** * Start the client in an interactive and declarative manner, @@ -165,7 +165,7 @@ export async function start( } if (!params.phone && !params.botToken) - throw new MtqtArgumentError( + throw new MtArgumentError( 'Neither phone nor bot token were provided' ) @@ -174,13 +174,13 @@ export async function start( phone = normalizePhoneNumber(phone) if (!params.code) - throw new MtqtArgumentError('You must pass `code` to use `phone`') + throw new MtArgumentError('You must pass `code` to use `phone`') } else { const botToken = params.botToken ? await resolveMaybeDynamic(params.botToken) : null if (!botToken) - throw new MtqtArgumentError( + throw new MtArgumentError( 'Either bot token or phone number must be provided' ) @@ -219,7 +219,7 @@ export async function start( e instanceof PhoneCodeInvalidError ) { if (typeof params.code !== 'function') { - throw new MtqtArgumentError('Provided code was invalid') + throw new MtArgumentError('Provided code was invalid') } if (params.invalidCodeCallback) { @@ -238,7 +238,7 @@ export async function start( if (has2fa) { if (!params.password) - throw new MtqtArgumentError( + throw new MtArgumentError( '2FA is enabled, but `password` was not provided.' ) @@ -249,7 +249,7 @@ export async function start( result = await this.checkPassword(password) } catch (e) { if (typeof params.password !== 'function') { - throw new MtqtArgumentError( + throw new MtArgumentError( 'Provided password was invalid' ) } diff --git a/packages/client/src/methods/bots/answer-callback-query.ts b/packages/client/src/methods/bots/answer-callback-query.ts index baa75172..2d760a78 100644 --- a/packages/client/src/methods/bots/answer-callback-query.ts +++ b/packages/client/src/methods/bots/answer-callback-query.ts @@ -1,5 +1,5 @@ import { TelegramClient } from '../../client' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' /** * Send an answer to a callback query. diff --git a/packages/client/src/methods/bots/answer-inline-query.ts b/packages/client/src/methods/bots/answer-inline-query.ts index c73237a1..347a19c7 100644 --- a/packages/client/src/methods/bots/answer-inline-query.ts +++ b/packages/client/src/methods/bots/answer-inline-query.ts @@ -1,5 +1,5 @@ import { TelegramClient } from '../../client' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { BotInline, InputInlineResult } from '../../types' /** diff --git a/packages/client/src/methods/bots/delete-my-commands.ts b/packages/client/src/methods/bots/delete-my-commands.ts index 201bb30e..aaa653a1 100644 --- a/packages/client/src/methods/bots/delete-my-commands.ts +++ b/packages/client/src/methods/bots/delete-my-commands.ts @@ -1,5 +1,5 @@ import { TelegramClient } from '../../client' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { BotCommands } from '../../types' /** diff --git a/packages/client/src/methods/bots/get-callback-answer.ts b/packages/client/src/methods/bots/get-callback-answer.ts index d489e5e5..cc01c433 100644 --- a/packages/client/src/methods/bots/get-callback-answer.ts +++ b/packages/client/src/methods/bots/get-callback-answer.ts @@ -1,7 +1,7 @@ import { TelegramClient } from '../../client' import { InputPeerLike } from '../../types' -import { tl } from '@mtqt/tl' -import { computeSrpParams } from '@mtqt/core' +import { tl } from '@mtcute/tl' +import { computeSrpParams } from '@mtcute/core' /** * Request a callback answer from a bot, diff --git a/packages/client/src/methods/bots/get-game-high-scores.ts b/packages/client/src/methods/bots/get-game-high-scores.ts index e0939c84..f39b2b9b 100644 --- a/packages/client/src/methods/bots/get-game-high-scores.ts +++ b/packages/client/src/methods/bots/get-game-high-scores.ts @@ -1,10 +1,10 @@ import { TelegramClient } from '../../client' import { InputPeerLike, - MtqtInvalidPeerTypeError, + MtInvalidPeerTypeError, GameHighScore, } from '../../types' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { createUsersChatsIndex, normalizeToInputUser, @@ -29,7 +29,7 @@ export async function getGameHighScores( let user: tl.TypeInputUser if (userId) { const res = normalizeToInputUser(await this.resolvePeer(userId)) - if (!res) throw new MtqtInvalidPeerTypeError(userId, 'user') + if (!res) throw new MtInvalidPeerTypeError(userId, 'user') user = res } else { @@ -65,7 +65,7 @@ export async function getInlineGameHighScores( let user: tl.TypeInputUser if (userId) { const res = normalizeToInputUser(await this.resolvePeer(userId)) - if (!res) throw new MtqtInvalidPeerTypeError(userId, 'user') + if (!res) throw new MtInvalidPeerTypeError(userId, 'user') user = res } else { diff --git a/packages/client/src/methods/bots/get-my-commands.ts b/packages/client/src/methods/bots/get-my-commands.ts index 0aa46f4d..f4cf5c4b 100644 --- a/packages/client/src/methods/bots/get-my-commands.ts +++ b/packages/client/src/methods/bots/get-my-commands.ts @@ -1,5 +1,5 @@ import { TelegramClient } from '../../client' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { BotCommands } from '../../types' /** diff --git a/packages/client/src/methods/bots/normalize-command-scope.ts b/packages/client/src/methods/bots/normalize-command-scope.ts index 128de385..95e96c75 100644 --- a/packages/client/src/methods/bots/normalize-command-scope.ts +++ b/packages/client/src/methods/bots/normalize-command-scope.ts @@ -1,5 +1,5 @@ -import { tl } from '@mtqt/tl' -import { BotCommands, MtqtInvalidPeerTypeError } from '../../types' +import { tl } from '@mtcute/tl' +import { BotCommands, MtInvalidPeerTypeError } from '../../types' import { TelegramClient } from '../../client' import { normalizeToInputUser } from '../../utils/peer-utils' @@ -25,7 +25,7 @@ export async function _normalizeCommandScope( const user = normalizeToInputUser(await this.resolvePeer(scope.user)) if (!user) - throw new MtqtInvalidPeerTypeError(scope.user, 'user') + throw new MtInvalidPeerTypeError(scope.user, 'user') return { _: 'botCommandScopePeerUser', diff --git a/packages/client/src/methods/bots/set-game-score.ts b/packages/client/src/methods/bots/set-game-score.ts index 094115e1..0b17148e 100644 --- a/packages/client/src/methods/bots/set-game-score.ts +++ b/packages/client/src/methods/bots/set-game-score.ts @@ -1,7 +1,7 @@ -import { InputPeerLike, Message, MtqtInvalidPeerTypeError } from '../../types' +import { InputPeerLike, Message, MtInvalidPeerTypeError } from '../../types' import { TelegramClient } from '../../client' import { normalizeToInputUser } from '../../utils/peer-utils' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' /** * Set a score of a user in a game @@ -38,7 +38,7 @@ export async function setGameScore( const chat = await this.resolvePeer(chatId) const user = normalizeToInputUser(await this.resolvePeer(userId)) - if (!user) throw new MtqtInvalidPeerTypeError(userId, 'user') + if (!user) throw new MtInvalidPeerTypeError(userId, 'user') const res = await this.call({ _: 'messages.setGameScore', @@ -85,7 +85,7 @@ export async function setInlineGameScore( if (!params) params = {} const user = normalizeToInputUser(await this.resolvePeer(userId)) - if (!user) throw new MtqtInvalidPeerTypeError(userId, 'user') + if (!user) throw new MtInvalidPeerTypeError(userId, 'user') const [id, connection] = await this._normalizeInline(messageId) diff --git a/packages/client/src/methods/bots/set-my-commands.ts b/packages/client/src/methods/bots/set-my-commands.ts index 56a31403..a13298e2 100644 --- a/packages/client/src/methods/bots/set-my-commands.ts +++ b/packages/client/src/methods/bots/set-my-commands.ts @@ -1,5 +1,5 @@ import { TelegramClient } from '../../client' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { BotCommands } from '../../types' /** diff --git a/packages/client/src/methods/chats/add-chat-members.ts b/packages/client/src/methods/chats/add-chat-members.ts index 9d97b4be..2ed9caf6 100644 --- a/packages/client/src/methods/chats/add-chat-members.ts +++ b/packages/client/src/methods/chats/add-chat-members.ts @@ -1,6 +1,6 @@ import { TelegramClient } from '../../client' -import { InputPeerLike, MtqtInvalidPeerTypeError } from '../../types' -import { MaybeArray } from '@mtqt/core' +import { InputPeerLike, MtInvalidPeerTypeError } from '../../types' +import { MaybeArray } from '@mtcute/core' import { isInputPeerChannel, isInputPeerChat, @@ -52,5 +52,5 @@ export async function addChatMembers( fwdLimit: forwardCount, }) this._handleUpdate(updates) - } else throw new MtqtInvalidPeerTypeError(chatId, 'chat or channel') + } else throw new MtInvalidPeerTypeError(chatId, 'chat or channel') } diff --git a/packages/client/src/methods/chats/archive-chats.ts b/packages/client/src/methods/chats/archive-chats.ts index 85c51657..b6746fb3 100644 --- a/packages/client/src/methods/chats/archive-chats.ts +++ b/packages/client/src/methods/chats/archive-chats.ts @@ -1,7 +1,7 @@ import { TelegramClient } from '../../client' -import { MaybeArray } from '@mtqt/core' +import { MaybeArray } from '@mtcute/core' import { InputPeerLike } from '../../types' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' /** * Archive one or more chats diff --git a/packages/client/src/methods/chats/ban-chat-member.ts b/packages/client/src/methods/chats/ban-chat-member.ts index efe01d61..c702fda5 100644 --- a/packages/client/src/methods/chats/ban-chat-member.ts +++ b/packages/client/src/methods/chats/ban-chat-member.ts @@ -2,8 +2,8 @@ import { TelegramClient } from '../../client' import { InputPeerLike, Message, - MtqtInvalidPeerTypeError, - MtqtTypeAssertionError, + MtInvalidPeerTypeError, + MtTypeAssertionError, } from '../../types' import { isInputPeerChannel, @@ -45,20 +45,20 @@ export async function banChatMember( }) } else if (isInputPeerChat(chat)) { const normUser = normalizeToInputUser(user) - if (!normUser) throw new MtqtInvalidPeerTypeError(userId, 'user') + if (!normUser) throw new MtInvalidPeerTypeError(userId, 'user') res = await this.call({ _: 'messages.deleteChatUser', chatId: chat.chatId, userId: normUser, }) - } else throw new MtqtInvalidPeerTypeError(chatId, 'chat or channel') + } else throw new MtInvalidPeerTypeError(chatId, 'chat or channel') try { return this._findMessageInUpdate(res) } catch (e) { if ( - e instanceof MtqtTypeAssertionError && + e instanceof MtTypeAssertionError && e.context === '_findInUpdate (@ .updates[*])' ) { // no service message diff --git a/packages/client/src/methods/chats/create-channel.ts b/packages/client/src/methods/chats/create-channel.ts index 8200b44b..ce30c6ae 100644 --- a/packages/client/src/methods/chats/create-channel.ts +++ b/packages/client/src/methods/chats/create-channel.ts @@ -1,5 +1,5 @@ import { TelegramClient } from '../../client' -import { Chat, MtqtTypeAssertionError } from '../../types' +import { Chat, MtTypeAssertionError } from '../../types' import { assertIsUpdatesGroup } from '../../utils/updates-utils' /** diff --git a/packages/client/src/methods/chats/create-group.ts b/packages/client/src/methods/chats/create-group.ts index bed89fac..394ba633 100644 --- a/packages/client/src/methods/chats/create-group.ts +++ b/packages/client/src/methods/chats/create-group.ts @@ -1,8 +1,8 @@ import { TelegramClient } from '../../client' -import { MaybeArray } from '@mtqt/core' -import { Chat, InputPeerLike, MtqtTypeAssertionError } from '../../types' +import { MaybeArray } from '@mtcute/core' +import { Chat, InputPeerLike, MtTypeAssertionError } from '../../types' import { normalizeToInputUser } from '../../utils/peer-utils' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { assertIsUpdatesGroup } from '../../utils/updates-utils' /** diff --git a/packages/client/src/methods/chats/create-supergroup.ts b/packages/client/src/methods/chats/create-supergroup.ts index 48ed9622..09b33dee 100644 --- a/packages/client/src/methods/chats/create-supergroup.ts +++ b/packages/client/src/methods/chats/create-supergroup.ts @@ -1,5 +1,5 @@ import { TelegramClient } from '../../client' -import { Chat, MtqtTypeAssertionError } from '../../types' +import { Chat, MtTypeAssertionError } from '../../types' import { assertIsUpdatesGroup } from '../../utils/updates-utils' /** diff --git a/packages/client/src/methods/chats/delete-channel.ts b/packages/client/src/methods/chats/delete-channel.ts index d4d4a060..55453912 100644 --- a/packages/client/src/methods/chats/delete-channel.ts +++ b/packages/client/src/methods/chats/delete-channel.ts @@ -1,4 +1,4 @@ -import { InputPeerLike, MtqtInvalidPeerTypeError } from '../../types' +import { InputPeerLike, MtInvalidPeerTypeError } from '../../types' import { TelegramClient } from '../../client' import { normalizeToInputChannel } from '../../utils/peer-utils' @@ -14,7 +14,7 @@ export async function deleteChannel( chatId: InputPeerLike ): Promise { const peer = normalizeToInputChannel(await this.resolvePeer(chatId)) - if (!peer) throw new MtqtInvalidPeerTypeError(chatId, 'channel') + if (!peer) throw new MtInvalidPeerTypeError(chatId, 'channel') const res = await this.call({ _: 'channels.deleteChannel', diff --git a/packages/client/src/methods/chats/delete-chat-photo.ts b/packages/client/src/methods/chats/delete-chat-photo.ts index 9e484d11..b7e3a491 100644 --- a/packages/client/src/methods/chats/delete-chat-photo.ts +++ b/packages/client/src/methods/chats/delete-chat-photo.ts @@ -1,5 +1,5 @@ import { TelegramClient } from '../../client' -import { InputPeerLike, MtqtInvalidPeerTypeError } from '../../types' +import { InputPeerLike, MtInvalidPeerTypeError } from '../../types' import { isInputPeerChannel, isInputPeerChat, @@ -33,7 +33,7 @@ export async function deleteChatPhoto( channel: normalizeToInputChannel(chat), photo: { _: 'inputChatPhotoEmpty' }, }) - } else throw new MtqtInvalidPeerTypeError(chatId, 'chat or channel') + } else throw new MtInvalidPeerTypeError(chatId, 'chat or channel') this._handleUpdate(res) } diff --git a/packages/client/src/methods/chats/delete-group.ts b/packages/client/src/methods/chats/delete-group.ts index 325c75a3..827954e6 100644 --- a/packages/client/src/methods/chats/delete-group.ts +++ b/packages/client/src/methods/chats/delete-group.ts @@ -1,5 +1,5 @@ import { TelegramClient } from '../../client' -import { InputPeerLike, MtqtInvalidPeerTypeError } from '../../types' +import { InputPeerLike, MtInvalidPeerTypeError } from '../../types' import { isInputPeerChat } from '../../utils/peer-utils' /** @@ -14,7 +14,7 @@ export async function deleteGroup( ): Promise { const chat = await this.resolvePeer(chatId) if (!isInputPeerChat(chat)) - throw new MtqtInvalidPeerTypeError(chatId, 'chat') + throw new MtInvalidPeerTypeError(chatId, 'chat') const res = await this.call({ _: 'messages.deleteChatUser', diff --git a/packages/client/src/methods/chats/delete-history.ts b/packages/client/src/methods/chats/delete-history.ts index 80963944..5769f3f5 100644 --- a/packages/client/src/methods/chats/delete-history.ts +++ b/packages/client/src/methods/chats/delete-history.ts @@ -2,7 +2,7 @@ import { TelegramClient } from '../../client' import { InputPeerLike } from '../../types' import { normalizeToInputChannel } from '../../utils/peer-utils' import { createDummyUpdate } from '../../utils/updates-utils' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' /** * Delete communication history (for private chats diff --git a/packages/client/src/methods/chats/delete-user-history.ts b/packages/client/src/methods/chats/delete-user-history.ts index 3c8eda6e..ddb796d4 100644 --- a/packages/client/src/methods/chats/delete-user-history.ts +++ b/packages/client/src/methods/chats/delete-user-history.ts @@ -1,10 +1,10 @@ import { TelegramClient } from '../../client' -import { InputPeerLike, MtqtInvalidPeerTypeError } from '../../types' +import { InputPeerLike, MtInvalidPeerTypeError } from '../../types' import { normalizeToInputChannel, normalizeToInputUser, } from '../../utils/peer-utils' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { createDummyUpdate } from '../../utils/updates-utils' /** @@ -20,10 +20,10 @@ export async function deleteUserHistory( userId: InputPeerLike ): Promise { const channel = normalizeToInputChannel(await this.resolvePeer(chatId)) - if (!channel) throw new MtqtInvalidPeerTypeError(chatId, 'channel') + if (!channel) throw new MtInvalidPeerTypeError(chatId, 'channel') const user = normalizeToInputUser(await this.resolvePeer(userId)) - if (!user) throw new MtqtInvalidPeerTypeError(userId, 'user') + if (!user) throw new MtInvalidPeerTypeError(userId, 'user') const res = await this.call({ _: 'channels.deleteUserHistory', diff --git a/packages/client/src/methods/chats/edit-admin-rights.ts b/packages/client/src/methods/chats/edit-admin-rights.ts index 0e29ad19..db4b46d9 100644 --- a/packages/client/src/methods/chats/edit-admin-rights.ts +++ b/packages/client/src/methods/chats/edit-admin-rights.ts @@ -1,6 +1,6 @@ import { TelegramClient } from '../../client' -import { InputPeerLike, MtqtInvalidPeerTypeError } from '../../types' -import { tl } from '@mtqt/tl' +import { InputPeerLike, MtInvalidPeerTypeError } from '../../types' +import { tl } from '@mtcute/tl' import { normalizeToInputChannel, normalizeToInputUser, @@ -23,10 +23,10 @@ export async function editAdminRights( rank = '' ): Promise { const chat = normalizeToInputChannel(await this.resolvePeer(chatId)) - if (!chat) throw new MtqtInvalidPeerTypeError(chatId, 'channel') + if (!chat) throw new MtInvalidPeerTypeError(chatId, 'channel') const user = normalizeToInputUser(await this.resolvePeer(userId)) - if (!user) throw new MtqtInvalidPeerTypeError(userId, 'user') + if (!user) throw new MtInvalidPeerTypeError(userId, 'user') const res = await this.call({ _: 'channels.editAdmin', diff --git a/packages/client/src/methods/chats/get-chat-event-log.ts b/packages/client/src/methods/chats/get-chat-event-log.ts index 83025e37..dff7ea73 100644 --- a/packages/client/src/methods/chats/get-chat-event-log.ts +++ b/packages/client/src/methods/chats/get-chat-event-log.ts @@ -1,11 +1,11 @@ import { TelegramClient } from '../../client' import { InputPeerLike, - MtqtInvalidPeerTypeError, + MtInvalidPeerTypeError, ChatEvent, } from '../../types' -import { tl } from '@mtqt/tl' -import { MaybeArray } from '@mtqt/core' +import { tl } from '@mtcute/tl' +import { MaybeArray } from '@mtcute/core' import bigInt from 'big-integer' import { createUsersChatsIndex, @@ -86,7 +86,7 @@ export async function* getChatEventLog( if (!params) params = {} const channel = normalizeToInputChannel(await this.resolvePeer(chatId)) - if (!channel) throw new MtqtInvalidPeerTypeError(chatId, 'channel') + if (!channel) throw new MtInvalidPeerTypeError(chatId, 'channel') let current = 0 let maxId = params.maxId ?? bigInt.zero diff --git a/packages/client/src/methods/chats/get-chat-member.ts b/packages/client/src/methods/chats/get-chat-member.ts index 0eae9986..8bb82910 100644 --- a/packages/client/src/methods/chats/get-chat-member.ts +++ b/packages/client/src/methods/chats/get-chat-member.ts @@ -1,5 +1,5 @@ import { TelegramClient } from '../../client' -import { InputPeerLike, MtqtInvalidPeerTypeError } from '../../types' +import { InputPeerLike, MtInvalidPeerTypeError } from '../../types' import { createUsersChatsIndex, isInputPeerChannel, @@ -8,9 +8,9 @@ import { normalizeToInputChannel, } from '../../utils/peer-utils' import { assertTypeIs } from '../../utils/type-assertion' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { ChatMember } from '../../types' -import { UserNotParticipantError } from '@mtqt/tl/errors' +import { UserNotParticipantError } from '@mtcute/tl/errors' /** * Get information about a single chat member @@ -30,7 +30,7 @@ export async function getChatMember( if (isInputPeerChat(chat)) { if (!isInputPeerUser(user)) - throw new MtqtInvalidPeerTypeError(userId, 'user') + throw new MtInvalidPeerTypeError(userId, 'user') const res = await this.call({ _: 'messages.getFullChat', @@ -71,5 +71,5 @@ export async function getChatMember( const { users } = createUsersChatsIndex(res) return new ChatMember(this, res.participant, users) - } else throw new MtqtInvalidPeerTypeError(chatId, 'chat or channel') + } else throw new MtInvalidPeerTypeError(chatId, 'chat or channel') } diff --git a/packages/client/src/methods/chats/get-chat-members.ts b/packages/client/src/methods/chats/get-chat-members.ts index 88d1407f..331b4921 100644 --- a/packages/client/src/methods/chats/get-chat-members.ts +++ b/packages/client/src/methods/chats/get-chat-members.ts @@ -1,7 +1,7 @@ import { ChatMember, InputPeerLike, - MtqtInvalidPeerTypeError, + MtInvalidPeerTypeError, } from '../../types' import { TelegramClient } from '../../client' import { @@ -11,7 +11,7 @@ import { normalizeToInputChannel, } from '../../utils/peer-utils' import { assertTypeIs } from '../../utils/type-assertion' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { ArrayWithTotal } from '../../types' /** @@ -156,5 +156,5 @@ export async function getChatMembers( return ret } - throw new MtqtInvalidPeerTypeError(chatId, 'chat or channel') + throw new MtInvalidPeerTypeError(chatId, 'chat or channel') } diff --git a/packages/client/src/methods/chats/get-chat-preview.ts b/packages/client/src/methods/chats/get-chat-preview.ts index 30142101..0b0556a6 100644 --- a/packages/client/src/methods/chats/get-chat-preview.ts +++ b/packages/client/src/methods/chats/get-chat-preview.ts @@ -1,4 +1,4 @@ -import { MtqtArgumentError, MtqtNotFoundError } from '../../types' +import { MtArgumentError, MtNotFoundError } from '../../types' import { TelegramClient } from '../../client' import { INVITE_LINK_REGEX } from '../../utils/peer-utils' import { ChatPreview } from '../../types' @@ -7,8 +7,8 @@ import { ChatPreview } from '../../types' * Get preview information about a private chat. * * @param inviteLink Invite link - * @throws MtqtArgumentError In case invite link has invalid format - * @throws MtqtNotFoundError + * @throws MtArgumentError In case invite link has invalid format + * @throws MtNotFoundError * In case you are trying to get info about private chat that you have already joined. * Use {@link getChat} or {@link getFullChat} instead. * @internal @@ -18,7 +18,7 @@ export async function getChatPreview( inviteLink: string ): Promise { const m = inviteLink.match(INVITE_LINK_REGEX) - if (!m) throw new MtqtArgumentError('Invalid invite link') + if (!m) throw new MtArgumentError('Invalid invite link') const res = await this.call({ _: 'messages.checkChatInvite', @@ -26,7 +26,7 @@ export async function getChatPreview( }) if (res._ !== 'chatInvite') { - throw new MtqtNotFoundError(`You have already joined this chat!`) + throw new MtNotFoundError(`You have already joined this chat!`) } return new ChatPreview(this, res, inviteLink) diff --git a/packages/client/src/methods/chats/get-chat.ts b/packages/client/src/methods/chats/get-chat.ts index 9ca46030..92b6fd0b 100644 --- a/packages/client/src/methods/chats/get-chat.ts +++ b/packages/client/src/methods/chats/get-chat.ts @@ -1,4 +1,4 @@ -import { Chat, InputPeerLike, MtqtArgumentError } from '../../types' +import { Chat, InputPeerLike, MtArgumentError } from '../../types' import { TelegramClient } from '../../client' import { INVITE_LINK_REGEX, @@ -8,13 +8,13 @@ import { normalizeToInputChannel, normalizeToInputUser, } from '../../utils/peer-utils' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' /** * Get basic information about a chat. * * @param chatId ID of the chat, its username or invite link - * @throws MtqtArgumentError + * @throws MtArgumentError * In case you are trying to get info about private chat that you haven't joined. * Use {@link getChatPreview} instead. * @internal @@ -32,7 +32,7 @@ export async function getChat( }) if (res._ === 'chatInvite') { - throw new MtqtArgumentError( + throw new MtArgumentError( `You haven't joined ${JSON.stringify(res.title)}` ) } diff --git a/packages/client/src/methods/chats/get-full-chat.ts b/packages/client/src/methods/chats/get-full-chat.ts index b02c315b..e09979fc 100644 --- a/packages/client/src/methods/chats/get-full-chat.ts +++ b/packages/client/src/methods/chats/get-full-chat.ts @@ -1,4 +1,4 @@ -import { Chat, InputPeerLike, MtqtArgumentError } from '../../types' +import { Chat, InputPeerLike, MtArgumentError } from '../../types' import { TelegramClient } from '../../client' import { INVITE_LINK_REGEX, @@ -8,13 +8,13 @@ import { normalizeToInputChannel, normalizeToInputUser, } from '../../utils/peer-utils' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' /** * Get full information about a chat. * * @param chatId ID of the chat, its username or invite link - * @throws MtqtArgumentError + * @throws MtArgumentError * In case you are trying to get info about private chat that you haven't joined. * Use {@link getChatPreview} instead. * @internal @@ -32,7 +32,7 @@ export async function getFullChat( }) if (res._ === 'chatInvite') { - throw new MtqtArgumentError( + throw new MtArgumentError( `You haven't joined ${JSON.stringify(res.title)}` ) } diff --git a/packages/client/src/methods/chats/get-nearby-chats.ts b/packages/client/src/methods/chats/get-nearby-chats.ts index f2b8638a..de8d5236 100644 --- a/packages/client/src/methods/chats/get-nearby-chats.ts +++ b/packages/client/src/methods/chats/get-nearby-chats.ts @@ -1,7 +1,7 @@ import { TelegramClient } from '../../client' -import { Chat, MtqtTypeAssertionError } from '../../types' +import { Chat, MtTypeAssertionError } from '../../types' import { assertTypeIs } from '../../utils/type-assertion' -import { getMarkedPeerId } from '@mtqt/core' +import { getMarkedPeerId } from '@mtcute/core' import { tl } from 'packages/tl' import { assertIsUpdatesGroup } from '../../utils/updates-utils' diff --git a/packages/client/src/methods/chats/join-chat.ts b/packages/client/src/methods/chats/join-chat.ts index 491395a2..8d8032f6 100644 --- a/packages/client/src/methods/chats/join-chat.ts +++ b/packages/client/src/methods/chats/join-chat.ts @@ -2,8 +2,8 @@ import { TelegramClient } from '../../client' import { Chat, InputPeerLike, - MtqtNotFoundError, - MtqtTypeAssertionError, + MtNotFoundError, + MtTypeAssertionError, } from '../../types' import { INVITE_LINK_REGEX, @@ -39,7 +39,7 @@ export async function joinChat( } const peer = normalizeToInputChannel(await this.resolvePeer(chatId)) - if (!peer) throw new MtqtNotFoundError() + if (!peer) throw new MtNotFoundError() const res = await this.call({ _: 'channels.joinChannel', diff --git a/packages/client/src/methods/chats/leave-chat.ts b/packages/client/src/methods/chats/leave-chat.ts index 884284b9..b36f6819 100644 --- a/packages/client/src/methods/chats/leave-chat.ts +++ b/packages/client/src/methods/chats/leave-chat.ts @@ -1,4 +1,4 @@ -import { InputPeerLike, MtqtInvalidPeerTypeError } from '../../types' +import { InputPeerLike, MtInvalidPeerTypeError } from '../../types' import { TelegramClient } from '../../client' import { isInputPeerChannel, @@ -37,5 +37,5 @@ export async function leaveChat( if (clear) { await this.deleteHistory(chat) } - } else throw new MtqtInvalidPeerTypeError(chatId, 'chat or channel') + } else throw new MtInvalidPeerTypeError(chatId, 'chat or channel') } diff --git a/packages/client/src/methods/chats/restrict-chat-member.ts b/packages/client/src/methods/chats/restrict-chat-member.ts index 264ed393..fe7f0a35 100644 --- a/packages/client/src/methods/chats/restrict-chat-member.ts +++ b/packages/client/src/methods/chats/restrict-chat-member.ts @@ -1,10 +1,10 @@ import { TelegramClient } from '../../client' -import { InputPeerLike, MtqtInvalidPeerTypeError } from '../../types' +import { InputPeerLike, MtInvalidPeerTypeError } from '../../types' import { isInputPeerChannel, normalizeToInputChannel, } from '../../utils/peer-utils' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { normalizeDate } from '../../utils/misc-utils' /** @@ -33,7 +33,7 @@ export async function restrictChatMember( ): Promise { const chat = await this.resolvePeer(chatId) if (!isInputPeerChannel(chat)) - throw new MtqtInvalidPeerTypeError(chatId, 'channel') + throw new MtInvalidPeerTypeError(chatId, 'channel') const user = await this.resolvePeer(userId) diff --git a/packages/client/src/methods/chats/save-draft.ts b/packages/client/src/methods/chats/save-draft.ts index bf2dd0ad..5c253775 100644 --- a/packages/client/src/methods/chats/save-draft.ts +++ b/packages/client/src/methods/chats/save-draft.ts @@ -1,6 +1,6 @@ import { TelegramClient } from '../../client' import { InputPeerLike } from '../../types' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' /** * Save or delete a draft message associated with some chat diff --git a/packages/client/src/methods/chats/set-chat-default-permissions.ts b/packages/client/src/methods/chats/set-chat-default-permissions.ts index bc1f72cc..0ca4d710 100644 --- a/packages/client/src/methods/chats/set-chat-default-permissions.ts +++ b/packages/client/src/methods/chats/set-chat-default-permissions.ts @@ -1,6 +1,6 @@ import { TelegramClient } from '../../client' -import { Chat, InputPeerLike, MtqtTypeAssertionError } from '../../types' -import { tl } from '@mtqt/tl' +import { Chat, InputPeerLike, MtTypeAssertionError } from '../../types' +import { tl } from '@mtcute/tl' import { assertIsUpdatesGroup } from '../../utils/updates-utils' /** diff --git a/packages/client/src/methods/chats/set-chat-photo.ts b/packages/client/src/methods/chats/set-chat-photo.ts index 3fe1af6c..9539cf42 100644 --- a/packages/client/src/methods/chats/set-chat-photo.ts +++ b/packages/client/src/methods/chats/set-chat-photo.ts @@ -3,16 +3,16 @@ import { InputFileLike, InputPeerLike, isUploadedFile, - MtqtArgumentError, - MtqtInvalidPeerTypeError, + MtArgumentError, + MtInvalidPeerTypeError, } from '../../types' import { isInputPeerChannel, isInputPeerChat, normalizeToInputChannel, } from '../../utils/peer-utils' -import { tl } from '@mtqt/tl' -import { fileIdToInputPhoto, tdFileId } from '@mtqt/file-id' +import { tl } from '@mtcute/tl' +import { fileIdToInputPhoto, tdFileId } from '@mtcute/file-id' /** * Set a new chat photo or video. @@ -36,14 +36,14 @@ export async function setChatPhoto( ): Promise { const chat = await this.resolvePeer(chatId) if (!(isInputPeerChannel(chat) || isInputPeerChat(chat))) - throw new MtqtInvalidPeerTypeError(chatId, 'chat or channel') + throw new MtInvalidPeerTypeError(chatId, 'chat or channel') let photo: tl.TypeInputChatPhoto | undefined = undefined let inputFile: tl.TypeInputFile if (tdFileId.isFileIdLike(media)) { if (typeof media === 'string' && media.match(/^https?:\/\//)) - throw new MtqtArgumentError("Chat photo can't be external") + throw new MtArgumentError("Chat photo can't be external") if (typeof media === 'string' && media.match(/^file:/)) { const uploaded = await this.uploadFile({ file: media.substr(5), @@ -62,7 +62,7 @@ export async function setChatPhoto( _: 'inputChatPhoto', id: media.id, } - } else throw new MtqtArgumentError("Chat photo can't be InputMedia") + } else throw new MtArgumentError("Chat photo can't be InputMedia") } else if (isUploadedFile(media)) { inputFile = media.inputFile } else if (typeof media === 'object' && tl.isAnyInputFile(media)) { diff --git a/packages/client/src/methods/chats/set-chat-title.ts b/packages/client/src/methods/chats/set-chat-title.ts index a4f0df7a..518448e2 100644 --- a/packages/client/src/methods/chats/set-chat-title.ts +++ b/packages/client/src/methods/chats/set-chat-title.ts @@ -1,5 +1,5 @@ import { TelegramClient } from '../../client' -import { InputPeerLike, MtqtInvalidPeerTypeError } from '../../types' +import { InputPeerLike, MtInvalidPeerTypeError } from '../../types' import { isInputPeerChannel, isInputPeerChat, @@ -35,7 +35,7 @@ export async function setChatTitle( channel: normalizeToInputChannel(chat), title, }) - } else throw new MtqtInvalidPeerTypeError(chatId, 'chat or channel') + } else throw new MtInvalidPeerTypeError(chatId, 'chat or channel') this._handleUpdate(res) } diff --git a/packages/client/src/methods/chats/set-chat-username.ts b/packages/client/src/methods/chats/set-chat-username.ts index aaa82680..ee2d8786 100644 --- a/packages/client/src/methods/chats/set-chat-username.ts +++ b/packages/client/src/methods/chats/set-chat-username.ts @@ -1,5 +1,5 @@ import { TelegramClient } from '../../client' -import { InputPeerLike, MtqtInvalidPeerTypeError } from '../../types' +import { InputPeerLike, MtInvalidPeerTypeError } from '../../types' import { normalizeToInputChannel } from '../../utils/peer-utils' /** @@ -17,7 +17,7 @@ export async function setChatUsername( username: string | null ): Promise { const chat = normalizeToInputChannel(await this.resolvePeer(chatId)) - if (!chat) throw new MtqtInvalidPeerTypeError(chatId, 'channel') + if (!chat) throw new MtInvalidPeerTypeError(chatId, 'channel') await this.call({ _: 'channels.updateUsername', diff --git a/packages/client/src/methods/chats/set-slow-mode.ts b/packages/client/src/methods/chats/set-slow-mode.ts index ea4db079..8fcc2858 100644 --- a/packages/client/src/methods/chats/set-slow-mode.ts +++ b/packages/client/src/methods/chats/set-slow-mode.ts @@ -1,5 +1,5 @@ import { TelegramClient } from '../../client' -import { InputPeerLike, MtqtInvalidPeerTypeError } from '../../types' +import { InputPeerLike, MtInvalidPeerTypeError } from '../../types' import { normalizeToInputChannel } from '../../utils/peer-utils' /** @@ -18,7 +18,7 @@ export async function setSlowMode( seconds = 0 ): Promise { const chat = normalizeToInputChannel(await this.resolvePeer(chatId)) - if (!chat) throw new MtqtInvalidPeerTypeError(chatId, 'channel') + if (!chat) throw new MtInvalidPeerTypeError(chatId, 'channel') const res = await this.call({ _: 'channels.toggleSlowMode', diff --git a/packages/client/src/methods/chats/unarchive-chats.ts b/packages/client/src/methods/chats/unarchive-chats.ts index 223f0032..051bc07c 100644 --- a/packages/client/src/methods/chats/unarchive-chats.ts +++ b/packages/client/src/methods/chats/unarchive-chats.ts @@ -1,7 +1,7 @@ import { TelegramClient } from '../../client' -import { MaybeArray } from '@mtqt/core' +import { MaybeArray } from '@mtcute/core' import { InputPeerLike } from '../../types' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' /** * Unarchive one or more chats diff --git a/packages/client/src/methods/chats/unban-chat-member.ts b/packages/client/src/methods/chats/unban-chat-member.ts index 33089b7e..47592a7d 100644 --- a/packages/client/src/methods/chats/unban-chat-member.ts +++ b/packages/client/src/methods/chats/unban-chat-member.ts @@ -1,5 +1,5 @@ import { TelegramClient } from '../../client' -import { InputPeerLike, MtqtInvalidPeerTypeError } from '../../types' +import { InputPeerLike, MtInvalidPeerTypeError } from '../../types' import { isInputPeerChannel, isInputPeerChat, @@ -41,5 +41,5 @@ export async function unbanChatMember( this._handleUpdate(res) } else if (isInputPeerChat(chat)) { // no-op // - } else throw new MtqtInvalidPeerTypeError(chatId, 'chat or channel') + } else throw new MtInvalidPeerTypeError(chatId, 'chat or channel') } diff --git a/packages/client/src/methods/contacts/add-contact.ts b/packages/client/src/methods/contacts/add-contact.ts index 71959a00..4f082d04 100644 --- a/packages/client/src/methods/contacts/add-contact.ts +++ b/packages/client/src/methods/contacts/add-contact.ts @@ -1,12 +1,12 @@ import { TelegramClient } from '../../client' import { InputPeerLike, - MtqtInvalidPeerTypeError, - MtqtTypeAssertionError, + MtInvalidPeerTypeError, + MtTypeAssertionError, User, } from '../../types' import { normalizeToInputUser } from '../../utils/peer-utils' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { assertIsUpdatesGroup } from '../../utils/updates-utils' /** @@ -43,7 +43,7 @@ export async function addContact( } ): Promise { const peer = normalizeToInputUser(await this.resolvePeer(userId)) - if (!peer) throw new MtqtInvalidPeerTypeError(userId, 'user') + if (!peer) throw new MtInvalidPeerTypeError(userId, 'user') const res = await this.call({ _: 'contacts.addContact', diff --git a/packages/client/src/methods/contacts/delete-contacts.ts b/packages/client/src/methods/contacts/delete-contacts.ts index 8933e92f..dbc1f004 100644 --- a/packages/client/src/methods/contacts/delete-contacts.ts +++ b/packages/client/src/methods/contacts/delete-contacts.ts @@ -1,13 +1,13 @@ import { TelegramClient } from '../../client' -import { MaybeArray } from '@mtqt/core' +import { MaybeArray } from '@mtcute/core' import { InputPeerLike, - MtqtInvalidPeerTypeError, - MtqtTypeAssertionError, + MtInvalidPeerTypeError, + MtTypeAssertionError, User, } from '../../types' import { normalizeToInputUser } from '../../utils/peer-utils' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { assertIsUpdatesGroup } from '../../utils/updates-utils' /** @@ -52,7 +52,7 @@ export async function deleteContacts( ) if (single && !inputPeers.length) - throw new MtqtInvalidPeerTypeError( + throw new MtInvalidPeerTypeError( (userIds as InputPeerLike[])[0], 'user' ) diff --git a/packages/client/src/methods/contacts/get-contacts.ts b/packages/client/src/methods/contacts/get-contacts.ts index 6f80aee5..4dc2fde1 100644 --- a/packages/client/src/methods/contacts/get-contacts.ts +++ b/packages/client/src/methods/contacts/get-contacts.ts @@ -1,7 +1,7 @@ import { TelegramClient } from '../../client' import { User } from '../../types' import { assertTypeIs } from '../../utils/type-assertion' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' /** * Get list of contacts from your Telegram contacts list. diff --git a/packages/client/src/methods/contacts/import-contacts.ts b/packages/client/src/methods/contacts/import-contacts.ts index d73f0dba..81bb2603 100644 --- a/packages/client/src/methods/contacts/import-contacts.ts +++ b/packages/client/src/methods/contacts/import-contacts.ts @@ -1,6 +1,6 @@ import { TelegramClient } from '../../client' -import { tl } from '@mtqt/tl' -import { PartialOnly } from '@mtqt/core' +import { tl } from '@mtcute/tl' +import { PartialOnly } from '@mtcute/core' import bigInt from 'big-integer' /** diff --git a/packages/client/src/methods/dialogs/_init-conversation.ts b/packages/client/src/methods/dialogs/_init-conversation.ts index 69843a76..81461a55 100644 --- a/packages/client/src/methods/dialogs/_init-conversation.ts +++ b/packages/client/src/methods/dialogs/_init-conversation.ts @@ -1,6 +1,6 @@ import { TelegramClient } from '../../client' import { Conversation, Message } from '../../types' -import { getMarkedPeerId } from '@mtqt/core' +import { getMarkedPeerId } from '@mtcute/core' // @extension interface ConversationsState { diff --git a/packages/client/src/methods/dialogs/create-folder.ts b/packages/client/src/methods/dialogs/create-folder.ts index a336ffc6..c57fe7c1 100644 --- a/packages/client/src/methods/dialogs/create-folder.ts +++ b/packages/client/src/methods/dialogs/create-folder.ts @@ -1,6 +1,6 @@ import { TelegramClient } from '../../client' -import { tl } from '@mtqt/tl' -import { PartialExcept } from '@mtqt/core' +import { tl } from '@mtcute/tl' +import { PartialExcept } from '@mtcute/core' /** * Create a folder from given parameters diff --git a/packages/client/src/methods/dialogs/delete-folder.ts b/packages/client/src/methods/dialogs/delete-folder.ts index e21a3f30..5850e0ae 100644 --- a/packages/client/src/methods/dialogs/delete-folder.ts +++ b/packages/client/src/methods/dialogs/delete-folder.ts @@ -1,5 +1,5 @@ import { TelegramClient } from '../../client' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' /** * Delete a folder by its ID diff --git a/packages/client/src/methods/dialogs/edit-folder.ts b/packages/client/src/methods/dialogs/edit-folder.ts index 8a8062d3..6c41e751 100644 --- a/packages/client/src/methods/dialogs/edit-folder.ts +++ b/packages/client/src/methods/dialogs/edit-folder.ts @@ -1,6 +1,6 @@ import { TelegramClient } from '../../client' -import { tl } from '@mtqt/tl' -import { MtqtArgumentError } from '../../types' +import { tl } from '@mtcute/tl' +import { MtArgumentError } from '../../types' /** * Edit a folder with given modification @@ -23,7 +23,7 @@ export async function editFolder( const old = await this.getFolders() const found = old.find((it) => it.id === folder || it.title === folder) if (!found) - throw new MtqtArgumentError(`Could not find a folder ${folder}`) + throw new MtArgumentError(`Could not find a folder ${folder}`) folder = found } diff --git a/packages/client/src/methods/dialogs/find-folder.ts b/packages/client/src/methods/dialogs/find-folder.ts index 84d872d7..b465e506 100644 --- a/packages/client/src/methods/dialogs/find-folder.ts +++ b/packages/client/src/methods/dialogs/find-folder.ts @@ -1,6 +1,6 @@ import { TelegramClient } from '../../client' -import { tl } from '@mtqt/tl' -import { MtqtArgumentError } from '../../types' +import { tl } from '@mtcute/tl' +import { MtArgumentError } from '../../types' /** * Find a folder by its parameter. @@ -21,7 +21,7 @@ export async function findFolder( } ): Promise { if (!params.title && !params.emoji && !params.id) - throw new MtqtArgumentError('One of search parameters must be passed') + throw new MtArgumentError('One of search parameters must be passed') const folders = await this.getFolders() diff --git a/packages/client/src/methods/dialogs/get-dialogs.ts b/packages/client/src/methods/dialogs/get-dialogs.ts index caa7412c..e2328b0b 100644 --- a/packages/client/src/methods/dialogs/get-dialogs.ts +++ b/packages/client/src/methods/dialogs/get-dialogs.ts @@ -1,13 +1,13 @@ import { TelegramClient } from '../../client' import { Dialog, - MtqtArgumentError, - MtqtTypeAssertionError, + MtArgumentError, + MtTypeAssertionError, } from '../../types' import { normalizeDate } from '../../utils/misc-utils' import { createUsersChatsIndex } from '../../utils/peer-utils' -import { tl } from '@mtqt/tl' -import { getMarkedPeerId } from '@mtqt/core' +import { tl } from '@mtcute/tl' +import { getMarkedPeerId } from '@mtcute/core' /** * Iterate over dialogs. @@ -103,7 +103,7 @@ export async function* getDialogs( * use {@link Dialog.filterFolder} instead. * * When a folder with given ID or title is not found, - * {@link MtqtArgumentError} is thrown + * {@link MtArgumentError} is thrown * * By default fetches from "All" folder */ @@ -132,7 +132,7 @@ export async function* getDialogs( (it) => it.id === params!.folder || it.title === params!.folder ) if (!found) - throw new MtqtArgumentError( + throw new MtArgumentError( `Could not find folder ${params.folder}` ) diff --git a/packages/client/src/methods/dialogs/get-folders.ts b/packages/client/src/methods/dialogs/get-folders.ts index ea088090..b2157aa3 100644 --- a/packages/client/src/methods/dialogs/get-folders.ts +++ b/packages/client/src/methods/dialogs/get-folders.ts @@ -1,5 +1,5 @@ import { TelegramClient } from '../../client' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' /** * Get list of folders. diff --git a/packages/client/src/methods/dialogs/get-peer-dialogs.ts b/packages/client/src/methods/dialogs/get-peer-dialogs.ts index a297b4e7..1cdada45 100644 --- a/packages/client/src/methods/dialogs/get-peer-dialogs.ts +++ b/packages/client/src/methods/dialogs/get-peer-dialogs.ts @@ -3,7 +3,7 @@ import { Dialog, InputPeerLike, } from '../../types' -import { MaybeArray } from '@mtqt/core' +import { MaybeArray } from '@mtcute/core' /** * Get dialogs with certain peers. diff --git a/packages/client/src/methods/dialogs/parse-dialogs.ts b/packages/client/src/methods/dialogs/parse-dialogs.ts index 71913f13..5e98e62e 100644 --- a/packages/client/src/methods/dialogs/parse-dialogs.ts +++ b/packages/client/src/methods/dialogs/parse-dialogs.ts @@ -1,8 +1,8 @@ import { TelegramClient } from '../../client' -import { tl } from '@mtqt/tl' -import { Dialog, MtqtTypeAssertionError } from '../../types' +import { tl } from '@mtcute/tl' +import { Dialog, MtTypeAssertionError } from '../../types' import { createUsersChatsIndex } from '../../utils/peer-utils' -import { getMarkedPeerId } from '@mtqt/core' +import { getMarkedPeerId } from '@mtcute/core' /** @internal */ export function _parseDialogs( @@ -10,7 +10,7 @@ export function _parseDialogs( res: tl.messages.TypeDialogs | tl.messages.TypePeerDialogs ): Dialog[] { if (res._ === 'messages.dialogsNotModified') - throw new MtqtTypeAssertionError( + throw new MtTypeAssertionError( 'messages.getPeerDialogs', '!messages.dialogsNotModified', 'messages.dialogsNotModified' diff --git a/packages/client/src/methods/files/_initialize.ts b/packages/client/src/methods/files/_initialize.ts index 54d63a64..7d2a90f8 100644 --- a/packages/client/src/methods/files/_initialize.ts +++ b/packages/client/src/methods/files/_initialize.ts @@ -1,4 +1,4 @@ -import { TelegramConnection } from '@mtqt/core' +import { TelegramConnection } from '@mtcute/core' import { TelegramClient } from '../../client' diff --git a/packages/client/src/methods/files/download-file.ts b/packages/client/src/methods/files/download-file.ts index 6bb86630..a6ba3e18 100644 --- a/packages/client/src/methods/files/download-file.ts +++ b/packages/client/src/methods/files/download-file.ts @@ -1,6 +1,6 @@ import { TelegramClient } from '../../client' import { - MtqtUnsupportedError, + MtUnsupportedError, FileDownloadParameters, FileLocation, } from '../../types' @@ -24,7 +24,7 @@ export function downloadToFile( params: FileDownloadParameters ): Promise { if (!fs) - throw new MtqtUnsupportedError( + throw new MtUnsupportedError( 'Downloading to file is only supported in NodeJS' ) diff --git a/packages/client/src/methods/files/download-iterable.ts b/packages/client/src/methods/files/download-iterable.ts index c7a34f6a..b8f58d93 100644 --- a/packages/client/src/methods/files/download-iterable.ts +++ b/packages/client/src/methods/files/download-iterable.ts @@ -1,10 +1,10 @@ import { TelegramClient } from '../../client' import { determinePartSize } from '../../utils/file-utils' -import { tl } from '@mtqt/tl' -import { FileMigrateError, FilerefUpgradeNeededError } from '@mtqt/tl/errors' +import { tl } from '@mtcute/tl' +import { FileMigrateError, FilerefUpgradeNeededError } from '@mtcute/tl/errors' import { - MtqtArgumentError, - MtqtUnsupportedError, + MtArgumentError, + MtUnsupportedError, FileDownloadParameters, FileLocation, } from '../../types' @@ -12,7 +12,7 @@ import { fileIdToInputFileLocation, fileIdToInputWebFileLocation, parseFileId, -} from '@mtqt/file-id' +} from '@mtcute/file-id' /** * Download a file and return it as an iterable, which yields file contents @@ -30,13 +30,13 @@ export async function* downloadAsIterable( params.partSize ?? (params.fileSize ? determinePartSize(params.fileSize) : 64) if (partSizeKb % 4 !== 0) - throw new MtqtArgumentError( + throw new MtArgumentError( `Invalid part size: ${partSizeKb}. Must be divisible by 4.` ) let offset = params.offset ?? 0 if (offset % 4096 !== 0) - throw new MtqtArgumentError( + throw new MtArgumentError( `Invalid offset: ${offset}. Must be divisible by 4096` ) @@ -112,7 +112,7 @@ export async function* downloadAsIterable( } else if (e.constructor === FilerefUpgradeNeededError) { // todo: implement someday // see: https://github.com/LonamiWebs/Telethon/blob/0e8bd8248cc649637b7c392616887c50986427a0/telethon/client/downloads.py#L99 - throw new MtqtUnsupportedError('File ref expired!') + throw new MtUnsupportedError('File ref expired!') } else throw e } @@ -120,7 +120,7 @@ export async function* downloadAsIterable( // 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 // i implemented that, i wouldnt be able to test that, so :shrug: - throw new MtqtUnsupportedError( + throw new MtUnsupportedError( 'Received CDN redirect, which is not supported (yet)' ) } diff --git a/packages/client/src/methods/files/normalize-file-to-document.ts b/packages/client/src/methods/files/normalize-file-to-document.ts index 26308cf8..44084941 100644 --- a/packages/client/src/methods/files/normalize-file-to-document.ts +++ b/packages/client/src/methods/files/normalize-file-to-document.ts @@ -1,6 +1,6 @@ import { TelegramClient } from '../../client' import { InputFileLike } from '../../types' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { assertTypeIs } from '../../utils/type-assertion' /** diff --git a/packages/client/src/methods/files/normalize-input-file.ts b/packages/client/src/methods/files/normalize-input-file.ts index 7fd91f9e..095257d9 100644 --- a/packages/client/src/methods/files/normalize-input-file.ts +++ b/packages/client/src/methods/files/normalize-input-file.ts @@ -1,7 +1,7 @@ import { TelegramClient } from '../../client' -import { InputFileLike, isUploadedFile, MtqtArgumentError } from '../../types' -import { tl } from '@mtqt/tl' -import { tdFileId } from '@mtqt/file-id' +import { InputFileLike, isUploadedFile, MtArgumentError } from '../../types' +import { tl } from '@mtcute/tl' +import { tdFileId } from '@mtcute/file-id' /** * Normalize a {@link InputFileLike} to `InputFile`, @@ -20,7 +20,7 @@ export async function _normalizeInputFile( } ): Promise { if (typeof input === 'object' && tl.isAnyInputMedia(input)) { - throw new MtqtArgumentError( + throw new MtArgumentError( "InputFile can't be created from an InputMedia" ) } else if (tdFileId.isFileIdLike(input)) { @@ -31,7 +31,7 @@ export async function _normalizeInputFile( }) return uploaded.inputFile } else { - throw new MtqtArgumentError( + throw new MtArgumentError( "InputFile can't be created from an URL or a File ID" ) } diff --git a/packages/client/src/methods/files/normalize-input-media.ts b/packages/client/src/methods/files/normalize-input-media.ts index d3ed9e77..5e33a143 100644 --- a/packages/client/src/methods/files/normalize-input-media.ts +++ b/packages/client/src/methods/files/normalize-input-media.ts @@ -2,16 +2,16 @@ import { TelegramClient } from '../../client' import { InputMediaLike, isUploadedFile, - MtqtArgumentError, + MtArgumentError, UploadFileLike, } from '../../types' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { fileIdToInputDocument, fileIdToInputPhoto, parseFileId, tdFileId, -} from '@mtqt/file-id' +} from '@mtcute/file-id' import { extractFileName } from '../../utils/file-utils' import { assertTypeIs } from '../../utils/type-assertion' import bigInt from 'big-integer' diff --git a/packages/client/src/methods/files/upload-file.ts b/packages/client/src/methods/files/upload-file.ts index 58ce912f..96d76232 100644 --- a/packages/client/src/methods/files/upload-file.ts +++ b/packages/client/src/methods/files/upload-file.ts @@ -9,8 +9,8 @@ import { Readable } from 'stream' import { determinePartSize, isProbablyPlainText } from '../../utils/file-utils' import { randomUlong } from '../../utils/misc-utils' import { fromBuffer } from 'file-type' -import { tl } from '@mtqt/tl' -import { MtqtArgumentError, UploadFileLike, UploadedFile } from '../../types' +import { tl } from '@mtcute/tl' +import { MtArgumentError, UploadFileLike, UploadedFile } from '../../types' import { TelegramClient } from '../../client' let fs: any = null @@ -20,7 +20,7 @@ try { path = require('path') } catch (e) {} -const debug = require('debug')('mtqt:upload') +const debug = require('debug')('mtcute:upload') const OVERRIDE_MIME: Record = { // 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 (!fs) - throw new MtqtArgumentError( + throw new MtArgumentError( 'Local paths are only supported for NodeJS!' ) file = fs.createReadStream(file) @@ -163,7 +163,7 @@ export async function uploadFile( } if (!file.body) - throw new MtqtArgumentError('Fetch response contains `null` body') + throw new MtArgumentError('Fetch response contains `null` body') if ( typeof ReadableStream !== 'undefined' && @@ -188,13 +188,13 @@ export async function uploadFile( } if (!(file instanceof Readable)) - throw new MtqtArgumentError( + throw new MtArgumentError( 'Could not convert input `file` to stream!' ) const partSizeKb = params.partSize ?? determinePartSize(fileSize) if (partSizeKb > 512) - throw new MtqtArgumentError(`Invalid part size: ${partSizeKb}KB`) + throw new MtArgumentError(`Invalid part size: ${partSizeKb}KB`) const partSize = partSizeKb * 1024 const isBig = fileSize > 10485760 // 10 MB @@ -216,14 +216,14 @@ export async function uploadFile( for (let idx = 0; idx < partCount; idx++) { const part = await readBytesFromStream(file, partSize) if (!part) - throw new MtqtArgumentError( + throw new MtArgumentError( `Unexpected EOS (there were only ${idx} parts, but expected ${partCount})` ) if (!Buffer.isBuffer(part)) - throw new MtqtArgumentError(`Part ${idx} was not a Buffer!`) + throw new MtArgumentError(`Part ${idx} was not a Buffer!`) if (part.length > partSize) - throw new MtqtArgumentError( + throw new MtArgumentError( `Part ${idx} had invalid size (expected ${partSize}, got ${part.length})` ) diff --git a/packages/client/src/methods/files/upload-media.ts b/packages/client/src/methods/files/upload-media.ts index c2bdb5f8..e8260f0d 100644 --- a/packages/client/src/methods/files/upload-media.ts +++ b/packages/client/src/methods/files/upload-media.ts @@ -2,8 +2,8 @@ import { InputMediaLike, InputPeerLike, MessageMedia, - MtqtArgumentError, - MtqtTypeAssertionError, + MtArgumentError, + MtTypeAssertionError, Photo, RawDocument, } from '../../types' import { TelegramClient } from '../../client' @@ -53,7 +53,7 @@ export async function uploadMedia( case 'inputMediaInvoice': case 'inputMediaPoll': case 'inputMediaDice': - throw new MtqtArgumentError("This media can't be uploaded") + throw new MtArgumentError("This media can't be uploaded") } const res = await this.call({ @@ -67,7 +67,7 @@ export async function uploadMedia( }) if (res._ === 'messageMediaEmpty') { - throw new MtqtTypeAssertionError( + throw new MtTypeAssertionError( 'uploadMedia', 'not messageMediaEmpty', 'messageMediaEmpty' diff --git a/packages/client/src/methods/invite-links/get-invite-link-members.ts b/packages/client/src/methods/invite-links/get-invite-link-members.ts index 3b6b415e..dd9bac74 100644 --- a/packages/client/src/methods/invite-links/get-invite-link-members.ts +++ b/packages/client/src/methods/invite-links/get-invite-link-members.ts @@ -1,7 +1,7 @@ import { TelegramClient } from '../../client' import { ChatInviteLink, InputPeerLike, User } from '../../types' import { createUsersChatsIndex } from '../../utils/peer-utils' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' /** * Iterate over users who have joined diff --git a/packages/client/src/methods/invite-links/get-invite-links.ts b/packages/client/src/methods/invite-links/get-invite-links.ts index 1d0980b7..a16eee02 100644 --- a/packages/client/src/methods/invite-links/get-invite-links.ts +++ b/packages/client/src/methods/invite-links/get-invite-links.ts @@ -2,13 +2,13 @@ import { TelegramClient } from '../../client' import { ChatInviteLink, InputPeerLike, - MtqtInvalidPeerTypeError, + MtInvalidPeerTypeError, } from '../../types' import { createUsersChatsIndex, normalizeToInputUser, } from '../../utils/peer-utils' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' /** * 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 admin = normalizeToInputUser(await this.resolvePeer(adminId)) - if (!admin) throw new MtqtInvalidPeerTypeError(adminId, 'user') + if (!admin) throw new MtInvalidPeerTypeError(adminId, 'user') let offsetDate: number | undefined = undefined let offsetLink: string | undefined = undefined diff --git a/packages/client/src/methods/invite-links/get-primary-invite-link.ts b/packages/client/src/methods/invite-links/get-primary-invite-link.ts index b90c9032..9b15b33d 100644 --- a/packages/client/src/methods/invite-links/get-primary-invite-link.ts +++ b/packages/client/src/methods/invite-links/get-primary-invite-link.ts @@ -2,7 +2,7 @@ import { TelegramClient } from '../../client' import { ChatInviteLink, InputPeerLike, - MtqtTypeAssertionError, + MtTypeAssertionError, } from '../../types' import { createUsersChatsIndex } from '../../utils/peer-utils' @@ -25,7 +25,7 @@ export async function getPrimaryInviteLink( }) if (!res.invites[0]?.permanent) - throw new MtqtTypeAssertionError( + throw new MtTypeAssertionError( 'messages.getExportedChatInvites (@ .invites[0].permanent)', 'true', 'false' diff --git a/packages/client/src/methods/messages/close-poll.ts b/packages/client/src/methods/messages/close-poll.ts index d68d0db6..0a4d17ed 100644 --- a/packages/client/src/methods/messages/close-poll.ts +++ b/packages/client/src/methods/messages/close-poll.ts @@ -1,5 +1,5 @@ import { TelegramClient } from '../../client' -import { InputPeerLike, MtqtTypeAssertionError, Poll } from '../../types' +import { InputPeerLike, MtTypeAssertionError, Poll } from '../../types' import { createUsersChatsIndex } from '../../utils/peer-utils' import bigInt from 'big-integer' import { assertTypeIs } from '../../utils/type-assertion' @@ -47,7 +47,7 @@ export async function closePoll( 'updateMessagePoll' ) if (!upd.poll) { - throw new MtqtTypeAssertionError( + throw new MtTypeAssertionError( 'messages.editMessage (@ .updates[0].poll)', 'poll', 'undefined' diff --git a/packages/client/src/methods/messages/delete-messages.ts b/packages/client/src/methods/messages/delete-messages.ts index 9bc31cbf..d6e8c21d 100644 --- a/packages/client/src/methods/messages/delete-messages.ts +++ b/packages/client/src/methods/messages/delete-messages.ts @@ -1,6 +1,6 @@ import { TelegramClient } from '../../client' import { InputPeerLike } from '../../types' -import { MaybeArray } from '@mtqt/core' +import { MaybeArray } from '@mtcute/core' import { isInputPeerChannel, normalizeToInputChannel, diff --git a/packages/client/src/methods/messages/delete-scheduled-messages.ts b/packages/client/src/methods/messages/delete-scheduled-messages.ts index accbf5b4..a9060083 100644 --- a/packages/client/src/methods/messages/delete-scheduled-messages.ts +++ b/packages/client/src/methods/messages/delete-scheduled-messages.ts @@ -1,6 +1,6 @@ import { TelegramClient } from '../../client' import { InputPeerLike } from '../../types' -import { MaybeArray } from '@mtqt/core' +import { MaybeArray } from '@mtcute/core' import { isInputPeerChannel, normalizeToInputChannel, diff --git a/packages/client/src/methods/messages/edit-inline-message.ts b/packages/client/src/methods/messages/edit-inline-message.ts index 3878e7c3..8c8d10ba 100644 --- a/packages/client/src/methods/messages/edit-inline-message.ts +++ b/packages/client/src/methods/messages/edit-inline-message.ts @@ -1,6 +1,6 @@ import { TelegramClient } from '../../client' import { BotKeyboard, FormattedString, InputMediaLike, ReplyMarkup } from '../../types' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' /** * Edit sent inline message text, media and reply markup. diff --git a/packages/client/src/methods/messages/edit-message.ts b/packages/client/src/methods/messages/edit-message.ts index 0f9fb4c7..1ffb7567 100644 --- a/packages/client/src/methods/messages/edit-message.ts +++ b/packages/client/src/methods/messages/edit-message.ts @@ -6,7 +6,7 @@ import { Message, ReplyMarkup, } from '../../types' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' /** * Edit message text, media, reply markup and schedule date. diff --git a/packages/client/src/methods/messages/find-in-update.ts b/packages/client/src/methods/messages/find-in-update.ts index 93ee836b..93a5dca5 100644 --- a/packages/client/src/methods/messages/find-in-update.ts +++ b/packages/client/src/methods/messages/find-in-update.ts @@ -1,6 +1,6 @@ import { TelegramClient } from '../../client' -import { tl } from '@mtqt/tl' -import { Message, MtqtTypeAssertionError } from '../../types' +import { tl } from '@mtcute/tl' +import { Message, MtTypeAssertionError } from '../../types' import { createUsersChatsIndex } from '../../utils/peer-utils' import { assertIsUpdatesGroup } from '../../utils/updates-utils' @@ -36,7 +36,7 @@ export function _findMessageInUpdate( } } - throw new MtqtTypeAssertionError( + throw new MtTypeAssertionError( '_findInUpdate (@ .updates[*])', 'updateNewMessage | updateNewChannelMessage | updateNewScheduledMessage', 'none' diff --git a/packages/client/src/methods/messages/forward-messages.ts b/packages/client/src/methods/messages/forward-messages.ts index 79e285a4..513f1fb3 100644 --- a/packages/client/src/methods/messages/forward-messages.ts +++ b/packages/client/src/methods/messages/forward-messages.ts @@ -4,11 +4,11 @@ import { InputMediaLike, InputPeerLike, Message, - MtqtArgumentError, - MtqtTypeAssertionError, + MtArgumentError, + MtTypeAssertionError, } from '../../types' -import { MaybeArray } from '@mtqt/core' -import { tl } from '@mtqt/tl' +import { MaybeArray } from '@mtcute/core' +import { tl } from '@mtcute/tl' import { createUsersChatsIndex } from '../../utils/peer-utils' import { normalizeDate, randomUlong } from '../../utils/misc-utils' import { assertIsUpdatesGroup } from '../../utils/updates-utils' @@ -197,7 +197,7 @@ export async function forwardMessages( // error, instead only first 100 IDs will be forwarded, // which is definitely not the best outcome. if ((messages as number[]).length > 100) - throw new MtqtArgumentError( + throw new MtArgumentError( 'You can forward no more than 100 messages at once' ) @@ -206,7 +206,7 @@ export async function forwardMessages( let captionMessage: Message | null = null if (params.caption) { if (params.captionMedia) - throw new MtqtArgumentError( + throw new MtArgumentError( 'You can either pass `caption` or `captionMedia`' ) diff --git a/packages/client/src/methods/messages/get-discussion-message.ts b/packages/client/src/methods/messages/get-discussion-message.ts index b602c686..bc141edf 100644 --- a/packages/client/src/methods/messages/get-discussion-message.ts +++ b/packages/client/src/methods/messages/get-discussion-message.ts @@ -1,6 +1,6 @@ import { TelegramClient } from '../../client' import { InputPeerLike, Message } from '../../types' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { createUsersChatsIndex } from '../../utils/peer-utils' /** @internal */ diff --git a/packages/client/src/methods/messages/get-history.ts b/packages/client/src/methods/messages/get-history.ts index 1f096369..8e005039 100644 --- a/packages/client/src/methods/messages/get-history.ts +++ b/packages/client/src/methods/messages/get-history.ts @@ -1,5 +1,5 @@ import { TelegramClient } from '../../client' -import { InputPeerLike, Message, MtqtTypeAssertionError } from '../../types' +import { InputPeerLike, Message, MtTypeAssertionError } from '../../types' import { createUsersChatsIndex } from '../../utils/peer-utils' import { normalizeDate } from '../../utils/misc-utils' @@ -74,7 +74,7 @@ export async function getHistory( }) if (res._ === 'messages.messagesNotModified') - throw new MtqtTypeAssertionError( + throw new MtTypeAssertionError( 'messages.getHistory', '!messages.messagesNotModified', res._ diff --git a/packages/client/src/methods/messages/get-message-group.ts b/packages/client/src/methods/messages/get-message-group.ts index 0581f3eb..ea93b7bc 100644 --- a/packages/client/src/methods/messages/get-message-group.ts +++ b/packages/client/src/methods/messages/get-message-group.ts @@ -1,5 +1,5 @@ import { TelegramClient } from '../../client' -import { InputPeerLike, MtqtArgumentError, Message } from '../../types' +import { InputPeerLike, MtArgumentError, Message } from '../../types' import { isInputPeerChannel } from '../../utils/peer-utils' /** @@ -32,7 +32,7 @@ export async function getMessageGroup( const messages = await this.getMessages(chatId, ids) const groupedId = messages.find((it) => it?.id === message)!.groupedId - if (!groupedId) throw new MtqtArgumentError('This message is not grouped') + if (!groupedId) throw new MtArgumentError('This message is not grouped') return messages.filter( (it) => it && it.groupedId?.eq(groupedId) diff --git a/packages/client/src/methods/messages/get-messages-unsafe.ts b/packages/client/src/methods/messages/get-messages-unsafe.ts index 6b5ed4ef..ba2d4ef6 100644 --- a/packages/client/src/methods/messages/get-messages-unsafe.ts +++ b/packages/client/src/methods/messages/get-messages-unsafe.ts @@ -1,10 +1,10 @@ import { TelegramClient } from '../../client' -import { MaybeArray } from '@mtqt/core' +import { MaybeArray } from '@mtcute/core' import { createUsersChatsIndex, } from '../../utils/peer-utils' -import { tl } from '@mtqt/tl' -import { Message, MtqtTypeAssertionError } from '../../types' +import { tl } from '@mtcute/tl' +import { Message, MtTypeAssertionError } from '../../types' /** * Get a single message from PM or legacy group by its ID. @@ -67,7 +67,7 @@ export async function getMessagesUnsafe( }) if (res._ === 'messages.messagesNotModified') - throw new MtqtTypeAssertionError( + throw new MtTypeAssertionError( 'getMessages', '!messages.messagesNotModified', res._ diff --git a/packages/client/src/methods/messages/get-messages.ts b/packages/client/src/methods/messages/get-messages.ts index 01451e32..a8c738d4 100644 --- a/packages/client/src/methods/messages/get-messages.ts +++ b/packages/client/src/methods/messages/get-messages.ts @@ -1,12 +1,12 @@ import { TelegramClient } from '../../client' -import { MaybeArray } from '@mtqt/core' +import { MaybeArray } from '@mtcute/core' import { createUsersChatsIndex, isInputPeerChannel, normalizeToInputChannel, } from '../../utils/peer-utils' -import { tl } from '@mtqt/tl' -import { Message, InputPeerLike, MtqtTypeAssertionError } from '../../types' +import { tl } from '@mtcute/tl' +import { Message, InputPeerLike, MtTypeAssertionError } from '../../types' /** * Get a single message in chat by its ID @@ -78,7 +78,7 @@ export async function getMessages( ) if (res._ === 'messages.messagesNotModified') - throw new MtqtTypeAssertionError( + throw new MtTypeAssertionError( 'getMessages', '!messages.messagesNotModified', res._ diff --git a/packages/client/src/methods/messages/get-scheduled-messages.ts b/packages/client/src/methods/messages/get-scheduled-messages.ts index 1f9f103e..d89f2649 100644 --- a/packages/client/src/methods/messages/get-scheduled-messages.ts +++ b/packages/client/src/methods/messages/get-scheduled-messages.ts @@ -1,12 +1,12 @@ import { TelegramClient } from '../../client' -import { MaybeArray } from '@mtqt/core' +import { MaybeArray } from '@mtcute/core' import { createUsersChatsIndex, isInputPeerChannel, normalizeToInputChannel, } from '../../utils/peer-utils' -import { tl } from '@mtqt/tl' -import { Message, InputPeerLike, MtqtTypeAssertionError } from '../../types' +import { tl } from '@mtcute/tl' +import { Message, InputPeerLike, MtTypeAssertionError } from '../../types' /** * Get a single scheduled message in chat by its ID @@ -54,7 +54,7 @@ export async function getScheduledMessages( }) if (res._ === 'messages.messagesNotModified') - throw new MtqtTypeAssertionError( + throw new MtTypeAssertionError( 'getMessages', '!messages.messagesNotModified', res._ diff --git a/packages/client/src/methods/messages/normalize-inline.ts b/packages/client/src/methods/messages/normalize-inline.ts index 96154e91..a1334e98 100644 --- a/packages/client/src/methods/messages/normalize-inline.ts +++ b/packages/client/src/methods/messages/normalize-inline.ts @@ -1,6 +1,6 @@ import { TelegramClient } from '../../client' -import { tl } from '@mtqt/tl' -import { TelegramConnection } from '@mtqt/core' +import { tl } from '@mtcute/tl' +import { TelegramConnection } from '@mtcute/core' import { parseInlineMessageId } from '../../utils/inline-utils' // @extension diff --git a/packages/client/src/methods/messages/parse-entities.ts b/packages/client/src/methods/messages/parse-entities.ts index d83d0fff..9845a98b 100644 --- a/packages/client/src/methods/messages/parse-entities.ts +++ b/packages/client/src/methods/messages/parse-entities.ts @@ -1,7 +1,7 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { TelegramClient } from '../../client' import { normalizeToInputUser } from '../../utils/peer-utils' -import { FormattedString, MtqtError } from '../../types' +import { FormattedString, MtClientError } from '../../types' const empty: [string, undefined] = ['', undefined] @@ -29,7 +29,7 @@ export async function _parseEntities( if (!mode) return [text, []] if (!(mode in this._parseModes)) { - throw new MtqtError(`Parse mode ${mode} is not registered.`) + throw new MtClientError(`Parse mode ${mode} is not registered.`) } ;[text, entities] = await this._parseModes[mode].parse(text) diff --git a/packages/client/src/methods/messages/search-global.ts b/packages/client/src/methods/messages/search-global.ts index da7274fe..1307152c 100644 --- a/packages/client/src/methods/messages/search-global.ts +++ b/packages/client/src/methods/messages/search-global.ts @@ -1,6 +1,6 @@ import { TelegramClient } from '../../client' -import { Message, MtqtTypeAssertionError } from '../../types' -import { tl } from '@mtqt/tl' +import { Message, MtTypeAssertionError } from '../../types' +import { tl } from '@mtcute/tl' import { createUsersChatsIndex } from '../../utils/peer-utils' import { SearchFilters } from '../../types' @@ -71,7 +71,7 @@ export async function* searchGlobal( }) if (res._ === 'messages.messagesNotModified') - throw new MtqtTypeAssertionError( + throw new MtTypeAssertionError( 'messages.searchGlobal', '!messages.messagesNotModified', res._ diff --git a/packages/client/src/methods/messages/search-messages.ts b/packages/client/src/methods/messages/search-messages.ts index 1c1ecd45..6670854d 100644 --- a/packages/client/src/methods/messages/search-messages.ts +++ b/packages/client/src/methods/messages/search-messages.ts @@ -1,6 +1,6 @@ import { TelegramClient } from '../../client' -import { InputPeerLike, Message, MtqtTypeAssertionError } from '../../types' -import { tl } from '@mtqt/tl' +import { InputPeerLike, Message, MtTypeAssertionError } from '../../types' +import { tl } from '@mtcute/tl' import { createUsersChatsIndex } from '../../utils/peer-utils' import { SearchFilters } from '../../types' @@ -92,7 +92,7 @@ export async function* searchMessages( }) if (res._ === 'messages.messagesNotModified') - throw new MtqtTypeAssertionError( + throw new MtTypeAssertionError( 'messages.search', '!messages.messagesNotModified', res._ diff --git a/packages/client/src/methods/messages/send-copy.ts b/packages/client/src/methods/messages/send-copy.ts index aae3f583..a687317e 100644 --- a/packages/client/src/methods/messages/send-copy.ts +++ b/packages/client/src/methods/messages/send-copy.ts @@ -1,7 +1,7 @@ import { TelegramClient } from '../../client' import { InputPeerLike, Message, FormattedString, ReplyMarkup } from '../../types' -import { tl } from '@mtqt/tl' -import { MessageNotFoundError } from '@mtqt/tl/errors' +import { tl } from '@mtcute/tl' +import { MessageNotFoundError } from '@mtcute/tl/errors' /** * Copy a message (i.e. send the same message, diff --git a/packages/client/src/methods/messages/send-media-group.ts b/packages/client/src/methods/messages/send-media-group.ts index 7e0f0faf..0c29fd4f 100644 --- a/packages/client/src/methods/messages/send-media-group.ts +++ b/packages/client/src/methods/messages/send-media-group.ts @@ -3,7 +3,7 @@ import { BotKeyboard, InputFileLike, InputMediaLike, InputPeerLike, - Message, MtqtArgumentError, + Message, MtArgumentError, ReplyMarkup, } from '../../types' import { @@ -11,10 +11,10 @@ import { normalizeMessageId, randomUlong, } from '../../utils/misc-utils' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { assertIsUpdatesGroup } from '../../utils/updates-utils' import { createUsersChatsIndex } from '../../utils/peer-utils' -import { MessageNotFoundError } from '@mtqt/tl/errors' +import { MessageNotFoundError } from '@mtcute/tl/errors' /** * Send a group of media. @@ -124,7 +124,7 @@ export async function sendMediaGroup( if (params.mustReply) { if (!replyTo) - throw new MtqtArgumentError( + throw new MtArgumentError( 'mustReply used, but replyTo was not passed' ) diff --git a/packages/client/src/methods/messages/send-media.ts b/packages/client/src/methods/messages/send-media.ts index 31fa4bbb..0940592e 100644 --- a/packages/client/src/methods/messages/send-media.ts +++ b/packages/client/src/methods/messages/send-media.ts @@ -3,7 +3,7 @@ import { BotKeyboard, FormattedString, InputMediaLike, InputPeerLike, - Message, MtqtArgumentError, + Message, MtArgumentError, ReplyMarkup, } from '../../types' import { @@ -11,8 +11,8 @@ import { normalizeMessageId, randomUlong, } from '../../utils/misc-utils' -import { tl } from '@mtqt/tl' -import { MessageNotFoundError } from '@mtqt/tl/errors' +import { tl } from '@mtcute/tl' +import { MessageNotFoundError } from '@mtcute/tl/errors' /** * Send a single media (a photo or a document-based media) @@ -151,7 +151,7 @@ export async function sendMedia( if (params.mustReply) { if (!replyTo) - throw new MtqtArgumentError( + throw new MtArgumentError( 'mustReply used, but replyTo was not passed' ) diff --git a/packages/client/src/methods/messages/send-scheduled.ts b/packages/client/src/methods/messages/send-scheduled.ts index 21679e18..ae37cc3f 100644 --- a/packages/client/src/methods/messages/send-scheduled.ts +++ b/packages/client/src/methods/messages/send-scheduled.ts @@ -1,5 +1,5 @@ import { InputPeerLike, Message } from '../../types' -import { MaybeArray } from '@mtqt/core' +import { MaybeArray } from '@mtcute/core' import { TelegramClient } from '../../client' import { assertIsUpdatesGroup } from '../../utils/updates-utils' import { createUsersChatsIndex } from '../../utils/peer-utils' diff --git a/packages/client/src/methods/messages/send-text.ts b/packages/client/src/methods/messages/send-text.ts index bca89c3e..78c205bb 100644 --- a/packages/client/src/methods/messages/send-text.ts +++ b/packages/client/src/methods/messages/send-text.ts @@ -1,5 +1,5 @@ import { TelegramClient } from '../../client' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { inputPeerToPeer } from '../../utils/peer-utils' import { normalizeDate, @@ -12,11 +12,11 @@ import { BotKeyboard, ReplyMarkup, UsersIndex, - MtqtTypeAssertionError, + MtTypeAssertionError, ChatsIndex, - MtqtArgumentError, FormattedString, + MtArgumentError, FormattedString, } from '../../types' -import { getMarkedPeerId, MessageNotFoundError } from '@mtqt/core' +import { getMarkedPeerId, MessageNotFoundError } from '@mtcute/core' import { createDummyUpdate } from '../../utils/updates-utils' /** @@ -127,7 +127,7 @@ export async function sendText( if (params.mustReply) { if (!replyTo) - throw new MtqtArgumentError( + throw new MtArgumentError( 'mustReply used, but replyTo was not passed' ) @@ -197,7 +197,7 @@ export async function sendText( } if (!cached) { - throw new MtqtTypeAssertionError( + throw new MtTypeAssertionError( 'sendText (@ getFullPeerById)', 'user | chat', 'null' @@ -215,7 +215,7 @@ export async function sendText( chats[cached.id] = cached break default: - throw new MtqtTypeAssertionError( + throw new MtTypeAssertionError( 'sendText (@ users.getUsers)', 'user | chat | channel', // not very accurate, but good enough cached._ diff --git a/packages/client/src/methods/messages/send-typing.ts b/packages/client/src/methods/messages/send-typing.ts index 42aae8c2..c23c3610 100644 --- a/packages/client/src/methods/messages/send-typing.ts +++ b/packages/client/src/methods/messages/send-typing.ts @@ -1,5 +1,5 @@ import { TelegramClient } from '../../client' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { InputPeerLike, TypingStatus } from '../../types' /** diff --git a/packages/client/src/methods/messages/send-vote.ts b/packages/client/src/methods/messages/send-vote.ts index cd9d83ab..41565ba9 100644 --- a/packages/client/src/methods/messages/send-vote.ts +++ b/packages/client/src/methods/messages/send-vote.ts @@ -1,11 +1,11 @@ import { TelegramClient } from '../../client' import { InputPeerLike, - MtqtArgumentError, - MtqtTypeAssertionError, + MtArgumentError, + MtTypeAssertionError, Poll, } from '../../types' -import { MaybeArray, MessageNotFoundError } from '@mtqt/core' +import { MaybeArray, MessageNotFoundError } from '@mtcute/core' import { createUsersChatsIndex } from '../../utils/peer-utils' import { assertTypeIs } from '../../utils/type-assertion' import { assertIsUpdatesGroup } from '../../utils/updates-utils' @@ -40,7 +40,7 @@ export async function sendVote( if (!msg) throw new MessageNotFoundError() if (!(msg.media instanceof Poll)) - throw new MtqtArgumentError( + throw new MtArgumentError( 'This message does not contain a poll' ) @@ -67,7 +67,7 @@ export async function sendVote( const upd = res.updates[0] assertTypeIs('messages.sendVote (@ .updates[0])', upd, 'updateMessagePoll') if (!upd.poll) { - throw new MtqtTypeAssertionError( + throw new MtTypeAssertionError( 'messages.sendVote (@ .updates[0].poll)', 'poll', 'undefined' diff --git a/packages/client/src/methods/misc/init-takeout-session.ts b/packages/client/src/methods/misc/init-takeout-session.ts index f7feaf70..2ac926ab 100644 --- a/packages/client/src/methods/misc/init-takeout-session.ts +++ b/packages/client/src/methods/misc/init-takeout-session.ts @@ -1,5 +1,5 @@ import { TelegramClient } from '../../client' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { TakeoutSession } from '../../types' /** diff --git a/packages/client/src/methods/parse-modes/parse-modes.ts b/packages/client/src/methods/parse-modes/parse-modes.ts index 4b4e2f2e..b996310f 100644 --- a/packages/client/src/methods/parse-modes/parse-modes.ts +++ b/packages/client/src/methods/parse-modes/parse-modes.ts @@ -1,5 +1,5 @@ import { TelegramClient } from '../../client' -import { MtqtError, IMessageEntityParser } from '../../types' +import { MtClientError, IMessageEntityParser } from '../../types' /** * Register a given {@link IMessageEntityParser} as a parse mode @@ -7,7 +7,7 @@ import { MtqtError, IMessageEntityParser } from '../../types' * mode is also set as default. * * @param parseMode Parse mode to register - * @throws MtqtError When the parse mode with a given name is already registered. + * @throws MtClientError When the parse mode with a given name is already registered. * @internal */ export function registerParseMode( @@ -17,7 +17,7 @@ export function registerParseMode( const name = parseMode.name if (name in this._parseModes) { - throw new MtqtError( + throw new MtClientError( `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). * * @param name Name of the parse mode which parser to get. - * @throws MtqtError When the provided parse mode is not registered - * @throws MtqtError When `name` is omitted and there is no default parse mode + * @throws MtClientError When the provided parse mode is not registered + * @throws MtClientError When `name` is omitted and there is no default parse mode * @internal */ export function getParseMode( @@ -59,13 +59,13 @@ export function getParseMode( ): IMessageEntityParser { if (!name) { if (!this._defaultParseMode) - throw new MtqtError('There is no default parse mode') + throw new MtClientError('There is no default parse mode') name = this._defaultParseMode } if (!(name in this._parseModes)) { - throw new MtqtError(`Parse mode ${name} is not registered.`) + throw new MtClientError(`Parse mode ${name} is not registered.`) } return this._parseModes[name] @@ -75,12 +75,12 @@ export function getParseMode( * Set a given parse mode as a default one. * * @param name Name of the parse mode - * @throws MtqtError When given parse mode is not registered. + * @throws MtClientError When given parse mode is not registered. * @internal */ export function setDefaultParseMode(this: TelegramClient, name: string): void { if (!(name in this._parseModes)) { - throw new MtqtError(`Parse mode ${name} is not registered.`) + throw new MtClientError(`Parse mode ${name} is not registered.`) } this._defaultParseMode = name diff --git a/packages/client/src/methods/pasword/change-cloud-password.ts b/packages/client/src/methods/pasword/change-cloud-password.ts index 3091be9e..399c5be6 100644 --- a/packages/client/src/methods/pasword/change-cloud-password.ts +++ b/packages/client/src/methods/pasword/change-cloud-password.ts @@ -1,7 +1,7 @@ import { TelegramClient } from '../../client' -import { MtqtArgumentError } from '../../types' +import { MtArgumentError } from '../../types' import { assertTypeIs } from '../../utils/type-assertion' -import { computeSrpParams, computeNewPasswordHash } from '@mtqt/core' +import { computeSrpParams, computeNewPasswordHash } from '@mtcute/core' /** * Change your 2FA password @@ -19,7 +19,7 @@ export async function changeCloudPassword( ): Promise { const pwd = await this.call({ _: 'account.getPassword' }) if (!pwd.hasPassword) - throw new MtqtArgumentError('Cloud password is not enabled') + throw new MtArgumentError('Cloud password is not enabled') const algo = pwd.newAlgo assertTypeIs( diff --git a/packages/client/src/methods/pasword/enable-cloud-password.ts b/packages/client/src/methods/pasword/enable-cloud-password.ts index 7b1eb6dc..ece987db 100644 --- a/packages/client/src/methods/pasword/enable-cloud-password.ts +++ b/packages/client/src/methods/pasword/enable-cloud-password.ts @@ -1,7 +1,7 @@ import { TelegramClient } from '../../client' -import { MtqtArgumentError } from '../../types' +import { MtArgumentError } from '../../types' import { assertTypeIs } from '../../utils/type-assertion' -import { computeNewPasswordHash } from '@mtqt/core' +import { computeNewPasswordHash } from '@mtcute/core' /** * Enable 2FA password on your account @@ -24,7 +24,7 @@ export async function enableCloudPassword( ): Promise { const pwd = await this.call({ _: 'account.getPassword' }) if (pwd.hasPassword) - throw new MtqtArgumentError('Cloud password is already enabled') + throw new MtArgumentError('Cloud password is already enabled') const algo = pwd.newAlgo assertTypeIs( diff --git a/packages/client/src/methods/pasword/remove-cloud-password.ts b/packages/client/src/methods/pasword/remove-cloud-password.ts index ece975f8..dac7c04f 100644 --- a/packages/client/src/methods/pasword/remove-cloud-password.ts +++ b/packages/client/src/methods/pasword/remove-cloud-password.ts @@ -1,6 +1,6 @@ import { TelegramClient } from '../../client' -import { MtqtArgumentError } from '../../types' -import { computeSrpParams } from '@mtqt/core' +import { MtArgumentError } from '../../types' +import { computeSrpParams } from '@mtcute/core' /** * Remove 2FA password from your account @@ -14,7 +14,7 @@ export async function removeCloudPassword( ): Promise { const pwd = await this.call({ _: 'account.getPassword' }) if (!pwd.hasPassword) - throw new MtqtArgumentError('Cloud password is not enabled') + throw new MtArgumentError('Cloud password is not enabled') const oldSrp = await computeSrpParams(this._crypto, pwd, password) diff --git a/packages/client/src/methods/stickers/add-sticker-to-set.ts b/packages/client/src/methods/stickers/add-sticker-to-set.ts index b297d6b6..c6511c16 100644 --- a/packages/client/src/methods/stickers/add-sticker-to-set.ts +++ b/packages/client/src/methods/stickers/add-sticker-to-set.ts @@ -1,6 +1,6 @@ import { TelegramClient } from '../../client' import { InputFileLike, InputStickerSetItem, StickerSet } from '../../types' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' const MASK_POS = { forehead: 0, diff --git a/packages/client/src/methods/stickers/create-sticker-set.ts b/packages/client/src/methods/stickers/create-sticker-set.ts index 1ef0c961..328aa29e 100644 --- a/packages/client/src/methods/stickers/create-sticker-set.ts +++ b/packages/client/src/methods/stickers/create-sticker-set.ts @@ -3,10 +3,10 @@ import { InputFileLike, InputPeerLike, InputStickerSetItem, - MtqtInvalidPeerTypeError, + MtInvalidPeerTypeError, StickerSet, } from '../../types' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { normalizeToInputUser } from '../../utils/peer-utils' const MASK_POS = { @@ -94,7 +94,7 @@ export async function createStickerSet( } ): Promise { const owner = normalizeToInputUser(await this.resolvePeer(params.owner)) - if (!owner) throw new MtqtInvalidPeerTypeError(params.owner, 'user') + if (!owner) throw new MtInvalidPeerTypeError(params.owner, 'user') const inputStickers: tl.TypeInputStickerSetItem[] = [] diff --git a/packages/client/src/methods/stickers/delete-sticker-from-set.ts b/packages/client/src/methods/stickers/delete-sticker-from-set.ts index 249f9dab..06d973ac 100644 --- a/packages/client/src/methods/stickers/delete-sticker-from-set.ts +++ b/packages/client/src/methods/stickers/delete-sticker-from-set.ts @@ -1,7 +1,7 @@ import { TelegramClient } from '../../client' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { StickerSet } from '../../types' -import { fileIdToInputDocument, tdFileId } from '@mtqt/file-id' +import { fileIdToInputDocument, tdFileId } from '@mtcute/file-id' /** * Delete a sticker from a sticker set diff --git a/packages/client/src/methods/stickers/get-sticker-set.ts b/packages/client/src/methods/stickers/get-sticker-set.ts index 042d0c45..e40f8786 100644 --- a/packages/client/src/methods/stickers/get-sticker-set.ts +++ b/packages/client/src/methods/stickers/get-sticker-set.ts @@ -1,5 +1,5 @@ import { TelegramClient } from '../../client' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { StickerSet } from '../../types' /** diff --git a/packages/client/src/methods/stickers/move-sticker-in-set.ts b/packages/client/src/methods/stickers/move-sticker-in-set.ts index cd8433a1..a89b8fb4 100644 --- a/packages/client/src/methods/stickers/move-sticker-in-set.ts +++ b/packages/client/src/methods/stickers/move-sticker-in-set.ts @@ -1,6 +1,6 @@ import { TelegramClient } from '../../client' -import { fileIdToInputDocument, tdFileId } from '@mtqt/file-id' -import { tl } from '@mtqt/tl' +import { fileIdToInputDocument, tdFileId } from '@mtcute/file-id' +import { tl } from '@mtcute/tl' import { StickerSet } from '../../types' /** diff --git a/packages/client/src/methods/stickers/set-sticker-set-thumb.ts b/packages/client/src/methods/stickers/set-sticker-set-thumb.ts index 36652530..1dc8cd6b 100644 --- a/packages/client/src/methods/stickers/set-sticker-set-thumb.ts +++ b/packages/client/src/methods/stickers/set-sticker-set-thumb.ts @@ -1,5 +1,5 @@ import { TelegramClient } from '../../client' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { InputFileLike, StickerSet } from '../../types' /** diff --git a/packages/client/src/methods/updates.ts b/packages/client/src/methods/updates.ts index 450d5563..0854cb50 100644 --- a/packages/client/src/methods/updates.ts +++ b/packages/client/src/methods/updates.ts @@ -1,4 +1,4 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { TelegramClient } from '../client' import { createUsersChatsIndex, @@ -11,12 +11,12 @@ import { getMarkedPeerId, markedPeerIdToBare, MAX_CHANNEL_ID, RpcError, -} from '@mtqt/core' +} from '@mtcute/core' import { isDummyUpdate, isDummyUpdates } from '../utils/updates-utils' import { ChatsIndex, UsersIndex } from '../types' import { _parseUpdate } from '../utils/parse-update' -const debug = require('debug')('mtqt:upds') +const debug = require('debug')('mtcute:upds') // code in this file is very bad, thanks to Telegram's awesome updates mechanism diff --git a/packages/client/src/methods/users/delete-profile-photos.ts b/packages/client/src/methods/users/delete-profile-photos.ts index 73743df3..50407c02 100644 --- a/packages/client/src/methods/users/delete-profile-photos.ts +++ b/packages/client/src/methods/users/delete-profile-photos.ts @@ -1,7 +1,7 @@ import { TelegramClient } from '../../client' -import { MaybeArray } from '@mtqt/core' -import { tl } from '@mtqt/tl' -import { fileIdToInputPhoto } from '@mtqt/file-id' +import { MaybeArray } from '@mtcute/core' +import { tl } from '@mtcute/tl' +import { fileIdToInputPhoto } from '@mtcute/file-id' /** * Delete your own profile photos diff --git a/packages/client/src/methods/users/get-common-chats.ts b/packages/client/src/methods/users/get-common-chats.ts index d13a5e5a..3299db43 100644 --- a/packages/client/src/methods/users/get-common-chats.ts +++ b/packages/client/src/methods/users/get-common-chats.ts @@ -1,4 +1,4 @@ -import { InputPeerLike, MtqtInvalidPeerTypeError } from '../../types' +import { InputPeerLike, MtInvalidPeerTypeError } from '../../types' import { TelegramClient } from '../../client' import { Chat } from '../../types' import { normalizeToInputUser } from '../../utils/peer-utils' @@ -7,7 +7,7 @@ import { normalizeToInputUser } from '../../utils/peer-utils' * Get a list of common chats you have with a given user * * @param userId User's ID, username or phone number - * @throws MtqtInvalidPeerTypeError + * @throws MtInvalidPeerTypeError * @internal */ export async function getCommonChats( @@ -15,7 +15,7 @@ export async function getCommonChats( userId: InputPeerLike ): Promise { const peer = normalizeToInputUser(await this.resolvePeer(userId)) - if (!peer) throw new MtqtInvalidPeerTypeError(userId, 'user') + if (!peer) throw new MtInvalidPeerTypeError(userId, 'user') return this.call({ _: 'messages.getCommonChats', diff --git a/packages/client/src/methods/users/get-profile-photos.ts b/packages/client/src/methods/users/get-profile-photos.ts index f8a242ad..d85164b5 100644 --- a/packages/client/src/methods/users/get-profile-photos.ts +++ b/packages/client/src/methods/users/get-profile-photos.ts @@ -1,8 +1,8 @@ import { TelegramClient } from '../../client' -import { InputPeerLike, MtqtInvalidPeerTypeError, Photo } from '../../types' +import { InputPeerLike, MtInvalidPeerTypeError, Photo } from '../../types' import { normalizeToInputUser } from '../../utils/peer-utils' import bigInt from 'big-integer' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' /** * Get a list of profile pictures of a user @@ -33,7 +33,7 @@ export async function getProfilePhotos( if (!params) params = {} const peer = normalizeToInputUser(await this.resolvePeer(userId)) - if (!peer) throw new MtqtInvalidPeerTypeError(userId, 'user') + if (!peer) throw new MtInvalidPeerTypeError(userId, 'user') const res = await this.call({ _: 'photos.getUserPhotos', diff --git a/packages/client/src/methods/users/get-users.ts b/packages/client/src/methods/users/get-users.ts index 1a76d012..e0b007a1 100644 --- a/packages/client/src/methods/users/get-users.ts +++ b/packages/client/src/methods/users/get-users.ts @@ -1,7 +1,7 @@ import { InputPeerLike, User } from '../../types' import { TelegramClient } from '../../client' -import { MaybeArray } from '@mtqt/core' -import { tl } from '@mtqt/tl' +import { MaybeArray } from '@mtcute/core' +import { tl } from '@mtcute/tl' import { normalizeToInputUser } from '../../utils/peer-utils' /** diff --git a/packages/client/src/methods/users/iter-profile-photos.ts b/packages/client/src/methods/users/iter-profile-photos.ts index 1c97cc96..443ea059 100644 --- a/packages/client/src/methods/users/iter-profile-photos.ts +++ b/packages/client/src/methods/users/iter-profile-photos.ts @@ -1,7 +1,7 @@ import { TelegramClient } from '../../client' -import { InputPeerLike, MtqtInvalidPeerTypeError, Photo } from '../../types' +import { InputPeerLike, MtInvalidPeerTypeError, Photo } from '../../types' import { normalizeToInputUser } from '../../utils/peer-utils' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import bigInt from 'big-integer' /** @@ -46,7 +46,7 @@ export async function* iterProfilePhotos( if (!params) params = {} const peer = normalizeToInputUser(await this.resolvePeer(userId)) - if (!peer) throw new MtqtInvalidPeerTypeError(userId, 'user') + if (!peer) throw new MtInvalidPeerTypeError(userId, 'user') let offset = params.offset || 0 let current = 0 diff --git a/packages/client/src/methods/users/resolve-peer-many.ts b/packages/client/src/methods/users/resolve-peer-many.ts index bf8b7288..aa484ad9 100644 --- a/packages/client/src/methods/users/resolve-peer-many.ts +++ b/packages/client/src/methods/users/resolve-peer-many.ts @@ -1,4 +1,4 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { TelegramClient } from '../../client' import { InputPeerLike } from '../../types' import { asyncPool } from 'eager-async-pool' diff --git a/packages/client/src/methods/users/resolve-peer.ts b/packages/client/src/methods/users/resolve-peer.ts index ac2200da..a031d35e 100644 --- a/packages/client/src/methods/users/resolve-peer.ts +++ b/packages/client/src/methods/users/resolve-peer.ts @@ -1,7 +1,7 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { TelegramClient } from '../../client' -import { InputPeerLike, MtqtNotFoundError } from '../../types' -import { getBasicPeerType, getMarkedPeerId, MAX_CHANNEL_ID } from '@mtqt/core' +import { InputPeerLike, MtNotFoundError } from '../../types' +import { getBasicPeerType, getMarkedPeerId, MAX_CHANNEL_ID } from '@mtcute/core' import bigInt from 'big-integer' import { normalizeToInputPeer } from '../../utils/peer-utils' import { assertTypeIs } from '../../utils/type-assertion' @@ -57,7 +57,7 @@ export async function resolvePeer( accessHash: found.accessHash!, } - throw new MtqtNotFoundError( + throw new MtNotFoundError( `Could not find a peer by phone ${peerId}` ) } else { @@ -105,7 +105,7 @@ export async function resolvePeer( } } - throw new MtqtNotFoundError( + throw new MtNotFoundError( `Could not find a peer by username ${peerId}` ) } @@ -186,5 +186,5 @@ export async function resolvePeer( } } - throw new MtqtNotFoundError(`Could not find a peer by ID ${peerId}`) + throw new MtNotFoundError(`Could not find a peer by ID ${peerId}`) } diff --git a/packages/client/src/methods/users/set-profile-photo.ts b/packages/client/src/methods/users/set-profile-photo.ts index 3c20d24a..ac3062ae 100644 --- a/packages/client/src/methods/users/set-profile-photo.ts +++ b/packages/client/src/methods/users/set-profile-photo.ts @@ -1,7 +1,7 @@ import { TelegramClient } from '../../client' -import { InputFileLike, MtqtArgumentError, Photo } from '../../types' -import { tl } from '@mtqt/tl' -import { fileIdToInputPhoto, tdFileId } from '@mtqt/file-id' +import { InputFileLike, MtArgumentError, Photo } from '../../types' +import { tl } from '@mtcute/tl' +import { fileIdToInputPhoto, tdFileId } from '@mtcute/file-id' /** * Set a new profile photo or video. @@ -24,7 +24,7 @@ export async function setProfilePhoto( // try parsing media as file id or input photo if (tdFileId.isFileIdLike(media) || typeof media === 'object' && tl.isAnyInputPhoto(media)) { if (typeof media === 'string' && media.match(/^https?:\/\//)) { - throw new MtqtArgumentError('Profile photo can\'t be set from URL.') + throw new MtArgumentError('Profile photo can\'t be set from URL.') } if (tdFileId.isFileIdLike(media)) { diff --git a/packages/client/src/types/auth/sent-code.ts b/packages/client/src/types/auth/sent-code.ts index c8aed78f..6fb70f4e 100644 --- a/packages/client/src/types/auth/sent-code.ts +++ b/packages/client/src/types/auth/sent-code.ts @@ -1,4 +1,4 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { makeInspectable } from '../utils' const sentCodeMap: Record< diff --git a/packages/client/src/types/auth/terms-of-service.ts b/packages/client/src/types/auth/terms-of-service.ts index 986e28f1..ba01e78c 100644 --- a/packages/client/src/types/auth/terms-of-service.ts +++ b/packages/client/src/types/auth/terms-of-service.ts @@ -1,4 +1,4 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { MessageEntity } from '../messages' import { makeInspectable } from '../utils' diff --git a/packages/client/src/types/bots/callback-query.ts b/packages/client/src/types/bots/callback-query.ts index 4cfdd927..0d5084fd 100644 --- a/packages/client/src/types/bots/callback-query.ts +++ b/packages/client/src/types/bots/callback-query.ts @@ -1,12 +1,12 @@ import { makeInspectable } from '../utils' import { TelegramClient } from '../../client' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { Message } from '../messages' -import { MtqtArgumentError } from '../errors' -import { BasicPeerType, getBasicPeerType, getMarkedPeerId } from '@mtqt/core' +import { MtArgumentError } from '../errors' +import { BasicPeerType, getBasicPeerType, getMarkedPeerId } from '@mtcute/core' import { encodeInlineMessageId } from '../../utils/inline-utils' import { User, UsersIndex } from '../peers' -import { MessageNotFoundError } from '@mtqt/core' +import { MessageNotFoundError } from '@mtcute/core' /** * An incoming callback query, originated from a callback button @@ -80,7 +80,7 @@ export class CallbackQuery { */ get inlineMessageId(): tl.TypeInputBotInlineMessageID { if (this.raw._ !== 'updateInlineBotCallbackQuery') - throw new MtqtArgumentError( + throw new MtArgumentError( 'Cannot get inline message id for non-inline callback' ) @@ -98,7 +98,7 @@ export class CallbackQuery { */ get inlineMessageIdStr(): string { if (this.raw._ !== 'updateInlineBotCallbackQuery') - throw new MtqtArgumentError( + throw new MtArgumentError( 'Cannot get inline message id for non-inline callback' ) @@ -110,7 +110,7 @@ export class CallbackQuery { */ get chatId(): number { if (this.raw._ !== 'updateBotCallbackQuery') - throw new MtqtArgumentError( + throw new MtArgumentError( 'Cannot get message id for inline callback' ) @@ -133,7 +133,7 @@ export class CallbackQuery { */ get messageId(): number { if (this.raw._ !== 'updateBotCallbackQuery') - throw new MtqtArgumentError( + throw new MtArgumentError( 'Cannot get message id for inline callback' ) @@ -187,7 +187,7 @@ export class CallbackQuery { */ async getMessage(): Promise { if (this.raw._ !== 'updateBotCallbackQuery') - throw new MtqtArgumentError( + throw new MtArgumentError( 'Cannot get a message for inline callback' ) diff --git a/packages/client/src/types/bots/command-scope.ts b/packages/client/src/types/bots/command-scope.ts index e0e7396e..61f5a945 100644 --- a/packages/client/src/types/bots/command-scope.ts +++ b/packages/client/src/types/bots/command-scope.ts @@ -1,4 +1,4 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { InputPeerLike } from '../peers' /** diff --git a/packages/client/src/types/bots/game-high-score.ts b/packages/client/src/types/bots/game-high-score.ts index 58d0866f..e66236d6 100644 --- a/packages/client/src/types/bots/game-high-score.ts +++ b/packages/client/src/types/bots/game-high-score.ts @@ -1,6 +1,6 @@ import { makeInspectable } from '../utils' import { TelegramClient } from '../../client' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { User, UsersIndex } from '../peers' /** diff --git a/packages/client/src/types/bots/inline-query.ts b/packages/client/src/types/bots/inline-query.ts index 32276972..de0f8769 100644 --- a/packages/client/src/types/bots/inline-query.ts +++ b/packages/client/src/types/bots/inline-query.ts @@ -1,5 +1,5 @@ import { makeInspectable } from '../utils' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { PeerType, User, UsersIndex } from '../peers' import { TelegramClient } from '../../client' import { Location } from '../media' diff --git a/packages/client/src/types/bots/input/input-inline-message.ts b/packages/client/src/types/bots/input/input-inline-message.ts index f0c4d9ff..4922f410 100644 --- a/packages/client/src/types/bots/input/input-inline-message.ts +++ b/packages/client/src/types/bots/input/input-inline-message.ts @@ -1,4 +1,4 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { BotKeyboard, ReplyMarkup } from '../keyboards' import { TelegramClient } from '../../../client' import { diff --git a/packages/client/src/types/bots/input/input-inline-result.ts b/packages/client/src/types/bots/input/input-inline-result.ts index 01fa6fe1..c5ab7da6 100644 --- a/packages/client/src/types/bots/input/input-inline-result.ts +++ b/packages/client/src/types/bots/input/input-inline-result.ts @@ -1,9 +1,9 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { BotInlineMessage, InputInlineMessage } from './input-inline-message' import { TelegramClient } from '../../../client' -import { fileIdToInputDocument, fileIdToInputPhoto } from '@mtqt/file-id' +import { fileIdToInputDocument, fileIdToInputPhoto } from '@mtcute/file-id' import { extractFileName } from '../../../utils/file-utils' -import { MtqtArgumentError } from '../../errors' +import { MtArgumentError } from '../../errors' interface BaseInputInlineResult { /** @@ -819,7 +819,7 @@ export namespace BotInline { parseMode ) if (sendMessage._ !== 'inputBotInlineMessageGame') { - throw new MtqtArgumentError( + throw new MtArgumentError( 'game inline result must contain a game inline message' ) } @@ -861,7 +861,7 @@ export namespace BotInline { venueType: '' } } else { - throw new MtqtArgumentError( + throw new MtArgumentError( 'message or location (lat&lon) bust be supplied for venue inline result' ) } @@ -913,7 +913,7 @@ export namespace BotInline { // file id or url if (obj.media.match(/^https?:\/\//)) { if (obj.type === 'sticker') - throw new MtqtArgumentError( + throw new MtArgumentError( 'sticker inline result cannot contain a URL' ) @@ -925,7 +925,7 @@ export namespace BotInline { else if (obj.type === 'voice') mime = 'audio/ogg' else if (obj.type === 'file') { if (!obj.mime) - throw new MtqtArgumentError( + throw new MtArgumentError( 'MIME type must be specified for file inline result' ) diff --git a/packages/client/src/types/bots/keyboard-builder.ts b/packages/client/src/types/bots/keyboard-builder.ts index 6ea4e915..d624852f 100644 --- a/packages/client/src/types/bots/keyboard-builder.ts +++ b/packages/client/src/types/bots/keyboard-builder.ts @@ -1,5 +1,5 @@ import type { InlineKeyboardMarkup, ReplyKeyboardMarkup } from './keyboards' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' type ButtonLike = tl.TypeKeyboardButton | false | null | undefined | void diff --git a/packages/client/src/types/bots/keyboards.ts b/packages/client/src/types/bots/keyboards.ts index 071d2839..c00b3c82 100644 --- a/packages/client/src/types/bots/keyboards.ts +++ b/packages/client/src/types/bots/keyboards.ts @@ -1,4 +1,4 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { BotKeyboardBuilder } from './keyboard-builder' /** diff --git a/packages/client/src/types/calls/discard-reason.ts b/packages/client/src/types/calls/discard-reason.ts index 535560a1..46e7a3ab 100644 --- a/packages/client/src/types/calls/discard-reason.ts +++ b/packages/client/src/types/calls/discard-reason.ts @@ -5,7 +5,7 @@ * - `hangup`: The call was ended normally * - `busy`: The call was discarded because the user is in another call */ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' export type CallDiscardReason = 'missed' | 'disconnect' | 'hangup' | 'busy' diff --git a/packages/client/src/types/conversation.ts b/packages/client/src/types/conversation.ts index 96bc15a1..7f577ecc 100644 --- a/packages/client/src/types/conversation.ts +++ b/packages/client/src/types/conversation.ts @@ -1,17 +1,17 @@ -import { AsyncLock, getMarkedPeerId, MaybeAsync } from '@mtqt/core' +import { AsyncLock, getMarkedPeerId, MaybeAsync } from '@mtcute/core' import { ControllablePromise, createControllablePromise, -} from '@mtqt/core/src/utils/controllable-promise' +} from '@mtcute/core/src/utils/controllable-promise' import { TelegramClient } from '../client' import { InputMediaLike } from './media' -import { MtqtArgumentError } from './errors' +import { MtArgumentError } from './errors' import { InputPeerLike } from './peers' import { HistoryReadUpdate } from './updates' import { FormattedString } from './parser' import { Message } from './messages' -import { tl } from '@mtqt/tl' -import { TimeoutError } from '@mtqt/tl/errors' +import { tl } from '@mtcute/tl' +import { TimeoutError } from '@mtcute/tl/errors' import { Queue } from '../utils/queue' interface QueuedHandler { @@ -62,7 +62,7 @@ export class Conversation { */ get inputPeer(): tl.TypeInputPeer { if (!this._started) { - throw new MtqtArgumentError("Conversation hasn't started yet") + throw new MtArgumentError("Conversation hasn't started yet") } return this._inputPeer @@ -73,7 +73,7 @@ export class Conversation { */ get lastMessage(): number { if (!this._started) { - throw new MtqtArgumentError("Conversation hasn't started yet") + throw new MtArgumentError("Conversation hasn't started yet") } return this._lastMessage @@ -87,7 +87,7 @@ export class Conversation { */ get lastReceivedMessage(): number { if (!this._started) { - throw new MtqtArgumentError("Conversation hasn't started yet") + throw new MtArgumentError("Conversation hasn't started yet") } return this._lastReceivedMessage @@ -157,7 +157,7 @@ export class Conversation { params?: Parameters[2] ): ReturnType { if (!this._started) { - throw new MtqtArgumentError("Conversation hasn't started yet") + throw new MtArgumentError("Conversation hasn't started yet") } return this.client.sendText(this._inputPeer, text, params) @@ -174,7 +174,7 @@ export class Conversation { params?: Parameters[2] ): ReturnType { if (!this._started) { - throw new MtqtArgumentError("Conversation hasn't started yet") + throw new MtArgumentError("Conversation hasn't started yet") } return this.client.sendMedia(this._inputPeer, media, params) @@ -191,7 +191,7 @@ export class Conversation { params?: Parameters[2] ): ReturnType { if (!this._started) { - throw new MtqtArgumentError("Conversation hasn't started yet") + throw new MtArgumentError("Conversation hasn't started yet") } return this.client.sendMediaGroup( @@ -210,7 +210,7 @@ export class Conversation { */ markRead(message?: number | null, clearMentions = true): Promise { if (!this._started) { - throw new MtqtArgumentError("Conversation hasn't started yet") + throw new MtArgumentError("Conversation hasn't started yet") } if (message === null) { @@ -263,7 +263,7 @@ export class Conversation { timeout: number | null = 15000 ): Promise { if (!this._started) { - throw new MtqtArgumentError("Conversation hasn't started yet") + throw new MtArgumentError("Conversation hasn't started yet") } const promise = createControllablePromise() @@ -355,7 +355,7 @@ export class Conversation { ): Promise { const msgId = params?.message ?? this._lastMessage if (!msgId) - throw new MtqtArgumentError( + throw new MtArgumentError( 'Provide message for which to wait for reply for' ) @@ -398,12 +398,12 @@ export class Conversation { } ): Promise { if (!this._started) { - throw new MtqtArgumentError("Conversation hasn't started yet") + throw new MtArgumentError("Conversation hasn't started yet") } const msgId = params?.message ?? this._lastReceivedMessage if (!msgId) { - throw new MtqtArgumentError( + throw new MtArgumentError( 'Provide message for which to wait for edit for' ) } @@ -441,12 +441,12 @@ export class Conversation { */ async waitForRead(message?: number, timeout: number | null = 15000): Promise { if (!this._started) { - throw new MtqtArgumentError("Conversation hasn't started yet") + throw new MtArgumentError("Conversation hasn't started yet") } const msgId = message ?? this._lastMessage if (!msgId) - throw new MtqtArgumentError( + throw new MtArgumentError( 'Provide message for which to wait for read for' ) diff --git a/packages/client/src/types/errors.ts b/packages/client/src/types/errors.ts index 5191d15d..4969a6d2 100644 --- a/packages/client/src/types/errors.ts +++ b/packages/client/src/types/errors.ts @@ -1,20 +1,20 @@ /** - * Base class for all `@mtqt/client` errors + * Base class for all `@mtcute/client` errors */ import { InputPeerLike } from './peers' -export class MtqtError extends Error {} +export class MtClientError extends Error {} /** * Method invocation was invalid because some argument * passed was invalid. */ -export class MtqtArgumentError extends MtqtError {} +export class MtArgumentError extends MtClientError {} /** * Could not find peer by provided information */ -export class MtqtNotFoundError extends MtqtError {} +export class MtNotFoundError extends MtClientError {} /** * Either you requested or the server returned something @@ -22,7 +22,7 @@ export class MtqtNotFoundError extends MtqtError {} * * Stay tuned for future updates! */ -export class MtqtUnsupportedError extends MtqtError {} +export class MtUnsupportedError extends MtClientError {} /** * Server returned something of an unexpected type. @@ -30,7 +30,7 @@ export class MtqtUnsupportedError extends MtqtError {} * This is usually a problem on library side. * Feel free to open an issue about this! */ -export class MtqtTypeAssertionError extends MtqtError { +export class MtTypeAssertionError extends MtClientError { /** * Context at which the error occurred. * Usually a user-friendly string containing name @@ -63,7 +63,7 @@ export class MtqtTypeAssertionError extends MtqtError { * For example, when trying to get common chats * while providing another chat as `userId` */ -export class MtqtInvalidPeerTypeError extends MtqtError { +export class MtInvalidPeerTypeError extends MtClientError { constructor(peer: InputPeerLike, expected: string) { super( `Provided identifier ${JSON.stringify(peer)} is not a ${expected}` @@ -75,7 +75,7 @@ export class MtqtInvalidPeerTypeError extends MtqtError { * Trying to access to some property on an object that does not * contain that information. */ -export class MtqtEmptyError extends MtqtError { +export class MtEmptyError extends MtClientError { constructor() { super('Property is not available on an empty object') } diff --git a/packages/client/src/types/files/file-location.ts b/packages/client/src/types/files/file-location.ts index 1bc6daa7..b7934e40 100644 --- a/packages/client/src/types/files/file-location.ts +++ b/packages/client/src/types/files/file-location.ts @@ -1,4 +1,4 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { TelegramClient } from '../../client' import { Readable } from 'stream' import { makeInspectable } from '../utils' diff --git a/packages/client/src/types/files/uploaded-file.ts b/packages/client/src/types/files/uploaded-file.ts index d170c5c5..5977510b 100644 --- a/packages/client/src/types/files/uploaded-file.ts +++ b/packages/client/src/types/files/uploaded-file.ts @@ -1,4 +1,4 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' /** * Describes a file uploaded to the Telegram servers diff --git a/packages/client/src/types/files/utils.ts b/packages/client/src/types/files/utils.ts index e060091a..163f599f 100644 --- a/packages/client/src/types/files/utils.ts +++ b/packages/client/src/types/files/utils.ts @@ -1,9 +1,9 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import type { Readable } from 'stream' import type { ReadStream } from 'fs' import { UploadedFile } from './uploaded-file' import { FileLocation } from './file-location' -import { tdFileId } from '@mtqt/file-id' +import { tdFileId } from '@mtcute/file-id' /** * Describes types that can be used in {@link TelegramClient.uploadFile} diff --git a/packages/client/src/types/files/web-document.ts b/packages/client/src/types/files/web-document.ts index 14ed5921..526586b3 100644 --- a/packages/client/src/types/files/web-document.ts +++ b/packages/client/src/types/files/web-document.ts @@ -1,11 +1,11 @@ import { TelegramClient } from '../../client' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { FileLocation } from './file-location' -import { MtqtArgumentError } from '../errors' +import { MtArgumentError } from '../errors' import { makeInspectable } from '../utils' const STUB_LOCATION = () => { - throw new MtqtArgumentError( + throw new MtArgumentError( 'This web document is not downloadable through Telegram' ) } diff --git a/packages/client/src/types/index.ts b/packages/client/src/types/index.ts index 69ac8dd1..374453c9 100644 --- a/packages/client/src/types/index.ts +++ b/packages/client/src/types/index.ts @@ -11,4 +11,4 @@ export * from './conversation' export * from './errors' export * from './parser' export { MaybeDynamic, ArrayWithTotal } from './utils' -export { MaybeAsync, PartialExcept, PartialOnly } from '@mtqt/core' +export { MaybeAsync, PartialExcept, PartialOnly } from '@mtcute/core' diff --git a/packages/client/src/types/media/audio.ts b/packages/client/src/types/media/audio.ts index b5612518..27cc46d9 100644 --- a/packages/client/src/types/media/audio.ts +++ b/packages/client/src/types/media/audio.ts @@ -1,8 +1,8 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { TelegramClient } from '../../client' import { RawDocument } from './document' import { makeInspectable } from '../utils' -import { tdFileId } from '@mtqt/file-id' +import { tdFileId } from '@mtcute/file-id' /** * An audio file diff --git a/packages/client/src/types/media/contact.ts b/packages/client/src/types/media/contact.ts index 31db20f8..d0099064 100644 --- a/packages/client/src/types/media/contact.ts +++ b/packages/client/src/types/media/contact.ts @@ -1,7 +1,7 @@ /** * A phone contact */ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { makeInspectable } from '../utils' export class Contact { diff --git a/packages/client/src/types/media/dice.ts b/packages/client/src/types/media/dice.ts index 0c43f82b..e7cae761 100644 --- a/packages/client/src/types/media/dice.ts +++ b/packages/client/src/types/media/dice.ts @@ -1,4 +1,4 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { makeInspectable } from '../utils' /** diff --git a/packages/client/src/types/media/document-utils.ts b/packages/client/src/types/media/document-utils.ts index 190a0fc8..47a630b9 100644 --- a/packages/client/src/types/media/document-utils.ts +++ b/packages/client/src/types/media/document-utils.ts @@ -1,4 +1,4 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { Document, RawDocument } from './document' import { Audio } from './audio' import { TelegramClient } from '../../client' diff --git a/packages/client/src/types/media/document.ts b/packages/client/src/types/media/document.ts index f209be94..5aa7a4fd 100644 --- a/packages/client/src/types/media/document.ts +++ b/packages/client/src/types/media/document.ts @@ -1,9 +1,9 @@ import { FileLocation } from '../files' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { Thumbnail } from './thumbnail' import { TelegramClient } from '../../client' import { makeInspectable } from '../utils' -import { tdFileId as td, toFileId, toUniqueFileId } from '@mtqt/file-id' +import { tdFileId as td, toFileId, toUniqueFileId } from '@mtcute/file-id' /** * A file that is represented as a document in MTProto. diff --git a/packages/client/src/types/media/game.ts b/packages/client/src/types/media/game.ts index 292ac36a..8e3948a0 100644 --- a/packages/client/src/types/media/game.ts +++ b/packages/client/src/types/media/game.ts @@ -1,4 +1,4 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { Photo } from './photo' import { Video } from './video' import { TelegramClient } from '../../client' diff --git a/packages/client/src/types/media/input-media.ts b/packages/client/src/types/media/input-media.ts index da1934d3..979af34b 100644 --- a/packages/client/src/types/media/input-media.ts +++ b/packages/client/src/types/media/input-media.ts @@ -1,7 +1,7 @@ import { InputFileLike } from '../files' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { Venue } from './venue' -import { MaybeArray } from '@mtqt/core' +import { MaybeArray } from '@mtcute/core' import { FormattedString } from '../parser' interface BaseInputMedia { diff --git a/packages/client/src/types/media/invoice.ts b/packages/client/src/types/media/invoice.ts index 9a521f87..0db4d06a 100644 --- a/packages/client/src/types/media/invoice.ts +++ b/packages/client/src/types/media/invoice.ts @@ -1,8 +1,8 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { TelegramClient } from '../../client' import { makeInspectable } from '../utils' import { WebDocument } from '../files/web-document' -import { MtqtArgumentError } from '../errors' +import { MtArgumentError } from '../errors' /** * An invoice @@ -105,7 +105,7 @@ export class Invoice { * is only provided to allow using `msg.media.inputMedia` */ get inputMedia(): tl.TypeInputMedia { - throw new MtqtArgumentError('Invoice cannot provide an InputMedia') + throw new MtArgumentError('Invoice cannot provide an InputMedia') } } diff --git a/packages/client/src/types/media/location.ts b/packages/client/src/types/media/location.ts index 28e6b70e..e7e9da3c 100644 --- a/packages/client/src/types/media/location.ts +++ b/packages/client/src/types/media/location.ts @@ -1,5 +1,5 @@ import { makeInspectable } from '../utils' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { FileLocation } from '../files' import { TelegramClient } from '../../client' diff --git a/packages/client/src/types/media/photo.ts b/packages/client/src/types/media/photo.ts index df50ebb4..bc27abc3 100644 --- a/packages/client/src/types/media/photo.ts +++ b/packages/client/src/types/media/photo.ts @@ -1,7 +1,7 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { FileLocation } from '../files' import { TelegramClient } from '../../client' -import { MtqtArgumentError } from '../errors' +import { MtArgumentError } from '../errors' import { Thumbnail } from './thumbnail' import { makeInspectable } from '../utils' @@ -61,7 +61,7 @@ export class Photo extends FileLocation { bestSize = max } else { // does this happen at all? - throw new MtqtArgumentError('Photo does not have any sizes') + throw new MtArgumentError('Photo does not have any sizes') } } @@ -116,7 +116,7 @@ export class Photo extends FileLocation { get fileId(): string { if (!this._fileId) { if (!this._bestSize) { - throw new MtqtArgumentError( + throw new MtArgumentError( 'Cannot get File ID for this photo' ) } @@ -135,7 +135,7 @@ export class Photo extends FileLocation { get uniqueFileId(): string { if (!this._uniqueFileId) { if (!this._bestSize) { - throw new MtqtArgumentError( + throw new MtArgumentError( 'Cannot get File ID for this photo' ) } diff --git a/packages/client/src/types/media/poll.ts b/packages/client/src/types/media/poll.ts index 6a47e0b6..d3eb73ad 100644 --- a/packages/client/src/types/media/poll.ts +++ b/packages/client/src/types/media/poll.ts @@ -1,5 +1,5 @@ import { makeInspectable } from '../utils' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { TelegramClient } from '../../client' import { MessageEntity } from '../messages' import bigInt from 'big-integer' diff --git a/packages/client/src/types/media/sticker.ts b/packages/client/src/types/media/sticker.ts index b6e05ffc..51c68ff8 100644 --- a/packages/client/src/types/media/sticker.ts +++ b/packages/client/src/types/media/sticker.ts @@ -1,9 +1,9 @@ import { RawDocument } from './document' import { TelegramClient } from '../../client' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { makeInspectable } from '../utils' import { StickerSet } from '../misc' -import { tdFileId } from '@mtqt/file-id' +import { tdFileId } from '@mtcute/file-id' export namespace Sticker { export interface MaskPosition { diff --git a/packages/client/src/types/media/thumbnail.ts b/packages/client/src/types/media/thumbnail.ts index 6d0f21f5..ad405915 100644 --- a/packages/client/src/types/media/thumbnail.ts +++ b/packages/client/src/types/media/thumbnail.ts @@ -1,15 +1,15 @@ import { TelegramClient } from '../../client' import { FileLocation } from '../files' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { inflateSvgPath, strippedPhotoToJpg, svgPathToFile, } from '../../utils/file-utils' -import { MtqtArgumentError, MtqtTypeAssertionError } from '../errors' +import { MtArgumentError, MtTypeAssertionError } from '../errors' import { assertTypeIs } from '../../utils/type-assertion' import { makeInspectable } from '../utils' -import { tdFileId as td, toFileId, toUniqueFileId } from '@mtqt/file-id' +import { tdFileId as td, toFileId, toUniqueFileId } from '@mtcute/file-id' import bigInt from 'big-integer' /** @@ -56,7 +56,7 @@ export class Thumbnail extends FileLocation { switch (sz._) { case 'photoSizeEmpty': case 'photoCachedSize': - throw new MtqtTypeAssertionError( + throw new MtTypeAssertionError( 'sz', 'not (photoSizeEmpty | photoCachedSize)', sz._ @@ -140,7 +140,7 @@ export class Thumbnail extends FileLocation { * * See also: https://core.telegram.org/api/files#vector-thumbnails * - * @throws MtqtTypeAssertionError In case {@link raw} is not `tl.RawPhotoPathSize` + * @throws MtTypeAssertionError In case {@link raw} is not `tl.RawPhotoPathSize` */ get path(): string { assertTypeIs('Thumbnail#path', this.raw, 'photoPathSize') @@ -159,7 +159,7 @@ export class Thumbnail extends FileLocation { this.raw._ !== 'photoSize' && this.raw._ !== 'photoSizeProgressive' ) { - throw new MtqtArgumentError( + throw new MtArgumentError( `Cannot generate a file ID for "${this.raw.type}"` ) } @@ -218,7 +218,7 @@ export class Thumbnail extends FileLocation { this.raw._ !== 'photoSize' && this.raw._ !== 'photoSizeProgressive' ) { - throw new MtqtArgumentError( + throw new MtArgumentError( `Cannot generate a unique file ID for "${this.raw.type}"` ) } diff --git a/packages/client/src/types/media/venue.ts b/packages/client/src/types/media/venue.ts index 2b0c465b..ef4a895c 100644 --- a/packages/client/src/types/media/venue.ts +++ b/packages/client/src/types/media/venue.ts @@ -1,4 +1,4 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { Location } from './location' import { assertTypeIs } from '../../utils/type-assertion' import { makeInspectable } from '../utils' diff --git a/packages/client/src/types/media/video.ts b/packages/client/src/types/media/video.ts index ba188e62..d8eca2d7 100644 --- a/packages/client/src/types/media/video.ts +++ b/packages/client/src/types/media/video.ts @@ -1,8 +1,8 @@ import { RawDocument } from './document' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { TelegramClient } from '../../client' import { makeInspectable } from '../utils' -import { tdFileId } from '@mtqt/file-id' +import { tdFileId } from '@mtcute/file-id' /** * A video, round video message or GIF animation. diff --git a/packages/client/src/types/media/voice.ts b/packages/client/src/types/media/voice.ts index 0584c438..46d5cd35 100644 --- a/packages/client/src/types/media/voice.ts +++ b/packages/client/src/types/media/voice.ts @@ -1,8 +1,8 @@ import { RawDocument } from './document' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { TelegramClient } from '../../client' import { makeInspectable } from '../utils' -import { tdFileId } from '@mtqt/file-id' +import { tdFileId } from '@mtcute/file-id' import { decodeWaveform } from '../../utils/voice-utils' /** diff --git a/packages/client/src/types/media/web-page.ts b/packages/client/src/types/media/web-page.ts index 2c1c4da9..2787b668 100644 --- a/packages/client/src/types/media/web-page.ts +++ b/packages/client/src/types/media/web-page.ts @@ -1,10 +1,10 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { Photo } from './photo' import { TelegramClient } from '../../client' import { RawDocument } from './document' import { parseDocument } from './document-utils' import { makeInspectable } from '../utils' -import { MtqtArgumentError } from '../errors' +import { MtArgumentError } from '../errors' /** * Web page preview. @@ -220,7 +220,7 @@ export class WebPage { * is only provided to allow using `msg.media.inputMedia` */ get inputMedia(): tl.TypeInputMedia { - throw new MtqtArgumentError('WebPage cannot provide an InputMedia') + throw new MtArgumentError('WebPage cannot provide an InputMedia') } } diff --git a/packages/client/src/types/messages/dialog.ts b/packages/client/src/types/messages/dialog.ts index 17fafa0b..c87dd24d 100644 --- a/packages/client/src/types/messages/dialog.ts +++ b/packages/client/src/types/messages/dialog.ts @@ -1,10 +1,10 @@ import { TelegramClient } from '../../client' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { Chat, ChatsIndex, UsersIndex } from '../peers' import { Message } from './message' import { DraftMessage } from './draft-message' import { makeInspectable } from '../utils' -import { getMarkedPeerId, MessageNotFoundError } from '@mtqt/core' +import { getMarkedPeerId, MessageNotFoundError } from '@mtcute/core' /** * A dialog. diff --git a/packages/client/src/types/messages/draft-message.ts b/packages/client/src/types/messages/draft-message.ts index 1cb861ad..cea3afec 100644 --- a/packages/client/src/types/messages/draft-message.ts +++ b/packages/client/src/types/messages/draft-message.ts @@ -1,7 +1,7 @@ /** * A draft message */ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { TelegramClient } from '../../client' import { MessageEntity } from './message-entity' import { Message } from './message' diff --git a/packages/client/src/types/messages/message-action.ts b/packages/client/src/types/messages/message-action.ts index 21ee201a..a5374c51 100644 --- a/packages/client/src/types/messages/message-action.ts +++ b/packages/client/src/types/messages/message-action.ts @@ -1,4 +1,4 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { Photo } from '../media' import { _callDiscardReasonFromTl, diff --git a/packages/client/src/types/messages/message-entity.ts b/packages/client/src/types/messages/message-entity.ts index 70439d79..53fb648d 100644 --- a/packages/client/src/types/messages/message-entity.ts +++ b/packages/client/src/types/messages/message-entity.ts @@ -1,4 +1,4 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { makeInspectable } from '../utils' const entityToType: Partial< diff --git a/packages/client/src/types/messages/message-media.ts b/packages/client/src/types/messages/message-media.ts index c97a0103..2e0f9673 100644 --- a/packages/client/src/types/messages/message-media.ts +++ b/packages/client/src/types/messages/message-media.ts @@ -15,7 +15,7 @@ import { Voice, WebPage, } from '../media' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { parseDocument } from '../media/document-utils' import { Message } from './message' diff --git a/packages/client/src/types/messages/message.ts b/packages/client/src/types/messages/message.ts index 5ab36f51..25b694c3 100644 --- a/packages/client/src/types/messages/message.ts +++ b/packages/client/src/types/messages/message.ts @@ -1,10 +1,10 @@ import { User, Chat, InputPeerLike, UsersIndex, ChatsIndex } from '../peers' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { BotKeyboard, ReplyMarkup } from '../bots' -import { getMarkedPeerId, MAX_CHANNEL_ID } from '@mtqt/core' +import { getMarkedPeerId, MAX_CHANNEL_ID } from '@mtcute/core' import { - MtqtArgumentError, - MtqtTypeAssertionError, + MtArgumentError, + MtTypeAssertionError, } from '../errors' import { TelegramClient } from '../../client' import { MessageEntity } from './message-entity' @@ -117,7 +117,7 @@ export class Message { isScheduled = false ) { if (raw._ === 'messageEmpty') - throw new MtqtTypeAssertionError('Message#ctor', 'not messageEmpty', 'messageEmpty') + throw new MtTypeAssertionError('Message#ctor', 'not messageEmpty', 'messageEmpty') this.client = client this._users = users @@ -218,7 +218,7 @@ export class Message { ) break default: - throw new MtqtTypeAssertionError( + throw new MtTypeAssertionError( 'raw.fromId', 'peerUser | peerChannel', from._ @@ -284,7 +284,7 @@ export class Message { ) break default: - throw new MtqtTypeAssertionError( + throw new MtTypeAssertionError( 'raw.fwdFrom.fromId', 'peerUser | peerChannel', fwd.fromId._ @@ -508,7 +508,7 @@ export class Message { /** * Generated permalink to this message, only for groups and channels * - * @throws MtqtArgumentError In case the chat does not support message links + * @throws MtArgumentError In case the chat does not support message links */ get link(): string { if (this.chat.type === 'supergroup' || this.chat.type === 'channel') { @@ -521,7 +521,7 @@ export class Message { } } - throw new MtqtArgumentError( + throw new MtArgumentError( `Cannot generate message link for ${this.chat.type}` ) } @@ -659,7 +659,7 @@ export class Message { * a simple reply will be sent. * * If this post does not have comments section, - * {@link MtqtArgumentError} is thrown. To check + * {@link MtArgumentError} is thrown. To check * if a message has comments, use {@link replies} * * @param text Text of the message @@ -674,7 +674,7 @@ export class Message { } if (!this.replies || !this.replies.isComments) { - throw new MtqtArgumentError( + throw new MtArgumentError( 'This message does not have comments section' ) } @@ -691,7 +691,7 @@ export class Message { * a simple reply will be sent. * * If this post does not have comments section, - * {@link MtqtArgumentError} is thrown. To check + * {@link MtArgumentError} is thrown. To check * if a message has comments, use {@link replies} * * @param media Media to send @@ -706,7 +706,7 @@ export class Message { } if (!this.replies || !this.replies.isComments) { - throw new MtqtArgumentError( + throw new MtArgumentError( 'This message does not have comments section' ) } @@ -722,7 +722,7 @@ export class Message { * a simple reply will be sent. * * If this post does not have comments section, - * {@link MtqtArgumentError} is thrown. To check + * {@link MtArgumentError} is thrown. To check * if a message has comments, use {@link replies} * * @param medias Medias to send @@ -737,7 +737,7 @@ export class Message { } if (!this.replies || !this.replies.isComments) { - throw new MtqtArgumentError( + throw new MtArgumentError( 'This message does not have comments section' ) } @@ -841,7 +841,7 @@ export class Message { if (!params) params = {} if (this.raw._ === 'messageService') { - throw new MtqtArgumentError("Service messages can't be copied") + throw new MtArgumentError("Service messages can't be copied") } if (this.media && !(this.media instanceof WebPage)) { diff --git a/packages/client/src/types/messages/search-filters.ts b/packages/client/src/types/messages/search-filters.ts index dd6bfd14..f0cd3b03 100644 --- a/packages/client/src/types/messages/search-filters.ts +++ b/packages/client/src/types/messages/search-filters.ts @@ -1,4 +1,4 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' /** * Search filters to be used in {@link TelegramClient.searchMessages} diff --git a/packages/client/src/types/misc/sticker-set.ts b/packages/client/src/types/misc/sticker-set.ts index 4701d9ed..66eab9a1 100644 --- a/packages/client/src/types/misc/sticker-set.ts +++ b/packages/client/src/types/misc/sticker-set.ts @@ -1,8 +1,8 @@ import { TelegramClient } from '../../client' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { makeInspectable } from '../utils' import { Sticker, Thumbnail } from '../media' -import { MtqtEmptyError, MtqtTypeAssertionError } from '../errors' +import { MtEmptyError, MtTypeAssertionError } from '../errors' import { parseDocument } from '../media/document-utils' import { InputFileLike } from '../files' @@ -130,11 +130,11 @@ export class StickerSet { /** * List of stickers inside this stickerset * - * @throws MtqtEmptyError + * @throws MtEmptyError * In case this object does not contain info about stickers (i.e. {@link isFull} = false) */ get stickers(): ReadonlyArray { - if (!this.isFull) throw new MtqtEmptyError() + if (!this.isFull) throw new MtEmptyError() if (!this._stickers) { this._stickers = [] @@ -146,7 +146,7 @@ export class StickerSet { doc as tl.RawDocument ) if (!(sticker instanceof Sticker)) { - throw new MtqtTypeAssertionError( + throw new MtTypeAssertionError( 'full.documents', 'Sticker', sticker.mimeType @@ -209,7 +209,7 @@ export class StickerSet { * Find stickers given their emoji. * * @param emoji Emoji to search for - * @throws MtqtEmptyError + * @throws MtEmptyError * In case this object does not contain info about stickers (i.e. {@link isFull} = false) */ getStickersByEmoji(emoji: string): StickerSet.StickerInfo[] { @@ -244,7 +244,7 @@ export class StickerSet { } private _getInputDocument(idx: number): tl.TypeInputDocument { - if (!this.full) throw new MtqtEmptyError() + if (!this.full) throw new MtEmptyError() if (idx < 0) idx = this.full!.documents.length + idx const doc = this.full!.documents[idx] as tl.RawDocument diff --git a/packages/client/src/types/parser.ts b/packages/client/src/types/parser.ts index cf29f97e..8bc805cf 100644 --- a/packages/client/src/types/parser.ts +++ b/packages/client/src/types/parser.ts @@ -1,10 +1,10 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { MessageEntity } from '../types' /** * Interface describing a message entity parser. - * mtqt comes with HTML parser inside `@mtqt/html-parser` - * and MarkdownV2 parser inside `@mtqt/markdown-parser`, + * MTCute comes with HTML parser inside `@mtcute/html-parser` + * and MarkdownV2 parser inside `@mtcute/markdown-parser`, * implemented similar to how they are described * in the [Bot API documentation](https://core.telegram.org/bots/api#formatting-options). * diff --git a/packages/client/src/types/peers/chat-event.ts b/packages/client/src/types/peers/chat-event.ts index 8d81c461..b077f13e 100644 --- a/packages/client/src/types/peers/chat-event.ts +++ b/packages/client/src/types/peers/chat-event.ts @@ -1,6 +1,6 @@ import { makeInspectable } from '../utils' import { TelegramClient } from '../../client' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { User } from './user' import { ChatMember } from './chat-member' import { Photo } from '../media' diff --git a/packages/client/src/types/peers/chat-invite-link.ts b/packages/client/src/types/peers/chat-invite-link.ts index 1b1a773b..8be19053 100644 --- a/packages/client/src/types/peers/chat-invite-link.ts +++ b/packages/client/src/types/peers/chat-invite-link.ts @@ -1,6 +1,6 @@ import { makeInspectable } from '../utils' import { TelegramClient } from '../../client' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { User } from './user' import { UsersIndex } from './index' diff --git a/packages/client/src/types/peers/chat-location.ts b/packages/client/src/types/peers/chat-location.ts index 92021d30..576c8dac 100644 --- a/packages/client/src/types/peers/chat-location.ts +++ b/packages/client/src/types/peers/chat-location.ts @@ -1,5 +1,5 @@ import { TelegramClient } from '../../client' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { Location } from '../media' import { makeInspectable } from '../utils' diff --git a/packages/client/src/types/peers/chat-member.ts b/packages/client/src/types/peers/chat-member.ts index 1e3865e7..93c08906 100644 --- a/packages/client/src/types/peers/chat-member.ts +++ b/packages/client/src/types/peers/chat-member.ts @@ -1,6 +1,6 @@ import { makeInspectable } from '../utils' import { TelegramClient } from '../../client' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { User } from './user' import { assertTypeIs } from '../../utils/type-assertion' import { ChatPermissions } from './chat-permissions' diff --git a/packages/client/src/types/peers/chat-permissions.ts b/packages/client/src/types/peers/chat-permissions.ts index 3eab84f5..ce04bae0 100644 --- a/packages/client/src/types/peers/chat-permissions.ts +++ b/packages/client/src/types/peers/chat-permissions.ts @@ -1,4 +1,4 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { makeInspectable } from '../utils' /** diff --git a/packages/client/src/types/peers/chat-photo.ts b/packages/client/src/types/peers/chat-photo.ts index 13f8cb5a..29b7b7a8 100644 --- a/packages/client/src/types/peers/chat-photo.ts +++ b/packages/client/src/types/peers/chat-photo.ts @@ -1,12 +1,12 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { FileLocation } from '../files' import { TelegramClient } from '../../client' import { makeInspectable } from '../utils' import { strippedPhotoToJpg } from '../../utils/file-utils' -import { tdFileId, toFileId, toUniqueFileId } from '@mtqt/file-id' +import { tdFileId, toFileId, toUniqueFileId } from '@mtcute/file-id' import bigInt from 'big-integer' -import { MAX_CHANNEL_ID } from '@mtqt/core' -import { MtqtArgumentError } from '../errors' +import { MAX_CHANNEL_ID } from '@mtcute/core' +import { MtArgumentError } from '../errors' /** * A size of a chat photo @@ -65,7 +65,7 @@ export class ChatPhotoSize extends FileLocation { break default: // should not happen - throw new MtqtArgumentError('Input peer was invalid') + throw new MtArgumentError('Input peer was invalid') } this._fileId = toFileId({ diff --git a/packages/client/src/types/peers/chat-preview.ts b/packages/client/src/types/peers/chat-preview.ts index d25341e1..3e14e4f8 100644 --- a/packages/client/src/types/peers/chat-preview.ts +++ b/packages/client/src/types/peers/chat-preview.ts @@ -1,4 +1,4 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { TelegramClient } from '../../client' import { makeInspectable } from '../utils' import { Photo } from '../media' diff --git a/packages/client/src/types/peers/chat.ts b/packages/client/src/types/peers/chat.ts index 73fbebb3..37476c36 100644 --- a/packages/client/src/types/peers/chat.ts +++ b/packages/client/src/types/peers/chat.ts @@ -1,9 +1,9 @@ import { ChatPhoto } from './chat-photo' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { ChatPermissions } from './chat-permissions' import { TelegramClient } from '../../client' -import { getMarkedPeerId, MaybeArray } from '@mtqt/core' -import { MtqtArgumentError, MtqtTypeAssertionError } from '../errors' +import { getMarkedPeerId, MaybeArray } from '@mtcute/core' +import { MtArgumentError, MtTypeAssertionError } from '../errors' import { makeInspectable } from '../utils' import { ChatsIndex, InputPeerLike, User, UsersIndex } from './index' import { ChatLocation } from './chat-location' @@ -56,7 +56,7 @@ export class Chat { peer: tl.TypeUser | tl.TypeChat, fullPeer?: tl.TypeUserFull | tl.TypeChatFull ) { - if (!peer) throw new MtqtArgumentError('peer is not available') + if (!peer) throw new MtArgumentError('peer is not available') switch (peer._) { case 'user': @@ -66,7 +66,7 @@ export class Chat { case 'channelForbidden': break default: - throw new MtqtTypeAssertionError( + throw new MtTypeAssertionError( 'peer', 'user | chat | channel', peer._ @@ -92,7 +92,7 @@ export class Chat { switch (this.peer._) { case 'user': if (!this.peer.accessHash) { - throw new MtqtArgumentError( + throw new MtArgumentError( "Peer's access hash is not available!" ) } @@ -113,7 +113,7 @@ export class Chat { case 'channel': case 'channelForbidden': if (!this.peer.accessHash) { - throw new MtqtArgumentError( + throw new MtArgumentError( "Peer's access hash is not available!" ) } diff --git a/packages/client/src/types/peers/index.ts b/packages/client/src/types/peers/index.ts index c496b771..945c7454 100644 --- a/packages/client/src/types/peers/index.ts +++ b/packages/client/src/types/peers/index.ts @@ -1,4 +1,4 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' export * from './user' export * from './chat' diff --git a/packages/client/src/types/peers/user.ts b/packages/client/src/types/peers/user.ts index 829ba0e9..aedc4dc8 100644 --- a/packages/client/src/types/peers/user.ts +++ b/packages/client/src/types/peers/user.ts @@ -1,7 +1,7 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { TelegramClient } from '../../client' import { ChatPhoto } from './chat-photo' -import { MtqtArgumentError } from '../errors' +import { MtArgumentError } from '../errors' import { makeInspectable } from '../utils' import { assertTypeIs } from '../../utils/type-assertion' import { InputMediaLike } from '../media' @@ -228,7 +228,7 @@ export class User { */ get inputPeer(): tl.TypeInputPeer { if (!this.raw.accessHash) - throw new MtqtArgumentError( + throw new MtArgumentError( "user's access hash is not available!" ) @@ -327,14 +327,14 @@ export class User { * somewhere and load it from there if needed. * * This method is only needed when the result will be - * stored somewhere outside current mtqt instance, + * stored somewhere outside current MTCute instance, * otherwise {@link mention} will be enough. * * > **Note**: the resulting text can only be used by clients - * > that support mtqt notation of permanent + * > that support MTCute notation of permanent * > mention links (`tg://user?id=123&hash=abc`). * > - * > Both `@mtqt/html-parser` and `@mtqt/markdown-parser` support it. + * > Both `@mtcute/html-parser` and `@mtcute/markdown-parser` support it. * > * > Also note that these permanent mentions are only * > valid for current account, since peer access hashes are @@ -345,7 +345,7 @@ export class User { */ permanentMention(text?: string | null, parseMode?: string | null): FormattedString { if (!this.raw.accessHash) - throw new MtqtArgumentError( + throw new MtArgumentError( "user's access hash is not available!" ) diff --git a/packages/client/src/types/updates/bot-stopped.ts b/packages/client/src/types/updates/bot-stopped.ts index ad974a7c..3fc587e3 100644 --- a/packages/client/src/types/updates/bot-stopped.ts +++ b/packages/client/src/types/updates/bot-stopped.ts @@ -1,5 +1,5 @@ import { TelegramClient } from '../../client' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { makeInspectable } from '../utils' import { User, UsersIndex } from '../peers' diff --git a/packages/client/src/types/updates/chat-member-update.ts b/packages/client/src/types/updates/chat-member-update.ts index 216473e5..e7e0d54d 100644 --- a/packages/client/src/types/updates/chat-member-update.ts +++ b/packages/client/src/types/updates/chat-member-update.ts @@ -1,4 +1,4 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { Chat, ChatInviteLink, diff --git a/packages/client/src/types/updates/chosen-inline-result.ts b/packages/client/src/types/updates/chosen-inline-result.ts index d92488d4..3198ee57 100644 --- a/packages/client/src/types/updates/chosen-inline-result.ts +++ b/packages/client/src/types/updates/chosen-inline-result.ts @@ -1,8 +1,8 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { User, Location, - MtqtArgumentError, + MtArgumentError, UsersIndex, } from '../' import { TelegramClient } from '../../client' @@ -103,7 +103,7 @@ export class ChosenInlineResult { params: Parameters[1] ): Promise { if (!this.raw.msgId) - throw new MtqtArgumentError( + throw new MtArgumentError( 'No message ID, make sure you have included reply markup!' ) diff --git a/packages/client/src/types/updates/delete-message-update.ts b/packages/client/src/types/updates/delete-message-update.ts index ec621fc5..7c5346a4 100644 --- a/packages/client/src/types/updates/delete-message-update.ts +++ b/packages/client/src/types/updates/delete-message-update.ts @@ -1,5 +1,5 @@ -import { tl } from '@mtqt/tl' -import { MAX_CHANNEL_ID } from '@mtqt/core' +import { tl } from '@mtcute/tl' +import { MAX_CHANNEL_ID } from '@mtcute/core' import { TelegramClient } from '../../client' import { makeInspectable } from '../utils' diff --git a/packages/client/src/types/updates/history-read-update.ts b/packages/client/src/types/updates/history-read-update.ts index a4f3e767..011a007e 100644 --- a/packages/client/src/types/updates/history-read-update.ts +++ b/packages/client/src/types/updates/history-read-update.ts @@ -1,6 +1,6 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { TelegramClient } from '../../client' -import { getMarkedPeerId, MAX_CHANNEL_ID } from '@mtqt/core' +import { getMarkedPeerId, MAX_CHANNEL_ID } from '@mtcute/core' import { makeInspectable } from '../utils' export class HistoryReadUpdate { diff --git a/packages/client/src/types/updates/poll-update.ts b/packages/client/src/types/updates/poll-update.ts index 73323ee4..344ce00b 100644 --- a/packages/client/src/types/updates/poll-update.ts +++ b/packages/client/src/types/updates/poll-update.ts @@ -1,6 +1,6 @@ import { Poll, UsersIndex } from '../' import { TelegramClient } from '../../client' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { makeInspectable } from '../utils' /** @@ -38,7 +38,7 @@ export class PollUpdate { * The poll. * * Note that sometimes the update does not have the poll - * (Telegram limitation), and mtqt creates a stub poll + * (Telegram limitation), and MTCute creates a stub poll * with empty question, answers and flags * (like `quiz`, `public`, etc.) * @@ -48,7 +48,7 @@ export class PollUpdate { * * Bot API and TDLib do basically the same internally, * and thus are able to always provide them, - * but mtqt tries to keep it simple in terms of local + * but MTCute tries to keep it simple in terms of local * storage and only stores the necessary information. */ get poll(): Poll { diff --git a/packages/client/src/types/updates/poll-vote.ts b/packages/client/src/types/updates/poll-vote.ts index 5d2ee5ed..9cd02c87 100644 --- a/packages/client/src/types/updates/poll-vote.ts +++ b/packages/client/src/types/updates/poll-vote.ts @@ -1,6 +1,6 @@ -import { MtqtUnsupportedError, User, UsersIndex } from '../' +import { MtUnsupportedError, User, UsersIndex } from '../' import { TelegramClient } from '../../client' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { makeInspectable } from '../utils' /** @@ -55,7 +55,7 @@ export class PollVoteUpdate { * * However, most of the major implementations * (tested with TDLib and Bot API, official apps - * for Android, Desktop, iOS/macOS) and mtqt + * for Android, Desktop, iOS/macOS) and MTCute * (by default) create `option` as a one-byte `Buffer`, * incrementing from `48` (ASCII `0`) up to `57` (ASCII `9`), * and ASCII representation would define index in the array. @@ -75,14 +75,14 @@ export class PollVoteUpdate { * described in {@link chosen}. * This might break at any time, but seems to be consistent for now. * - * If something does not add up, {@link MtqtUnsupportedError} is thrown + * If something does not add up, {@link MtUnsupportedError} is thrown */ get chosenIndexesAuto(): ReadonlyArray { return this.raw.options.map((buf) => { if (buf.length > 1) - throw new MtqtUnsupportedError('option had >1 byte') + throw new MtUnsupportedError('option had >1 byte') if (buf[0] < 48 || buf[0] > 57) - throw new MtqtUnsupportedError( + throw new MtUnsupportedError( 'option had first byte out of 0-9 range' ) diff --git a/packages/client/src/types/updates/user-status-update.ts b/packages/client/src/types/updates/user-status-update.ts index de5b7405..9af65a4d 100644 --- a/packages/client/src/types/updates/user-status-update.ts +++ b/packages/client/src/types/updates/user-status-update.ts @@ -1,6 +1,6 @@ import { User } from '../' import { TelegramClient } from '../../client' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { makeInspectable } from '../utils' /** diff --git a/packages/client/src/types/updates/user-typing-update.ts b/packages/client/src/types/updates/user-typing-update.ts index 6dc81980..52c5d260 100644 --- a/packages/client/src/types/updates/user-typing-update.ts +++ b/packages/client/src/types/updates/user-typing-update.ts @@ -1,13 +1,13 @@ import { BasicPeerType, Chat, - MtqtUnsupportedError, + MtUnsupportedError, User, TypingStatus, } from '../' import { TelegramClient } from '../../client' -import { tl } from '@mtqt/tl' -import { getBarePeerId, MAX_CHANNEL_ID } from '@mtqt/core' +import { tl } from '@mtcute/tl' +import { getBarePeerId, MAX_CHANNEL_ID } from '@mtcute/core' import { makeInspectable } from '../utils' /** @@ -102,7 +102,7 @@ export class UserTypingUpdate { return 'history_import' } - throw new MtqtUnsupportedError() + throw new MtUnsupportedError() } /** diff --git a/packages/client/src/types/utils.ts b/packages/client/src/types/utils.ts index f1f614fd..0301b741 100644 --- a/packages/client/src/types/utils.ts +++ b/packages/client/src/types/utils.ts @@ -1,4 +1,4 @@ -import { MaybeAsync } from '@mtqt/core' +import { MaybeAsync } from '@mtcute/core' export type MaybeDynamic = MaybeAsync | (() => MaybeAsync) diff --git a/packages/client/src/utils/file-utils.ts b/packages/client/src/utils/file-utils.ts index 3d03c43c..e161fcd6 100644 --- a/packages/client/src/utils/file-utils.ts +++ b/packages/client/src/utils/file-utils.ts @@ -1,11 +1,11 @@ -import { MtqtArgumentError } from '../types' +import { MtArgumentError } from '../types' export function determinePartSize(fileSize: number): number { if (fileSize <= 104857600) return 128 // 100 MB if (fileSize <= 786432000) return 256 // 750 MB if (fileSize <= 2097152000) return 512 // 2000 MB - throw new MtqtArgumentError('File is too large') + throw new MtArgumentError('File is too large') } /** diff --git a/packages/client/src/utils/inline-utils.ts b/packages/client/src/utils/inline-utils.ts index 795ff164..42bc6200 100644 --- a/packages/client/src/utils/inline-utils.ts +++ b/packages/client/src/utils/inline-utils.ts @@ -1,10 +1,10 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { encodeUrlSafeBase64, parseUrlSafeBase64, BinaryReader, BinaryWriter, -} from '@mtqt/core' +} from '@mtcute/core' export function parseInlineMessageId( id: string diff --git a/packages/client/src/utils/misc-utils.ts b/packages/client/src/utils/misc-utils.ts index 26b7f3db..4b2e2be0 100644 --- a/packages/client/src/utils/misc-utils.ts +++ b/packages/client/src/utils/misc-utils.ts @@ -1,13 +1,13 @@ -import { MaybeDynamic, Message, MtqtError } from '../types' +import { MaybeDynamic, Message, MtClientError } from '../types' import { BigInteger } from 'big-integer' -import { randomBytes, bufferToBigInt } from '@mtqt/core' -import { tl } from '@mtqt/tl' +import { randomBytes, bufferToBigInt } from '@mtcute/core' +import { tl } from '@mtcute/tl' export const EMPTY_BUFFER = Buffer.alloc(0) export function normalizePhoneNumber(phone: string): string { phone = phone.trim().replace(/[+()\s-]/g, '') - if (!phone.match(/^\d+$/)) throw new MtqtError('Invalid phone number') + if (!phone.match(/^\d+$/)) throw new MtClientError('Invalid phone number') return phone } diff --git a/packages/client/src/utils/parse-update.ts b/packages/client/src/utils/parse-update.ts index 56fe909d..09ce0d8c 100644 --- a/packages/client/src/utils/parse-update.ts +++ b/packages/client/src/utils/parse-update.ts @@ -1,5 +1,5 @@ import { TelegramClient } from '../client' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { BotStoppedUpdate, CallbackQuery, diff --git a/packages/client/src/utils/peer-utils.ts b/packages/client/src/utils/peer-utils.ts index a44e2740..56410ce3 100644 --- a/packages/client/src/utils/peer-utils.ts +++ b/packages/client/src/utils/peer-utils.ts @@ -1,4 +1,4 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import bigInt from 'big-integer' import { ChatsIndex, UsersIndex } from '../types' diff --git a/packages/client/src/utils/type-assertion.ts b/packages/client/src/utils/type-assertion.ts index a66e9c5c..ec761747 100644 --- a/packages/client/src/utils/type-assertion.ts +++ b/packages/client/src/utils/type-assertion.ts @@ -1,5 +1,5 @@ -import { MtqtTypeAssertionError } from '../types' -import { tl } from '@mtqt/tl' +import { MtTypeAssertionError } from '../types' +import { tl } from '@mtcute/tl' export function assertTypeIs( context: string, @@ -7,6 +7,6 @@ export function assertTypeIs( expected: K ): asserts obj is tl.FindByName { if (obj._ !== expected) { - throw new MtqtTypeAssertionError(context, expected, obj._) + throw new MtTypeAssertionError(context, expected, obj._) } } diff --git a/packages/client/src/utils/updates-utils.ts b/packages/client/src/utils/updates-utils.ts index 3176c2be..6cd6477f 100644 --- a/packages/client/src/utils/updates-utils.ts +++ b/packages/client/src/utils/updates-utils.ts @@ -1,5 +1,5 @@ -import { tl } from '@mtqt/tl' -import { MtqtTypeAssertionError } from '../types' +import { tl } from '@mtcute/tl' +import { MtTypeAssertionError } from '../types' // dummy updates which are used for methods that return messages.affectedHistory. // that is not an update, but it carries info about pts, and we need to handle it @@ -64,5 +64,5 @@ export function assertIsUpdatesGroup( case 'updatesCombined': return } - throw new MtqtTypeAssertionError(ctx, 'updates | updatesCombined', upd._) + throw new MtTypeAssertionError(ctx, 'updates | updatesCombined', upd._) } diff --git a/packages/client/tsconfig.json b/packages/client/tsconfig.json index 755ef0d0..948bccf8 100644 --- a/packages/client/tsconfig.json +++ b/packages/client/tsconfig.json @@ -7,7 +7,7 @@ "./src" ], "typedocOptions": { - "name": "@mtqt/client", + "name": "@mtcute/client", "includeVersion": true, "out": "../../docs/packages/client", "listInvalidSymbolLinks": true, diff --git a/packages/core/package.json b/packages/core/package.json index 89f07788..78bf83e9 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,5 +1,5 @@ { - "name": "@mtqt/core", + "name": "@mtcute/core", "private": true, "version": "1.0.0", "description": "Core functions and base MTProto client", @@ -19,7 +19,7 @@ "dependencies": { "@types/node": "^15.12.1", "@types/events": "^3.0.0", - "@mtqt/tl": "~1.131.0", + "@mtcute/tl": "~1.131.0", "leemon": "6.2.0", "pako": "2.0.2", "big-integer": "1.6.48", diff --git a/packages/core/scripts/get-user-token-for-e2e.ts b/packages/core/scripts/get-user-token-for-e2e.ts index 3d8e732f..17344287 100644 --- a/packages/core/scripts/get-user-token-for-e2e.ts +++ b/packages/core/scripts/get-user-token-for-e2e.ts @@ -1,7 +1,7 @@ import { BaseTelegramClient, defaultDcs } from '../src' require('dotenv-flow').config({ path: __dirname + '/../' }) -require('debug').enable('mtqt:*') +require('debug').enable('mtcute:*') if (!process.env.API_ID || !process.env.API_HASH) { console.warn('Set API_ID and API_HASH env variables') @@ -45,12 +45,12 @@ const tg = new BaseTelegramClient({ _: 'auth.signUp', phoneNumber: phone, phoneCodeHash: res.phoneCodeHash, - firstName: 'mtqt E2E', + firstName: 'MTCute E2E', lastName: '', }) } - const username = `mtqt_e2e_${numbers}` + const username = `mtcute_e2e_${numbers}` await tg.call({ _: 'account.updateUsername', diff --git a/packages/core/src/base-client.ts b/packages/core/src/base-client.ts index 4be75d32..8f59b24d 100644 --- a/packages/core/src/base-client.ts +++ b/packages/core/src/base-client.ts @@ -1,4 +1,4 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { CryptoProviderFactory, ICryptoProvider, @@ -28,7 +28,7 @@ import { RpcError, SlowmodeWaitError, UserMigrateError, -} from '@mtqt/tl/errors' +} from '@mtcute/tl/errors' import { sleep } from './utils/misc-utils' import { addPublicKey } from './utils/crypto/keys' import { ITelegramStorage, MemoryStorage } from './storage' @@ -39,7 +39,7 @@ import { encodeUrlSafeBase64, parseUrlSafeBase64 } from './utils/buffer-utils' import { BinaryReader } from './utils/binary/binary-reader' import EventEmitter from 'events' -const debug = require('debug')('mtqt:base') +const debug = require('debug')('mtcute:base') export namespace BaseTelegramClient { export interface Options { @@ -149,7 +149,7 @@ export namespace BaseTelegramClient { * If true, RPC errors will have a stack trace of the initial `.call()` * or `.sendForResult()` call position, which drastically improves * debugging experience.
- * If false, they will have a stack trace of mtqt internals. + * If false, they will have a stack trace of MTCute internals. * * Internally this creates a stack capture before every RPC call * and stores it until the result is received. This might @@ -301,7 +301,7 @@ export class BaseTelegramClient extends EventEmitter { this._layer = opts.overrideLayer ?? tl.CURRENT_LAYER - let deviceModel = 'mtqt on ' + let deviceModel = 'MTCute on ' if (typeof process !== 'undefined' && typeof require !== 'undefined') { const os = require('os') deviceModel += `${os.type()} ${os.arch()} ${os.release()}` @@ -538,7 +538,7 @@ export class BaseTelegramClient extends EventEmitter { * `primaryConnection.sendForResult()` (which is what this method wraps) * * This method is still quite low-level and you shouldn't use this - * when using high-level API provided by `@mtqt/client`. + * when using high-level API provided by `@mtcute/client`. * * @param message RPC method to call * @param params Additional call parameters @@ -676,7 +676,7 @@ export class BaseTelegramClient extends EventEmitter { * transport and reconnection strategy as the primary connection * * This method is quite low-level and you shouldn't usually care about this - * when using high-level API provided by `@mtqt/client`. + * when using high-level API provided by `@mtcute/client`. * * @param dcId DC id, to which the connection will be created * @param cdn Whether that DC is a CDN DC @@ -868,7 +868,7 @@ export class BaseTelegramClient extends EventEmitter { * > In case you have accidentally leaked this string, * > make sure to revoke this session in account settings: * > "Privacy & Security" > "Active sessions" > - * > find the one containing `mtqt` > Revoke, + * > find the one containing `MTCute` > Revoke, * > or, in case this is a bot, revoke bot token * > with [@BotFather](//t.me/botfather) */ diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 54f860aa..eb17eb59 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -3,8 +3,8 @@ export * from './network' export * from './storage' export * from './types' -export * from '@mtqt/tl' -export * from '@mtqt/tl/errors' +export * from '@mtcute/tl' +export * from '@mtcute/tl/errors' export * from './utils/crypto' export * from './utils/peer-utils' diff --git a/packages/core/src/network/authorization.ts b/packages/core/src/network/authorization.ts index cb31b17c..96dc75f6 100644 --- a/packages/core/src/network/authorization.ts +++ b/packages/core/src/network/authorization.ts @@ -1,6 +1,6 @@ import { TelegramConnection } from './telegram-connection' import { buffersEqual, randomBytes, xorBuffer } from '../utils/buffer-utils' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { BinaryReader } from '../utils/binary/binary-reader' import { BinaryWriter, @@ -16,7 +16,7 @@ import { bufferToBigInt, } from '../utils/bigint-utils' -const debug = require('debug')('mtqt:auth') +const debug = require('debug')('mtcute:auth') // Heavily based on code from https://github.com/LonamiWebs/Telethon/blob/master/telethon/network/authenticator.py diff --git a/packages/core/src/network/mtproto-session.ts b/packages/core/src/network/mtproto-session.ts index 4ea54d0c..3878db23 100644 --- a/packages/core/src/network/mtproto-session.ts +++ b/packages/core/src/network/mtproto-session.ts @@ -1,7 +1,7 @@ import { BigInteger } from 'big-integer' import { buffersEqual, randomBytes } from '../utils/buffer-utils' import { ICryptoProvider } from '../utils/crypto' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { createAesIgeForMessage } from '../utils/crypto/mtproto' import { BinaryWriter, @@ -9,7 +9,7 @@ import { } from '../utils/binary/binary-writer' import { BinaryReader } from '../utils/binary/binary-reader' -const debug = require('debug')('mtqt:sess') +const debug = require('debug')('mtcute:sess') export interface EncryptedMessage { messageId: BigInteger diff --git a/packages/core/src/network/persistent-connection.ts b/packages/core/src/network/persistent-connection.ts index 75fbb30a..a5849fc7 100644 --- a/packages/core/src/network/persistent-connection.ts +++ b/packages/core/src/network/persistent-connection.ts @@ -1,6 +1,6 @@ import EventEmitter from 'events' import { ITelegramTransport, TransportFactory, TransportState } from './transports' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { ReconnectionStrategy } from './reconnection' import { ControllablePromise, @@ -8,7 +8,7 @@ import { } from '../utils/controllable-promise' import { ICryptoProvider } from '../utils/crypto' -const debug = require('debug')('mtqt:conn') +const debug = require('debug')('mtcute:conn') export interface PersistentConnectionParams { crypto: ICryptoProvider diff --git a/packages/core/src/network/telegram-connection.ts b/packages/core/src/network/telegram-connection.ts index 0c3da2a1..e2677f1c 100644 --- a/packages/core/src/network/telegram-connection.ts +++ b/packages/core/src/network/telegram-connection.ts @@ -3,7 +3,7 @@ import { PersistentConnectionParams, } from './persistent-connection' import { TransportError } from './transports' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { doAuthorization } from './authorization' import { MtprotoSession } from './mtproto-session' import { BinaryWriter } from '../utils/binary/binary-writer' @@ -21,7 +21,7 @@ import { createRpcErrorFromTl, RpcError, RpcTimeoutError, -} from '@mtqt/tl/errors' +} from '@mtcute/tl/errors' import { LruStringSet } from '../utils/lru-string-set' function makeNiceStack(error: RpcError, stack: string, method?: string) { @@ -31,7 +31,7 @@ function makeNiceStack(error: RpcError, stack: string, method?: string) { } const _debug = require('debug') -const debug = _debug('mtqt:conn') +const debug = _debug('mtcute:conn') // hex formatting buffers with %h _debug.formatters.h = (v: Buffer): string => v.toString('hex') diff --git a/packages/core/src/network/transports/abstract.ts b/packages/core/src/network/transports/abstract.ts index 54b54d68..798dd1ad 100644 --- a/packages/core/src/network/transports/abstract.ts +++ b/packages/core/src/network/transports/abstract.ts @@ -1,4 +1,4 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { MaybeAsync } from '../../types/utils' import { ICryptoProvider } from '../../utils/crypto' import EventEmitter from 'events' diff --git a/packages/core/src/network/transports/tcp.ts b/packages/core/src/network/transports/tcp.ts index d43e1d7e..a5169804 100644 --- a/packages/core/src/network/transports/tcp.ts +++ b/packages/core/src/network/transports/tcp.ts @@ -1,11 +1,11 @@ import { ITelegramTransport, IPacketCodec, TransportState } from './abstract' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { Socket, connect } from 'net' import EventEmitter from 'events' import { ICryptoProvider } from '../../utils/crypto' import { IntermediatePacketCodec } from './intermediate' -const debug = require('debug')('mtqt:tcp') +const debug = require('debug')('mtcute:tcp') /** * Base for TCP transports. diff --git a/packages/core/src/network/transports/websocket.ts b/packages/core/src/network/transports/websocket.ts index efc1ed6f..8785ebba 100644 --- a/packages/core/src/network/transports/websocket.ts +++ b/packages/core/src/network/transports/websocket.ts @@ -1,5 +1,5 @@ import { ITelegramTransport, IPacketCodec, TransportState } from './abstract' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import EventEmitter from 'events' import { typedArrayToBuffer } from '../../utils/buffer-utils' import { ICryptoProvider } from '../../utils/crypto' @@ -7,7 +7,7 @@ import type WebSocket from 'ws' import { IntermediatePacketCodec } from './intermediate' import { ObfuscatedPacketCodec } from './obfuscated' -const debug = require('debug')('mtqt:ws') +const debug = require('debug')('mtcute:ws') let ws: { new (address: string, options?: string): WebSocket diff --git a/packages/core/src/storage/abstract.ts b/packages/core/src/storage/abstract.ts index 8de6b0ff..3150deaf 100644 --- a/packages/core/src/storage/abstract.ts +++ b/packages/core/src/storage/abstract.ts @@ -1,5 +1,5 @@ import { BasicPeerType, MaybeAsync } from '../types' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' export namespace ITelegramStorage { export interface PeerInfo { diff --git a/packages/core/src/storage/memory.ts b/packages/core/src/storage/memory.ts index 0521c18c..70c74438 100644 --- a/packages/core/src/storage/memory.ts +++ b/packages/core/src/storage/memory.ts @@ -1,6 +1,6 @@ import { ITelegramStorage } from './abstract' import { MaybeAsync } from '../types' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { MAX_CHANNEL_ID } from '../utils/peer-utils' import { LruMap } from '../utils/lru-map' diff --git a/packages/core/src/utils/binary/binary-reader.ts b/packages/core/src/utils/binary/binary-reader.ts index b135fcfa..a106e21f 100644 --- a/packages/core/src/utils/binary/binary-reader.ts +++ b/packages/core/src/utils/binary/binary-reader.ts @@ -1,9 +1,9 @@ import bigInt, { BigInteger } from 'big-integer' import { inflate } from 'pako' import { typedArrayToBuffer } from '../buffer-utils' -import readerMap, { ITlBinaryReader } from '@mtqt/tl/binary/reader' +import readerMap, { ITlBinaryReader } from '@mtcute/tl/binary/reader' import { bufferToBigInt, longToUlong, ulongToLong } from '../bigint-utils' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' const isNativeBigIntAvailable = typeof BigInt !== 'undefined' && 'readBigInt64LE' in Buffer.prototype diff --git a/packages/core/src/utils/binary/binary-writer.ts b/packages/core/src/utils/binary/binary-writer.ts index 08e9be73..d6b9881a 100644 --- a/packages/core/src/utils/binary/binary-writer.ts +++ b/packages/core/src/utils/binary/binary-writer.ts @@ -4,7 +4,7 @@ import writerMap, { ITlBinaryWriter, TlBinaryWriterFunction, TlWriterMap, -} from '@mtqt/tl/binary/writer' +} from '@mtcute/tl/binary/writer' type SerializableObject = { _: string diff --git a/packages/core/src/utils/crypto/abstract.ts b/packages/core/src/utils/crypto/abstract.ts index 06d4b2dc..f53788c4 100644 --- a/packages/core/src/utils/crypto/abstract.ts +++ b/packages/core/src/utils/crypto/abstract.ts @@ -1,5 +1,5 @@ import { MaybeAsync } from '../../types' -import { TlPublicKey } from '@mtqt/tl/binary/rsa-keys' +import { TlPublicKey } from '@mtcute/tl/binary/rsa-keys' import { AesModeOfOperationIge } from './common' import { bigIntToBuffer, bufferToBigInt } from '../bigint-utils' import bigInt from 'big-integer' diff --git a/packages/core/src/utils/crypto/keys.ts b/packages/core/src/utils/crypto/keys.ts index b1d7fb63..c7ed8a0e 100644 --- a/packages/core/src/utils/crypto/keys.ts +++ b/packages/core/src/utils/crypto/keys.ts @@ -3,7 +3,7 @@ import { BigInteger } from 'big-integer' import { parseAsn1, parsePemContents } from '../binary/asn1-parser' import { BinaryWriter } from '../binary/binary-writer' import { ICryptoProvider } from './abstract' -import keysIndex, { TlPublicKey } from '@mtqt/tl/binary/rsa-keys' +import keysIndex, { TlPublicKey } from '@mtcute/tl/binary/rsa-keys' export async function parsePublicKey( crypto: ICryptoProvider, diff --git a/packages/core/src/utils/crypto/password.ts b/packages/core/src/utils/crypto/password.ts index e2e69fab..79b4ca36 100644 --- a/packages/core/src/utils/crypto/password.ts +++ b/packages/core/src/utils/crypto/password.ts @@ -1,4 +1,4 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { ICryptoProvider } from './abstract' import { bigIntToBuffer, bufferToBigInt } from '../bigint-utils' import bigInt from 'big-integer' diff --git a/packages/core/src/utils/default-dcs.ts b/packages/core/src/utils/default-dcs.ts index 9c4cea3c..ed7e891b 100644 --- a/packages/core/src/utils/default-dcs.ts +++ b/packages/core/src/utils/default-dcs.ts @@ -1,4 +1,4 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' export const defaultProductionDc: tl.RawDcOption = { _: 'dcOption', diff --git a/packages/core/src/utils/peer-utils.ts b/packages/core/src/utils/peer-utils.ts index 977cb89a..b1977ad7 100644 --- a/packages/core/src/utils/peer-utils.ts +++ b/packages/core/src/utils/peer-utils.ts @@ -1,4 +1,4 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { BasicPeerType } from '../types' export const MIN_CHANNEL_ID = -1002147483647 diff --git a/packages/core/src/utils/tl-json.ts b/packages/core/src/utils/tl-json.ts index 3847c8d4..127fb470 100644 --- a/packages/core/src/utils/tl-json.ts +++ b/packages/core/src/utils/tl-json.ts @@ -1,4 +1,4 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' /** * Convert a JS object to TL JSON diff --git a/packages/core/tests/binary-writer.spec.ts b/packages/core/tests/binary-writer.spec.ts index e942cd10..d667e82d 100644 --- a/packages/core/tests/binary-writer.spec.ts +++ b/packages/core/tests/binary-writer.spec.ts @@ -6,8 +6,8 @@ import { } from '../src/utils/binary/binary-writer' import bigInt from 'big-integer' import { randomBytes } from '../src/utils/buffer-utils' -import { tl } from '@mtqt/tl' -import { ITlBinaryWriter } from '@mtqt/tl/binary/writer' +import { tl } from '@mtcute/tl' +import { ITlBinaryWriter } from '@mtcute/tl/binary/writer' describe('BinaryWriter', () => { const testSingleMethod = ( diff --git a/packages/core/tests/e2e/_setup-accounts.spec.ts b/packages/core/tests/e2e/_setup-accounts.spec.ts index 78cf0179..faeda9f2 100644 --- a/packages/core/tests/e2e/_setup-accounts.spec.ts +++ b/packages/core/tests/e2e/_setup-accounts.spec.ts @@ -36,12 +36,12 @@ async function getTestAccount(dcId = 2) { _: 'auth.signUp', phoneNumber: phone, phoneCodeHash: res.phoneCodeHash, - firstName: 'mtqt E2E', + firstName: 'MTCute E2E', lastName: '', }) } - const username = `mtqt_e2e_${numbers}` + const username = `mtcute_e2e_${numbers}` await tg.call({ _: 'account.updateUsername', diff --git a/packages/core/tests/e2e/utils.ts b/packages/core/tests/e2e/utils.ts index 399365b1..f4697c69 100644 --- a/packages/core/tests/e2e/utils.ts +++ b/packages/core/tests/e2e/utils.ts @@ -1,6 +1,6 @@ import { BaseTelegramClient, NodeCryptoProvider, TcpTransport } from '../../src' -// require('debug').enable('mtqt:*') +// require('debug').enable('mtcute:*') export function createTestTelegramClient() { return new BaseTelegramClient({ diff --git a/packages/core/tests/fuzz/fuzz-session.spec.ts b/packages/core/tests/fuzz/fuzz-session.spec.ts index df5384a1..d185bd17 100644 --- a/packages/core/tests/fuzz/fuzz-session.spec.ts +++ b/packages/core/tests/fuzz/fuzz-session.spec.ts @@ -2,7 +2,7 @@ import { describe, it } from 'mocha' import { expect } from 'chai' import { randomBytes } from '../../src' import { sleep } from '../../src/utils/misc-utils' -import { UserMigrateError } from '@mtqt/tl/errors' +import { UserMigrateError } from '@mtcute/tl/errors' import { createTestTelegramClient } from '../e2e/utils' require('dotenv-flow').config() diff --git a/packages/core/tsconfig.json b/packages/core/tsconfig.json index 717dd5d9..ccea383b 100644 --- a/packages/core/tsconfig.json +++ b/packages/core/tsconfig.json @@ -7,7 +7,7 @@ "./src" ], "typedocOptions": { - "name": "@mtqt/core", + "name": "@mtcute/core", "includeVersion": true, "out": "../../docs/packages/core", "listInvalidSymbolLinks": true, diff --git a/packages/crypto-node/README.md b/packages/crypto-node/README.md index 1914c76a..09acb229 100644 --- a/packages/crypto-node/README.md +++ b/packages/crypto-node/README.md @@ -1,4 +1,4 @@ -# `@mtqt/crypto-node` +# `@mtcute/crypto-node` Native extension for NodeJS that improves performance of the most used cryptographic mode in Telegram (IGE), which is not implemented by OpenSSL. @@ -14,8 +14,8 @@ Then, install the package as usual. The native library will be built automatical ## Usage ```typescript -import { TelegramClient } from '@mtqt/client' -import { NodeNativeCryptoProvider } from '@mtqt/crypto-node' +import { TelegramClient } from '@mtcute/client' +import { NodeNativeCryptoProvider } from '@mtcute/crypto-node' const tg = new TelegramClient({ ..., diff --git a/packages/crypto-node/package.json b/packages/crypto-node/package.json index c5e484da..3d96df61 100644 --- a/packages/crypto-node/package.json +++ b/packages/crypto-node/package.json @@ -1,5 +1,5 @@ { - "name": "@mtqt/crypto-node", + "name": "@mtcute/crypto-node", "version": "1.0.0", "description": "Native crypto implementation for NodeJS", "main": "src/index.ts", @@ -17,6 +17,6 @@ "docs": "npx typedoc" }, "dependencies": { - "@mtqt/core": "^1.0.0" + "@mtcute/core": "^1.0.0" } } diff --git a/packages/crypto-node/src/index.ts b/packages/crypto-node/src/index.ts index 97316c90..dbb5f0a2 100644 --- a/packages/crypto-node/src/index.ts +++ b/packages/crypto-node/src/index.ts @@ -1,4 +1,4 @@ -import { NodeCryptoProvider, IEncryptionScheme } from '@mtqt/core' +import { NodeCryptoProvider, IEncryptionScheme } from '@mtcute/core' import { ige256_decrypt, ige256_encrypt } from './native' /** diff --git a/packages/crypto-node/tsconfig.json b/packages/crypto-node/tsconfig.json index caaa32df..bdc90847 100644 --- a/packages/crypto-node/tsconfig.json +++ b/packages/crypto-node/tsconfig.json @@ -7,7 +7,7 @@ "./src" ], "typedocOptions": { - "name": "@mtqt/crypto-node", + "name": "@mtcute/crypto-node", "includeVersion": true, "out": "../../docs/packages/crypto-node", "listInvalidSymbolLinks": true, diff --git a/packages/crypto/package.json b/packages/crypto/package.json index 93dc000e..f9ebb5d2 100644 --- a/packages/crypto/package.json +++ b/packages/crypto/package.json @@ -1,5 +1,5 @@ { - "name": "@mtqt/crypto", + "name": "@mtcute/crypto", "private": true, "version": "1.0.0" } diff --git a/packages/dispatcher/package.json b/packages/dispatcher/package.json index 4c39e676..c04e0503 100644 --- a/packages/dispatcher/package.json +++ b/packages/dispatcher/package.json @@ -1,8 +1,8 @@ { - "name": "@mtqt/dispatcher", + "name": "@mtcute/dispatcher", "private": true, "version": "1.0.0", - "description": "Updates dispatcher and bot framework for @mtqt/client", + "description": "Updates dispatcher and bot framework for @mtcute/client", "author": "Alisa Sireneva ", "license": "LGPL-3.0", "main": "src/index.ts", @@ -12,9 +12,9 @@ "build": "tsc" }, "dependencies": { - "@mtqt/tl": "~1.131.0", - "@mtqt/core": "^1.0.0", - "@mtqt/client": "^1.0.0", + "@mtcute/tl": "~1.131.0", + "@mtcute/core": "^1.0.0", + "@mtcute/client": "^1.0.0", "events": "^3.2.0", "debug": "^4.3.1" } diff --git a/packages/dispatcher/src/callback-data-builder.ts b/packages/dispatcher/src/callback-data-builder.ts index d0fcefc5..e92e68cd 100644 --- a/packages/dispatcher/src/callback-data-builder.ts +++ b/packages/dispatcher/src/callback-data-builder.ts @@ -1,5 +1,5 @@ -import { MaybeArray } from '@mtqt/core' -import { CallbackQuery, MtqtArgumentError } from '@mtqt/client' +import { MaybeArray } from '@mtcute/core' +import { CallbackQuery, MtArgumentError } from '@mtcute/client' import { UpdateFilter } from './filters' /** @@ -36,7 +36,7 @@ export class CallbackDataBuilder { const val = obj[f] if (val.indexOf(this.sep) > -1) - throw new MtqtArgumentError( + throw new MtArgumentError( `Value for ${f} ${val} contains separator ${this.sep} and cannot be used.` ) @@ -45,7 +45,7 @@ export class CallbackDataBuilder { .join(this.sep) if (ret.length > 64) { - throw new MtqtArgumentError( + throw new MtArgumentError( 'Resulting callback data is too long.' ) } @@ -62,11 +62,11 @@ export class CallbackDataBuilder { const parts = data.split(this.sep) if (parts[0] !== this.prefix) { - throw new MtqtArgumentError('Invalid data passed') + throw new MtArgumentError('Invalid data passed') } if (parts.length !== this._fields.length + 1) { - throw new MtqtArgumentError('Invalid data passed') + throw new MtArgumentError('Invalid data passed') } const ret = {} as Record diff --git a/packages/dispatcher/src/dispatcher.ts b/packages/dispatcher/src/dispatcher.ts index fa31e421..b333366c 100644 --- a/packages/dispatcher/src/dispatcher.ts +++ b/packages/dispatcher/src/dispatcher.ts @@ -5,7 +5,7 @@ import { InlineQuery, MaybeAsync, Message, - MtqtArgumentError, + MtArgumentError, TelegramClient, UsersIndex, ChatMemberUpdate, @@ -18,8 +18,8 @@ import { HistoryReadUpdate, ParsedUpdate, BotStoppedUpdate -} from '@mtqt/client' -import { tl } from '@mtqt/tl' +} from '@mtcute/client' +import { tl } from '@mtcute/tl' // begin-codegen-imports import { UpdateHandler, @@ -428,14 +428,14 @@ export class Dispatcher { break outer case 'scene': { if (!parsedState) - throw new MtqtArgumentError( + throw new MtArgumentError( 'Cannot use ToScene without state' ) const scene = parsedState['_scene'] if (!scene) - throw new MtqtArgumentError( + throw new MtArgumentError( 'Cannot use ToScene without entering a scene' ) @@ -626,7 +626,7 @@ export class Dispatcher { state?: UpdateState ): MaybeAsync { if (!this.parent) - throw new MtqtArgumentError('This dispatcher is not a child') + throw new MtArgumentError('This dispatcher is not a child') if (this.parent._errorHandler) { return this.parent._errorHandler(err, update, state) @@ -647,7 +647,7 @@ export class Dispatcher { private _prepareChild(child: Dispatcher): void { if (child._client) { - throw new MtqtArgumentError( + throw new MtArgumentError( 'Provided dispatcher is ' + (child._parent ? 'already a child. Use parent.removeChild() before calling addChild()' @@ -726,17 +726,17 @@ export class Dispatcher { ): void { if (!this._scenes) this._scenes = {} if (uid in this._scenes) { - throw new MtqtArgumentError( + throw new MtArgumentError( `Scene with UID ${uid} is already registered!` ) } if (uid[0] === '$') { - throw new MtqtArgumentError(`Scene UID cannot start with $`) + throw new MtArgumentError(`Scene UID cannot start with $`) } if (scene._scene) { - throw new MtqtArgumentError( + throw new MtArgumentError( `This dispatcher is already registered as scene ${scene._scene}` ) } @@ -786,7 +786,7 @@ export class Dispatcher { */ extend(other: Dispatcher): void { if (other._customStorage || other._customStateKeyDelegate) { - throw new MtqtArgumentError( + throw new MtArgumentError( 'Provided dispatcher has custom storage and cannot be extended from.' ) } @@ -916,7 +916,7 @@ export class Dispatcher { object: string | Parameters[0] ): MaybeAsync> { if (!this._storage) - throw new MtqtArgumentError( + throw new MtArgumentError( 'Cannot use getUpdateState() filter without state storage' ) @@ -932,7 +932,7 @@ export class Dispatcher { return Promise.resolve(this._stateKeyDelegate!(object)).then((key) => { if (!key) { - throw new MtqtArgumentError( + throw new MtArgumentError( 'Cannot derive key from given object' ) } @@ -950,7 +950,7 @@ export class Dispatcher { return Promise.resolve(this._customStateKeyDelegate(object)).then( (customKey) => { if (!customKey) { - throw new MtqtArgumentError( + throw new MtArgumentError( 'Cannot derive custom key from given object' ) } @@ -978,14 +978,14 @@ export class Dispatcher { object: Parameters[0] ): Promise> { if (!this._parent) { - throw new MtqtArgumentError( + throw new MtArgumentError( 'This dispatcher does not have a parent' ) } return Promise.resolve(this._stateKeyDelegate!(object)).then((key) => { if (!key) { - throw new MtqtArgumentError( + throw new MtArgumentError( 'Cannot derive key from given object' ) } diff --git a/packages/dispatcher/src/filters.ts b/packages/dispatcher/src/filters.ts index 028c927c..7b4b86c6 100644 --- a/packages/dispatcher/src/filters.ts +++ b/packages/dispatcher/src/filters.ts @@ -28,8 +28,8 @@ import { UserStatusUpdate, PollVoteUpdate, UserTypingUpdate, -} from '@mtqt/client' -import { MaybeArray } from '@mtqt/core' +} from '@mtcute/client' +import { MaybeArray } from '@mtcute/core' import { UpdateState } from './state' function extractText( diff --git a/packages/dispatcher/src/handler.ts b/packages/dispatcher/src/handler.ts index 4b9f8241..60d79f65 100644 --- a/packages/dispatcher/src/handler.ts +++ b/packages/dispatcher/src/handler.ts @@ -15,8 +15,8 @@ import { PollUpdate, UserTypingUpdate, BotStoppedUpdate -} from '@mtqt/client' -import { tl } from '@mtqt/tl' +} from '@mtcute/client' +import { tl } from '@mtcute/tl' import { PropagationAction } from './propagation' interface BaseUpdateHandler { diff --git a/packages/dispatcher/src/state/key.ts b/packages/dispatcher/src/state/key.ts index 18412af6..8f561211 100644 --- a/packages/dispatcher/src/state/key.ts +++ b/packages/dispatcher/src/state/key.ts @@ -1,5 +1,5 @@ -import { CallbackQuery, Message } from '@mtqt/client' -import { MaybeAsync } from '@mtqt/core' +import { CallbackQuery, Message } from '@mtcute/client' +import { MaybeAsync } from '@mtcute/core' /** * Function that determines how the state key is derived. diff --git a/packages/dispatcher/src/state/storage.ts b/packages/dispatcher/src/state/storage.ts index 07c126ef..180fc74d 100644 --- a/packages/dispatcher/src/state/storage.ts +++ b/packages/dispatcher/src/state/storage.ts @@ -1,4 +1,4 @@ -import { MaybeAsync } from '@mtqt/core' +import { MaybeAsync } from '@mtcute/core' /** * Interface for FSM storage for the dispatcher. diff --git a/packages/dispatcher/src/state/update-state.ts b/packages/dispatcher/src/state/update-state.ts index 36d3561c..499a599b 100644 --- a/packages/dispatcher/src/state/update-state.ts +++ b/packages/dispatcher/src/state/update-state.ts @@ -1,11 +1,11 @@ import { IStateStorage } from './storage' -import { MtqtArgumentError, MtqtError } from '@mtqt/client' -import { sleep } from '@mtqt/core/src/utils/misc-utils' +import { MtArgumentError, MtClientError } from '@mtcute/client' +import { sleep } from '@mtcute/core/src/utils/misc-utils' /** * Error thrown by `.rateLimit()` */ -export class RateLimitError extends MtqtError { +export class RateLimitError extends MtClientError { constructor (readonly reset: number) { super(`You are being rate limited.`) } @@ -134,7 +134,7 @@ export class UpdateState { const old = await this.get(forceLoad) if (!old) { if (!fallback) - throw new MtqtArgumentError('Cannot use merge on empty state without fallback.') + throw new MtArgumentError('Cannot use merge on empty state without fallback.') await this.set({ ...fallback, ...state }, ttl) } else { diff --git a/packages/dispatcher/src/wizard.ts b/packages/dispatcher/src/wizard.ts index 67d2b351..587ab2da 100644 --- a/packages/dispatcher/src/wizard.ts +++ b/packages/dispatcher/src/wizard.ts @@ -1,4 +1,4 @@ -import { MaybeAsync, Message } from '@mtqt/client' +import { MaybeAsync, Message } from '@mtcute/client' import { Dispatcher } from './dispatcher' import { NewMessageHandler } from './handler' import { UpdateState } from './state' diff --git a/packages/dispatcher/tests/dispatcher.spec.ts b/packages/dispatcher/tests/dispatcher.spec.ts index 8d8a6037..6f0b7bfe 100644 --- a/packages/dispatcher/tests/dispatcher.spec.ts +++ b/packages/dispatcher/tests/dispatcher.spec.ts @@ -1,7 +1,7 @@ import { describe, it } from 'mocha' import { expect } from 'chai' import { Dispatcher, handlers, PropagationAction } from '../src' -import { TelegramClient } from '@mtqt/client' +import { TelegramClient } from '@mtcute/client' describe('Dispatcher', () => { // todo: replace with proper mocked TelegramClient diff --git a/packages/dispatcher/tsconfig.json b/packages/dispatcher/tsconfig.json index 33da2057..1b6d35fc 100644 --- a/packages/dispatcher/tsconfig.json +++ b/packages/dispatcher/tsconfig.json @@ -7,7 +7,7 @@ "./src" ], "typedocOptions": { - "name": "@mtqt/dispatcher", + "name": "@mtcute/dispatcher", "includeVersion": true, "out": "../../docs/packages/dispatcher", "listInvalidSymbolLinks": true, diff --git a/packages/file-id/README.md b/packages/file-id/README.md index ff85d509..12054fcb 100644 --- a/packages/file-id/README.md +++ b/packages/file-id/README.md @@ -1,6 +1,6 @@ -# `@mtqt/file-id` +# `@mtcute/file-id` -A package that is used internally by `@mtqt/client` to parse, serialize +A package that is used internally by `@mtcute/client` to parse, serialize and manipulate TDLib and Bot API compatible File IDs, but can also be used for any other purposes. @@ -16,17 +16,17 @@ This package also exports namespace `tdFileId`, which contains all the types used by the library ## Dependencies -This package uses `@mtqt/core` `BinaryReader` and `BinaryWriter` classes to -work with binary streams. Additionally, it depends on `@mtqt/tl` types to +This package uses `@mtcute/core` `BinaryReader` and `BinaryWriter` classes to +work with binary streams. Additionally, it depends on `@mtcute/tl` types to allow type-safe code for conversion functions. -Note that `@mtqt/core` itself depends on `@mtqt/tl`, which might +Note that `@mtcute/core` itself depends on `@mtcute/tl`, which might redundantly increase your bundle size in case you don't actually use TL types. ## Acknowledgements This is basically a port of a portion of TDLib APIs, but greatly simplified in usage and made to work seamlessly with the rest of the -mtqt APIs. +MTCute APIs. This is a list of files from TDLib repository, from which most of the code was taken: - [td/telegram/files/FileManager.cpp](https://github.com/tdlib/td/blob/master/td/telegram/files/FileManager.cpp) diff --git a/packages/file-id/package.json b/packages/file-id/package.json index f2f50747..f819778d 100644 --- a/packages/file-id/package.json +++ b/packages/file-id/package.json @@ -1,8 +1,8 @@ { - "name": "@mtqt/file-id", + "name": "@mtcute/file-id", "private": true, "version": "1.0.0", - "description": "Support for TDLib and Bot API file ID for mtqt", + "description": "Support for TDLib and Bot API file ID for MTCute", "author": "Alisa Sireneva ", "license": "LGPL-3.0", "main": "src/index.ts", @@ -12,8 +12,8 @@ "build": "tsc" }, "dependencies": { - "@mtqt/tl": "~1.131.0", - "@mtqt/core": "^1.0.0", + "@mtcute/tl": "~1.131.0", + "@mtcute/core": "^1.0.0", "big-integer": "1.6.48" } } diff --git a/packages/file-id/src/convert.ts b/packages/file-id/src/convert.ts index 9c5bbab2..85176cff 100644 --- a/packages/file-id/src/convert.ts +++ b/packages/file-id/src/convert.ts @@ -1,7 +1,7 @@ -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { tdFileId, tdFileId as td } from './types' import { parseFileId } from './parse' -import { getBasicPeerType, markedPeerIdToBare } from '@mtqt/core' +import { getBasicPeerType, markedPeerIdToBare } from '@mtcute/core' import FileType = tdFileId.FileType import bigInt from 'big-integer' diff --git a/packages/file-id/src/parse.ts b/packages/file-id/src/parse.ts index 831aadfc..d9c0193e 100644 --- a/packages/file-id/src/parse.ts +++ b/packages/file-id/src/parse.ts @@ -1,6 +1,6 @@ import { telegramRleDecode } from './utils' import { tdFileId as td } from './types' -import { BinaryReader, parseUrlSafeBase64 } from '@mtqt/core' +import { BinaryReader, parseUrlSafeBase64 } from '@mtcute/core' function parseWebFileLocation( reader: BinaryReader diff --git a/packages/file-id/src/serialize-unique.ts b/packages/file-id/src/serialize-unique.ts index f21181ef..4b316d13 100644 --- a/packages/file-id/src/serialize-unique.ts +++ b/packages/file-id/src/serialize-unique.ts @@ -1,5 +1,5 @@ import { tdFileId, tdFileId as td } from './types' -import { encodeUrlSafeBase64, BinaryWriter } from '@mtqt/core' +import { encodeUrlSafeBase64, BinaryWriter } from '@mtcute/core' import { telegramRleEncode } from './utils' import FileType = tdFileId.FileType diff --git a/packages/file-id/src/serialize.ts b/packages/file-id/src/serialize.ts index 069bd0e0..1c29fd81 100644 --- a/packages/file-id/src/serialize.ts +++ b/packages/file-id/src/serialize.ts @@ -1,5 +1,5 @@ import { tdFileId as td } from './types' -import { encodeUrlSafeBase64, BinaryWriter } from '@mtqt/core' +import { encodeUrlSafeBase64, BinaryWriter } from '@mtcute/core' import { telegramRleEncode } from './utils' const SUFFIX = Buffer.from([td.CURRENT_VERSION, td.PERSISTENT_ID_VERSION]) diff --git a/packages/file-id/src/types.ts b/packages/file-id/src/types.ts index cfac31fc..e7dca4f7 100644 --- a/packages/file-id/src/types.ts +++ b/packages/file-id/src/types.ts @@ -63,7 +63,7 @@ export namespace tdFileId { None, } - // naming convention just like in @mtqt/tl + // naming convention just like in @mtcute/tl // additionally, `_` discriminator is used, // so we can interoperate with normal TL objects @@ -209,7 +209,7 @@ export namespace tdFileId { * * This type is supposed to be an intermediate step * between TL objects and string file IDs, - * and if you are using `@mtqt/client`, you don't + * and if you are using `@mtcute/client`, you don't * really need to care about this type at all. */ export interface RawFullRemoteFileLocation { diff --git a/packages/file-id/tsconfig.json b/packages/file-id/tsconfig.json index 4535343c..65628325 100644 --- a/packages/file-id/tsconfig.json +++ b/packages/file-id/tsconfig.json @@ -7,7 +7,7 @@ "./src" ], "typedocOptions": { - "name": "@mtqt/file-id", + "name": "@mtcute/file-id", "includeVersion": true, "out": "../../docs/packages/file-id", "listInvalidSymbolLinks": true, diff --git a/packages/html-parser/README.md b/packages/html-parser/README.md index 9b1a450c..85571048 100644 --- a/packages/html-parser/README.md +++ b/packages/html-parser/README.md @@ -1,6 +1,6 @@ -# @mtqt/html-parser +# @mtcute/html-parser -> HTML entities parser for mtqt +> HTML entities parser for MTCute This package implements formatting syntax based on HTML, similar to the one available in the Bot API ([documented here](https://core.telegram.org/bots/api#html-style)) @@ -12,8 +12,8 @@ API ([documented here](https://core.telegram.org/bots/api#html-style)) ## Usage ```typescript -import { TelegramClient } from '@mtqt/client' -import { HtmlMessageEntityParser, html } from '@mtqt/html-parser' +import { TelegramClient } from '@mtcute/client' +import { HtmlMessageEntityParser, html } from '@mtcute/html-parser' const tg = new TelegramClient({ ... }) tg.registerParseMode(new HtmlMessageEntityParser()) @@ -26,7 +26,7 @@ tg.sendText( ## Syntax -`@mtqt/html-parser` uses [`htmlparser2`](https://www.npmjs.com/package/htmlparser2) under the hood, so the parser +`@mtcute/html-parser` uses [`htmlparser2`](https://www.npmjs.com/package/htmlparser2) under the hood, so the parser supports nearly any HTML. However, since the text is still processed in a custom way for Telegram, the supported subset of features is documented below: @@ -40,7 +40,7 @@ Line breaks are preserved, `
` are ignored. > > Use `htm` instead (which is just an alias): > ```typescript -> import { htm } from '@mtqt/html-parser' +> import { htm } from '@mtcute/html-parser' > > await msg.answerText(htm`Hello, ${msg.sender.username}`) > ``` @@ -110,7 +110,7 @@ better to use [`HtmlMessageEntityParser.escape`](./classes/htmlmessageentitypars `html` helper: ```typescript -import { html } from '@mtqt/html-parser' +import { html } from '@mtcute/html-parser' const username = 'Boris <&>' const text = html`Hi, ${username}!` diff --git a/packages/html-parser/package.json b/packages/html-parser/package.json index 471c5921..9b39d010 100644 --- a/packages/html-parser/package.json +++ b/packages/html-parser/package.json @@ -1,8 +1,8 @@ { - "name": "@mtqt/html-parser", + "name": "@mtcute/html-parser", "private": true, "version": "1.0.0", - "description": "HTML entities parser for mtqt", + "description": "HTML entities parser for MTCute", "author": "Alisa Sireneva ", "license": "LGPL-3.0", "main": "src/index.ts", @@ -13,11 +13,11 @@ "docs": "npx typedoc" }, "dependencies": { - "@mtqt/tl": "~1.131.0", + "@mtcute/tl": "~1.131.0", "htmlparser2": "^6.0.1", "big-integer": "^1.6.48" }, "devDependencies": { - "@mtqt/client": "^1.0.0" + "@mtcute/client": "^1.0.0" } } diff --git a/packages/html-parser/src/index.ts b/packages/html-parser/src/index.ts index 30570e80..5ebf98ed 100644 --- a/packages/html-parser/src/index.ts +++ b/packages/html-parser/src/index.ts @@ -2,8 +2,8 @@ import type { IMessageEntityParser, MessageEntity, FormattedString, -} from '@mtqt/client' -import { tl } from '@mtqt/tl' +} from '@mtcute/client' +import { tl } from '@mtcute/tl' import { Parser } from 'htmlparser2' import bigInt from 'big-integer' diff --git a/packages/html-parser/tests/html-parser.spec.ts b/packages/html-parser/tests/html-parser.spec.ts index 9ff61a0c..ebde052c 100644 --- a/packages/html-parser/tests/html-parser.spec.ts +++ b/packages/html-parser/tests/html-parser.spec.ts @@ -1,8 +1,8 @@ import { describe, it } from 'mocha' import { expect } from 'chai' -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' import { HtmlMessageEntityParser, html } from '../src' -import { MessageEntity, FormattedString } from '@mtqt/client' +import { MessageEntity, FormattedString } from '@mtcute/client' import bigInt from 'big-integer' const createEntity = ( diff --git a/packages/html-parser/tsconfig.json b/packages/html-parser/tsconfig.json index aa16667e..6a8fe885 100644 --- a/packages/html-parser/tsconfig.json +++ b/packages/html-parser/tsconfig.json @@ -7,7 +7,7 @@ "./src" ], "typedocOptions": { - "name": "@mtqt/html-parser", + "name": "@mtcute/html-parser", "includeVersion": true, "out": "../../docs/packages/html-parser", "listInvalidSymbolLinks": true, diff --git a/packages/http-proxy/index.ts b/packages/http-proxy/index.ts index 37bf7364..dacdd68f 100644 --- a/packages/http-proxy/index.ts +++ b/packages/http-proxy/index.ts @@ -3,11 +3,11 @@ import { BaseTcpTransport, TransportState, tl -} from '@mtqt/core' +} from '@mtcute/core' import { connect as connectTcp } from 'net' import { connect as connectTls, SecureContextOptions } from 'tls' -const debug = require('debug')('mtqt:http-proxy') +const debug = require('debug')('mtcute:http-proxy') /** * An error has occurred while connecting to an HTTP(s) proxy diff --git a/packages/http-proxy/package.json b/packages/http-proxy/package.json index 6a2c99ca..cf0f00b1 100644 --- a/packages/http-proxy/package.json +++ b/packages/http-proxy/package.json @@ -1,8 +1,8 @@ { - "name": "@mtqt/http-proxy", + "name": "@mtcute/http-proxy", "private": true, "version": "1.0.0", - "description": "HTTP(S) proxy support for mtqt", + "description": "HTTP(S) proxy support for MTCute", "author": "Alisa Sireneva ", "license": "LGPL-3.0", "main": "index.ts", @@ -12,7 +12,7 @@ "build": "tsc" }, "dependencies": { - "@mtqt/core": "^1.0.0", + "@mtcute/core": "^1.0.0", "debug": "^4.3.1" } } diff --git a/packages/http-proxy/tsconfig.json b/packages/http-proxy/tsconfig.json index b0a8d12e..e670a8fe 100644 --- a/packages/http-proxy/tsconfig.json +++ b/packages/http-proxy/tsconfig.json @@ -7,7 +7,7 @@ "./index.ts", ], "typedocOptions": { - "name": "@mtqt/http-proxy", + "name": "@mtcute/http-proxy", "includeVersion": true, "out": "../../docs/packages/http-proxy", "listInvalidSymbolLinks": true, diff --git a/packages/markdown-parser/README.md b/packages/markdown-parser/README.md index 8b2ca6e6..78690c20 100644 --- a/packages/markdown-parser/README.md +++ b/packages/markdown-parser/README.md @@ -1,6 +1,6 @@ -# @mtqt/markdown-parser +# @mtcute/markdown-parser -> Markdown entities parser for mtqt +> Markdown entities parser for MTCute This package implements formatting syntax similar to Markdown (CommonMark) but slightly adjusted and simplified. @@ -11,8 +11,8 @@ This package implements formatting syntax similar to Markdown (CommonMark) but s ## Usage ```typescript -import { TelegramClient } from '@mtqt/client' -import { MarkdownMessageEntityParser, md } from '@mtqt/markdown-parser' +import { TelegramClient } from '@mtcute/client' +import { MarkdownMessageEntityParser, md } from '@mtcute/markdown-parser' const tg = new TelegramClient({ ... }) tg.registerParseMode(new MarkdownMessageEntityParser()) @@ -124,7 +124,7 @@ like `"\\_\\_not italic\\_\\_`. > > This will look pretty bad in real code, so use escaping only when really needed, and use > [`MarkdownMessageEntityParser.escape`](./classes/markdownmessageentityparser.html#escape) or `md` or -> other parse modes (like HTML one provided by [`@mtqt/html-parser`](../html-parser/index.html))) instead. +> other parse modes (like HTML one provided by [`@mtcute/html-parser`](../html-parser/index.html))) instead. > In theory, you could escape every single non-markup character, but why would you want to do that 😜 diff --git a/packages/markdown-parser/package.json b/packages/markdown-parser/package.json index 217fcd78..9f9d28c7 100644 --- a/packages/markdown-parser/package.json +++ b/packages/markdown-parser/package.json @@ -1,8 +1,8 @@ { - "name": "@mtqt/markdown-parser", + "name": "@mtcute/markdown-parser", "private": true, "version": "1.0.0", - "description": "Markdown entities parser for mtqt", + "description": "Markdown entities parser for MTCute", "author": "Alisa Sireneva ", "license": "LGPL-3.0", "main": "src/index.ts", @@ -13,10 +13,10 @@ "docs": "npx typedoc" }, "dependencies": { - "@mtqt/tl": "~1.131.0", + "@mtcute/tl": "~1.131.0", "big-integer": "^1.6.48" }, "devDependencies": { - "@mtqt/client": "^1.0.0" + "@mtcute/client": "^1.0.0" } } diff --git a/packages/markdown-parser/src/index.ts b/packages/markdown-parser/src/index.ts index dafd8c02..50899290 100644 --- a/packages/markdown-parser/src/index.ts +++ b/packages/markdown-parser/src/index.ts @@ -1,7 +1,7 @@ -import type { IMessageEntityParser, MessageEntity } from '@mtqt/client' -import { tl } from '@mtqt/tl' +import type { IMessageEntityParser, MessageEntity } from '@mtcute/client' +import { tl } from '@mtcute/tl' import bigInt from 'big-integer' -import { FormattedString } from '@mtqt/client' +import { FormattedString } from '@mtcute/client' const MENTION_REGEX = /^tg:\/\/user\?id=(\d+)(?:&hash=(-?[0-9a-fA-F]+)(?:&|$)|&|$)/ diff --git a/packages/markdown-parser/tests/markdown-parser.spec.ts b/packages/markdown-parser/tests/markdown-parser.spec.ts index ac934d11..bf98387c 100644 --- a/packages/markdown-parser/tests/markdown-parser.spec.ts +++ b/packages/markdown-parser/tests/markdown-parser.spec.ts @@ -1,7 +1,7 @@ import { describe, it } from 'mocha' import { expect } from 'chai' -import { tl } from '@mtqt/tl' -import { MessageEntity, FormattedString } from '@mtqt/client' +import { tl } from '@mtcute/tl' +import { MessageEntity, FormattedString } from '@mtcute/client' import { MarkdownMessageEntityParser, md } from '../src' import bigInt from 'big-integer' diff --git a/packages/markdown-parser/tsconfig.json b/packages/markdown-parser/tsconfig.json index 946695b3..5b8f1839 100644 --- a/packages/markdown-parser/tsconfig.json +++ b/packages/markdown-parser/tsconfig.json @@ -7,7 +7,7 @@ "./src" ], "typedocOptions": { - "name": "@mtqt/markdown-parser", + "name": "@mtcute/markdown-parser", "includeVersion": true, "out": "../../docs/packages/markdown-parser", "listInvalidSymbolLinks": true, diff --git a/packages/mtproxy/fake-tls.ts b/packages/mtproxy/fake-tls.ts index 72307e77..a27cd94d 100644 --- a/packages/mtproxy/fake-tls.ts +++ b/packages/mtproxy/fake-tls.ts @@ -5,7 +5,7 @@ import { IPacketCodec, WrappedCodec, randomBytes, -} from '@mtqt/core' +} from '@mtcute/core' import bigInt, { BigInteger } from 'big-integer' const MAX_TLS_PACKET_LENGTH = 2878 diff --git a/packages/mtproxy/index.ts b/packages/mtproxy/index.ts index 0194e535..f6757743 100644 --- a/packages/mtproxy/index.ts +++ b/packages/mtproxy/index.ts @@ -6,8 +6,8 @@ import { parseUrlSafeBase64, BaseTcpTransport, TransportState, -} from '@mtqt/core' -import { tl } from '@mtqt/tl' +} from '@mtcute/core' +import { tl } from '@mtcute/tl' import { connect } from 'net' import { FakeTlsPacketCodec, generateFakeTlsHeader } from './fake-tls' diff --git a/packages/mtproxy/package.json b/packages/mtproxy/package.json index 4d57a365..7071285a 100644 --- a/packages/mtproxy/package.json +++ b/packages/mtproxy/package.json @@ -1,8 +1,8 @@ { - "name": "@mtqt/mtproxy", + "name": "@mtcute/mtproxy", "private": true, "version": "1.0.0", - "description": "MTProto proxy (MTProxy) support for mtqt", + "description": "MTProto proxy (MTProxy) support for MTCute", "author": "Alisa Sireneva ", "license": "LGPL-3.0", "main": "index.ts", @@ -12,8 +12,8 @@ "build": "tsc" }, "dependencies": { - "@mtqt/core": "^1.0.0", - "@mtqt/tl": "~1.131.0", + "@mtcute/core": "^1.0.0", + "@mtcute/tl": "~1.131.0", "big-integer": "1.6.48" } } diff --git a/packages/mtproxy/tsconfig.json b/packages/mtproxy/tsconfig.json index b98ad345..0d95e3cc 100644 --- a/packages/mtproxy/tsconfig.json +++ b/packages/mtproxy/tsconfig.json @@ -7,7 +7,7 @@ "./index.ts", ], "typedocOptions": { - "name": "@mtqt/mtproxy", + "name": "@mtcute/mtproxy", "includeVersion": true, "out": "../../docs/packages/mtproxy", "listInvalidSymbolLinks": true, diff --git a/packages/node/index.ts b/packages/node/index.ts index 49e0d34c..42bfa449 100644 --- a/packages/node/index.ts +++ b/packages/node/index.ts @@ -1,19 +1,19 @@ -import { TelegramClient, User } from '@mtqt/client' -import { BaseTelegramClient } from '@mtqt/core' -import { HtmlMessageEntityParser } from '@mtqt/html-parser' -import { MarkdownMessageEntityParser } from '@mtqt/markdown-parser' -import { SqliteStorage } from '@mtqt/sqlite' +import { TelegramClient, User } from '@mtcute/client' +import { BaseTelegramClient } from '@mtcute/core' +import { HtmlMessageEntityParser } from '@mtcute/html-parser' +import { MarkdownMessageEntityParser } from '@mtcute/markdown-parser' +import { SqliteStorage } from '@mtcute/sqlite' import { createInterface, Interface as RlInterface } from 'readline' -export * from '@mtqt/dispatcher' -export * from '@mtqt/client' -export * from '@mtqt/html-parser' -export * from '@mtqt/markdown-parser' +export * from '@mtcute/dispatcher' +export * from '@mtcute/client' +export * from '@mtcute/html-parser' +export * from '@mtcute/markdown-parser' export { SqliteStorage } let nativeCrypto: any try { - nativeCrypto = require('@mtqt/crypto-node').NodeNativeCryptoProvider + nativeCrypto = require('@mtcute/crypto-node').NodeNativeCryptoProvider } catch (e) {} export namespace NodeTelegramClient { diff --git a/packages/node/package.json b/packages/node/package.json index 13cb7748..4907cd6a 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -1,5 +1,5 @@ { - "name": "@mtqt/node", + "name": "@mtcute/node", "private": true, "version": "1.0.0", "description": "Meta-package for Node JS", @@ -12,11 +12,11 @@ "build": "tsc" }, "dependencies": { - "@mtqt/core": "^1.0.0", - "@mtqt/client": "^1.0.0", - "@mtqt/sqlite": "^1.0.0", - "@mtqt/markdown-parser": "^1.0.0", - "@mtqt/html-parser": "^1.0.0", - "@mtqt/dispatcher": "^1.0.0" + "@mtcute/core": "^1.0.0", + "@mtcute/client": "^1.0.0", + "@mtcute/sqlite": "^1.0.0", + "@mtcute/markdown-parser": "^1.0.0", + "@mtcute/html-parser": "^1.0.0", + "@mtcute/dispatcher": "^1.0.0" } } diff --git a/packages/node/tsconfig.json b/packages/node/tsconfig.json index 8b0a839c..02e4f433 100644 --- a/packages/node/tsconfig.json +++ b/packages/node/tsconfig.json @@ -7,7 +7,7 @@ "./index.ts" ], "typedocOptions": { - "name": "@mtqt/node", + "name": "@mtcute/node", "includeVersion": true, "out": "../../docs/packages/node", "listInvalidSymbolLinks": true, diff --git a/packages/socks-proxy/index.ts b/packages/socks-proxy/index.ts index 89ba2238..e7d676e8 100644 --- a/packages/socks-proxy/index.ts +++ b/packages/socks-proxy/index.ts @@ -3,13 +3,13 @@ import { BaseTcpTransport, TransportState, tl -} from '@mtqt/core' +} from '@mtcute/core' import { connect } from 'net' // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore import { normalize } from 'ip6' -const debug = require('debug')('mtqt:socks-proxy') +const debug = require('debug')('mtcute:socks-proxy') /** * An error has occurred while connecting to an SOCKS proxy diff --git a/packages/socks-proxy/package.json b/packages/socks-proxy/package.json index 9e0bd2d1..00280413 100644 --- a/packages/socks-proxy/package.json +++ b/packages/socks-proxy/package.json @@ -1,8 +1,8 @@ { - "name": "@mtqt/socks-proxy", + "name": "@mtcute/socks-proxy", "private": true, "version": "1.0.0", - "description": "SOCKS4/5 proxy support for mtqt", + "description": "SOCKS4/5 proxy support for MTCute", "author": "Alisa Sireneva ", "license": "LGPL-3.0", "main": "index.ts", @@ -12,7 +12,7 @@ "build": "tsc" }, "dependencies": { - "@mtqt/core": "^1.0.0", + "@mtcute/core": "^1.0.0", "ip6": "^0.2.6", "debug": "^4.3.1" } diff --git a/packages/socks-proxy/tsconfig.json b/packages/socks-proxy/tsconfig.json index e1339dc6..67806e05 100644 --- a/packages/socks-proxy/tsconfig.json +++ b/packages/socks-proxy/tsconfig.json @@ -7,7 +7,7 @@ "./index.ts", ], "typedocOptions": { - "name": "@mtqt/socks-proxy", + "name": "@mtcute/socks-proxy", "includeVersion": true, "out": "../../docs/packages/socks-proxy", "listInvalidSymbolLinks": true, diff --git a/packages/sqlite/index.ts b/packages/sqlite/index.ts index 59018373..80fb833c 100644 --- a/packages/sqlite/index.ts +++ b/packages/sqlite/index.ts @@ -6,13 +6,13 @@ import { ITelegramStorage, LruMap, MAX_CHANNEL_ID, -} from '@mtqt/core' -import { tl } from '@mtqt/tl' +} from '@mtcute/core' +import { tl } from '@mtcute/tl' import sqlite3 from 'better-sqlite3' import bigInt from 'big-integer' -import { throttle } from '@mtqt/core' +import { throttle } from '@mtcute/core' -const debug = require('debug')('mtqt:sqlite') +const debug = require('debug')('mtcute:sqlite') function serializeAccessHash(hash: tl.Long): Buffer { const arr = hash.toArray(256) @@ -156,7 +156,7 @@ const STATEMENTS = { const EMPTY_BUFFER = Buffer.alloc(0) /** - * SQLite backed storage for mtqt. + * SQLite backed storage for MTCute. * * Uses `better-sqlite3` library */ diff --git a/packages/sqlite/package.json b/packages/sqlite/package.json index 02edaf18..ada07aaf 100644 --- a/packages/sqlite/package.json +++ b/packages/sqlite/package.json @@ -1,8 +1,8 @@ { - "name": "@mtqt/sqlite", + "name": "@mtcute/sqlite", "private": true, "version": "1.0.0", - "description": "SQLite-based storage for mtqt", + "description": "SQLite-based storage for MTCute", "author": "Alisa Sireneva ", "license": "LGPL-3.0", "main": "index.ts", @@ -12,8 +12,8 @@ "build": "tsc" }, "dependencies": { - "@mtqt/core": "^1.0.0", - "@mtqt/tl": "~1.131.0", + "@mtcute/core": "^1.0.0", + "@mtcute/tl": "~1.131.0", "better-sqlite3": "^7.4.0", "big-integer": "1.6.48", "debug": "^4.3.1" diff --git a/packages/sqlite/tsconfig.json b/packages/sqlite/tsconfig.json index edc3d342..1a263372 100644 --- a/packages/sqlite/tsconfig.json +++ b/packages/sqlite/tsconfig.json @@ -7,7 +7,7 @@ "./index.ts" ], "typedocOptions": { - "name": "@mtqt/sqlite", + "name": "@mtcute/sqlite", "includeVersion": true, "out": "../../docs/packages/sqlite", "listInvalidSymbolLinks": true, diff --git a/packages/tl/README.md b/packages/tl/README.md index 1042f6fc..677a575c 100644 --- a/packages/tl/README.md +++ b/packages/tl/README.md @@ -1,6 +1,6 @@ -# @mtqt/tl +# @mtcute/tl -> TL schema and related utils used for mtqt. +> TL schema and related utils used for MTCute. Generated from TL layer **131** (last updated on 25.07.2021). @@ -14,8 +14,8 @@ so version `1.42.0` means that this version was generated from TL layer 42. > ⚠️ **Warning**: Always use strict or tilde constraint to ensure > the same schema is used. > -> I.e. use `"@mtqt/tl": "~1.42.0"` or `"@mtqt/tl": "1.42.0"` -> instead of `"@mtqt/tl": "^1.42.0"`, since the former would also +> I.e. use `"@mtcute/tl": "~1.42.0"` or `"@mtcute/tl": "1.42.0"` +> instead of `"@mtcute/tl": "^1.42.0"`, since the former would also > match `1.43.0, 1.44.0, ...` and will probably break your build or runtime - JSON schema, types, binary (de-)serialization and helper functions are generated directly from `.tl` files that are @@ -27,7 +27,7 @@ so version `1.42.0` means that this version was generated from TL layer 42. ## Contents -### `@mtqt/tl` +### `@mtcute/tl` [Documentation](./modules/index.html) @@ -42,32 +42,32 @@ use-cases for mutable TL objects, so you can use exported import statements. ```typescript -import { tl } from '@mtqt/tl' +import { tl } from '@mtcute/tl' const obj: tl.RawInputPeerChat = { _: 'inputPeerChat', chatId: 42 } console.log(tl.isAnyInputPeer(obj)) // true ``` -### `@mtqt/tl/raw-schema` +### `@mtcute/tl/raw-schema` [Documentation](./modules/raw_schema.html) JSON file describing all available TL classes, methods and unions. Can be used to write custom code generators -> This very file is used to generate binary serialization and TypeScript typings for `@mtqt/tl`. +> This very file is used to generate binary serialization and TypeScript typings for `@mtcute/tl`. ```typescript -import * as tlSchema from '@mtqt/tl/raw-schema' +import * as tlSchema from '@mtcute/tl/raw-schema' console.log(`Current layer: ${tlSchema.apiLayer}`) // Current layer: 124 ``` -### `@mtqt/tl/binary/reader` +### `@mtcute/tl/binary/reader` [Documentation](./modules/binary_reader.html) Contains mapping used to read TL objects from binary streams. ```typescript -import readerMap from '@mtqt/tl/binary/reader' +import readerMap from '@mtcute/tl/binary/reader' import { BinaryReader } from './binary-reader' const reader = new BinaryReader(Buffer.from([...])) @@ -75,14 +75,14 @@ console.log(readerMap[0x5bb8e511 /* mt_message */].call(reader)) // { _: 'mt_message', ... } ``` -### `@mtqt/tl/binary/writer` +### `@mtcute/tl/binary/writer` [Documentation](./modules/binary_writer.html) Contains mapping used to write TL objects to binary streams. ```typescript -import writerMap from '@mtqt/tl/binary/writer' +import writerMap from '@mtcute/tl/binary/writer' import { BinaryWriter } from './binary-writer' const writer = new BinaryWriter() diff --git a/packages/tl/binary/reader.d.ts b/packages/tl/binary/reader.d.ts index 46b53231..e6ddc6db 100644 --- a/packages/tl/binary/reader.d.ts +++ b/packages/tl/binary/reader.d.ts @@ -1,7 +1,7 @@ import { BigInteger } from 'big-integer' /** - * Interface describing binary reader compatible with @mtqt/tl + * Interface describing binary reader compatible with @mtcute/tl * generated binary readers */ export interface ITlBinaryReader { diff --git a/packages/tl/binary/writer.d.ts b/packages/tl/binary/writer.d.ts index b797aa50..8b92325a 100644 --- a/packages/tl/binary/writer.d.ts +++ b/packages/tl/binary/writer.d.ts @@ -1,7 +1,7 @@ import { BigInteger } from 'big-integer' /** - * Interface describing binary writer compatible with @mtqt/tl + * Interface describing binary writer compatible with @mtcute/tl * generated binary writers */ export interface ITlBinaryWriter { diff --git a/packages/tl/package.json b/packages/tl/package.json index dc7b470c..99b73a8d 100644 --- a/packages/tl/package.json +++ b/packages/tl/package.json @@ -1,7 +1,7 @@ { - "name": "@mtqt/tl", + "name": "@mtcute/tl", "version": "1.131.0", - "description": "TL schema used for mtqt", + "description": "TL schema used for MTCute", "main": "index.js", "author": "Alisa Sireneva ", "license": "LGPL-3.0", diff --git a/packages/tl/typedoc.json b/packages/tl/typedoc.json index c9d82488..546b8228 100644 --- a/packages/tl/typedoc.json +++ b/packages/tl/typedoc.json @@ -1,5 +1,5 @@ { - "name": "@mtqt/tl", + "name": "@mtcute/tl", "out": "../../docs/packages/tl", "includeVersion": true, "listInvalidSymbolLinks": false, diff --git a/scripts/publish.js b/scripts/publish.js index 4f19f3bf..8e60edb9 100644 --- a/scripts/publish.js +++ b/scripts/publish.js @@ -56,9 +56,9 @@ function publishSinglePackage(name) { content = content.replace('/// ', '') } - if (content.match(/@mtqt\/[a-z]+\/src/)) { + if (content.match(/@mtcute\/[a-z]+\/src/)) { changed = true - content = content.replace(/(@mtqt\/[a-z]+)\/src/g, '$1') + content = content.replace(/(@mtcute\/[a-z]+)\/src/g, '$1') } if (content.trim().match(/^export {};?$/)) { @@ -75,9 +75,9 @@ function publishSinglePackage(name) { let content = fs.readFileSync(f, 'utf8') let changed = false - if (content.match(/@mtqt\/[a-z]+\/src/)) { + if (content.match(/@mtcute\/[a-z]+\/src/)) { changed = true - content = content.replace(/(@mtqt\/[a-z]+)\/src/g, '$1') + content = content.replace(/(@mtcute\/[a-z]+)\/src/g, '$1') } if (changed) fs.writeFileSync(f, content) diff --git a/tl-reference/src/components/page.tsx b/tl-reference/src/components/page.tsx index e6cceb9b..b646bdb3 100644 --- a/tl-reference/src/components/page.tsx +++ b/tl-reference/src/components/page.tsx @@ -81,8 +81,8 @@ export function Page({ variant="body2" className={classes.footer} > - © mtqt TL reference. This website is{' '} - + © MTCute TL reference. This website is{' '} + open-source {' '} and licensed under MIT. diff --git a/tl-reference/src/pages/history.tsx b/tl-reference/src/pages/history.tsx index c16bdeec..109292d7 100644 --- a/tl-reference/src/pages/history.tsx +++ b/tl-reference/src/pages/history.tsx @@ -49,7 +49,7 @@ export default function HistoryPage({ data }: { data: GraphqlResult }) { Telegram's website.

- Note that schemas for mtqt are merged from Telegram Desktop + Note that schemas for MTCute are merged from Telegram Desktop and TDLib repositories, and thus may not be exactly the same as in history. diff --git a/tl-reference/src/pages/index.tsx b/tl-reference/src/pages/index.tsx index 066572c0..0fa5ea45 100644 --- a/tl-reference/src/pages/index.tsx +++ b/tl-reference/src/pages/index.tsx @@ -77,9 +77,9 @@ export default function IndexPage({ data }: { data: Data }) { Even though this reference is intended to be used with{' '} - mtqt{' '} + MTCute{' '} library, the objects are common to any other MTProto library. - The key difference is that mtqt (and this reference) use{' '} + The key difference is that MTCute (and this reference) use{' '} camelCase for arguments, while the original schema and some other libraries use snake_case. @@ -112,8 +112,8 @@ export default function IndexPage({ data }: { data: Data }) { Class. - In mtqt, all types are exposed as a namespace tl{' '} - of package @mtqt/tl. By design, we use immutable + In MTCute, all types are exposed as a namespace tl{' '} + of package @mtcute/tl. By design, we use immutable plain objects with type discriminator to represent{' '} Classes and Methods, and TypeScript unions to represent Unions.
diff --git a/tl-reference/src/pages/no-description.tsx b/tl-reference/src/pages/no-description.tsx index eab95fba..b3b2fe87 100644 --- a/tl-reference/src/pages/no-description.tsx +++ b/tl-reference/src/pages/no-description.tsx @@ -54,7 +54,7 @@ export default function NoDescriptionPage({ data }: { data: Data }) { schema that currently do not have a description, neither official nor unofficial. You can improve this reference by adding description to missing items in{' '} - + descriptions.yaml . @@ -66,7 +66,7 @@ export default function NoDescriptionPage({ data }: { data: Data }) { Type Name - + descriptions.yaml {' '} key @@ -109,7 +109,7 @@ export default function NoDescriptionPage({ data }: { data: Data }) { Type Name - + descriptions.yaml {' '} key