build: renamed to mtqt

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

View file

@ -1,10 +1,10 @@
# MTCute
# mtqt
![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)
Work-in-progress library for MTProto in TypeScript.
[🎯 Roadmap (notion.so)](https://www.notion.so/teidesu/MTCute-development-cfccff4fddad4b218f3bea27f784b8b5)
[🎯 Roadmap (notion.so)](https://teidesu.notion.site/mtqt-development-cfccff4fddad4b218f3bea27f784b8b5)
| [📦 TL Reference](https://mt.tei.su/tl)
> ⚠️ **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/teidesu/mtcute
cd mtcute
git clone https://github.com/mtqt-dev/mtqt
cd mtqt
yarn install
npx lerna link
@ -44,6 +44,7 @@ yarn generate-code
Some parts were based on code from these projects:
- [Pyrogram](https://pyrogram.org)
- [TDLib](https://github.com/tdlib/td)
- [Pyrogram](https://github.com/pyrogram/pyrogram)
- [Telethon](https://github.com/LonamiWebs/Telethon)
- [TDesktop](https://github.com/telegramdesktop/tdesktop)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,10 +1,10 @@
import { TelegramClient } from '../../client'
import {
InputPeerLike,
MtCuteInvalidPeerTypeError,
MtqtInvalidPeerTypeError,
GameHighScore,
} from '../../types'
import { tl } from '@mtcute/tl'
import { tl } from '@mtqt/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 MtCuteInvalidPeerTypeError(userId, 'user')
if (!res) throw new MtqtInvalidPeerTypeError(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 MtCuteInvalidPeerTypeError(userId, 'user')
if (!res) throw new MtqtInvalidPeerTypeError(userId, 'user')
user = res
} else {

View file

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

View file

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

View file

@ -1,7 +1,7 @@
import { InputPeerLike, Message, MtCuteInvalidPeerTypeError } from '../../types'
import { InputPeerLike, Message, MtqtInvalidPeerTypeError } from '../../types'
import { TelegramClient } from '../../client'
import { normalizeToInputUser } from '../../utils/peer-utils'
import { tl } from '@mtcute/tl'
import { tl } from '@mtqt/tl'
/**
* Set a score of a user in a game
@ -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 MtCuteInvalidPeerTypeError(userId, 'user')
if (!user) throw new MtqtInvalidPeerTypeError(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 MtCuteInvalidPeerTypeError(userId, 'user')
if (!user) throw new MtqtInvalidPeerTypeError(userId, 'user')
const [id, connection] = await this._normalizeInline(messageId)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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 '@mtcute/tl'
import { tl } from '@mtqt/tl'
/**
* Delete communication history (for private chats

View file

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

View file

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

View file

@ -1,11 +1,11 @@
import { TelegramClient } from '../../client'
import {
InputPeerLike,
MtCuteInvalidPeerTypeError,
MtqtInvalidPeerTypeError,
ChatEvent,
} from '../../types'
import { tl } from '@mtcute/tl'
import { MaybeArray } from '@mtcute/core'
import { tl } from '@mtqt/tl'
import { MaybeArray } from '@mtqt/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 MtCuteInvalidPeerTypeError(chatId, 'channel')
if (!channel) throw new MtqtInvalidPeerTypeError(chatId, 'channel')
let current = 0
let maxId = params.maxId ?? bigInt.zero

View file

@ -1,5 +1,5 @@
import { TelegramClient } from '../../client'
import { InputPeerLike, MtCuteInvalidPeerTypeError } from '../../types'
import { InputPeerLike, MtqtInvalidPeerTypeError } from '../../types'
import {
createUsersChatsIndex,
isInputPeerChannel,
@ -8,9 +8,9 @@ import {
normalizeToInputChannel,
} from '../../utils/peer-utils'
import { assertTypeIs } from '../../utils/type-assertion'
import { tl } from '@mtcute/tl'
import { tl } from '@mtqt/tl'
import { ChatMember } from '../../types'
import { UserNotParticipantError } from '@mtcute/tl/errors'
import { UserNotParticipantError } from '@mtqt/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 MtCuteInvalidPeerTypeError(userId, 'user')
throw new MtqtInvalidPeerTypeError(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 MtCuteInvalidPeerTypeError(chatId, 'chat or channel')
} else throw new MtqtInvalidPeerTypeError(chatId, 'chat or channel')
}

View file

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

View file

@ -1,4 +1,4 @@
import { MtCuteArgumentError, MtCuteNotFoundError } from '../../types'
import { MtqtArgumentError, MtqtNotFoundError } from '../../types'
import { TelegramClient } from '../../client'
import { 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 MtCuteArgumentError In case invite link has invalid format
* @throws MtCuteNotFoundError
* @throws MtqtArgumentError In case invite link has invalid format
* @throws MtqtNotFoundError
* 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<ChatPreview> {
const m = inviteLink.match(INVITE_LINK_REGEX)
if (!m) throw new MtCuteArgumentError('Invalid invite link')
if (!m) throw new MtqtArgumentError('Invalid invite link')
const res = await this.call({
_: 'messages.checkChatInvite',
@ -26,7 +26,7 @@ export async function getChatPreview(
})
if (res._ !== 'chatInvite') {
throw new MtCuteNotFoundError(`You have already joined this chat!`)
throw new MtqtNotFoundError(`You have already joined this chat!`)
}
return new ChatPreview(this, res, inviteLink)

View file

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

View file

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

View file

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

View file

@ -2,8 +2,8 @@ import { TelegramClient } from '../../client'
import {
Chat,
InputPeerLike,
MtCuteNotFoundError,
MtCuteTypeAssertionError,
MtqtNotFoundError,
MtqtTypeAssertionError,
} 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 MtCuteNotFoundError()
if (!peer) throw new MtqtNotFoundError()
const res = await this.call({
_: 'channels.joinChannel',

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,6 +1,6 @@
import { TelegramClient } from '../../client'
import { tl } from '@mtcute/tl'
import { MtCuteArgumentError } from '../../types'
import { tl } from '@mtqt/tl'
import { MtqtArgumentError } 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 MtCuteArgumentError(`Could not find a folder ${folder}`)
throw new MtqtArgumentError(`Could not find a folder ${folder}`)
folder = found
}

View file

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

View file

@ -1,13 +1,13 @@
import { TelegramClient } from '../../client'
import {
Dialog,
MtCuteArgumentError,
MtCuteTypeAssertionError,
MtqtArgumentError,
MtqtTypeAssertionError,
} from '../../types'
import { normalizeDate } from '../../utils/misc-utils'
import { createUsersChatsIndex } from '../../utils/peer-utils'
import { tl } from '@mtcute/tl'
import { getMarkedPeerId } from '@mtcute/core'
import { tl } from '@mtqt/tl'
import { getMarkedPeerId } from '@mtqt/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 MtCuteArgumentError} is thrown
* {@link MtqtArgumentError} 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 MtCuteArgumentError(
throw new MtqtArgumentError(
`Could not find folder ${params.folder}`
)

View file

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

View file

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

View file

@ -1,8 +1,8 @@
import { TelegramClient } from '../../client'
import { tl } from '@mtcute/tl'
import { Dialog, MtCuteTypeAssertionError } from '../../types'
import { tl } from '@mtqt/tl'
import { Dialog, MtqtTypeAssertionError } from '../../types'
import { createUsersChatsIndex } from '../../utils/peer-utils'
import { getMarkedPeerId } from '@mtcute/core'
import { getMarkedPeerId } from '@mtqt/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 MtCuteTypeAssertionError(
throw new MtqtTypeAssertionError(
'messages.getPeerDialogs',
'!messages.dialogsNotModified',
'messages.dialogsNotModified'

View file

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

View file

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

View file

@ -1,10 +1,10 @@
import { TelegramClient } from '../../client'
import { determinePartSize } from '../../utils/file-utils'
import { tl } from '@mtcute/tl'
import { FileMigrateError, FilerefUpgradeNeededError } from '@mtcute/tl/errors'
import { tl } from '@mtqt/tl'
import { FileMigrateError, FilerefUpgradeNeededError } from '@mtqt/tl/errors'
import {
MtCuteArgumentError,
MtCuteUnsupportedError,
MtqtArgumentError,
MtqtUnsupportedError,
FileDownloadParameters,
FileLocation,
} from '../../types'
@ -12,7 +12,7 @@ import {
fileIdToInputFileLocation,
fileIdToInputWebFileLocation,
parseFileId,
} from '@mtcute/file-id'
} from '@mtqt/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 MtCuteArgumentError(
throw new MtqtArgumentError(
`Invalid part size: ${partSizeKb}. Must be divisible by 4.`
)
let offset = params.offset ?? 0
if (offset % 4096 !== 0)
throw new MtCuteArgumentError(
throw new MtqtArgumentError(
`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 MtCuteUnsupportedError('File ref expired!')
throw new MtqtUnsupportedError('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 MtCuteUnsupportedError(
throw new MtqtUnsupportedError(
'Received CDN redirect, which is not supported (yet)'
)
}

View file

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

View file

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

View file

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

View file

@ -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 '@mtcute/tl'
import { MtCuteArgumentError, UploadFileLike, UploadedFile } from '../../types'
import { tl } from '@mtqt/tl'
import { MtqtArgumentError, 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')('mtcute:upload')
const debug = require('debug')('mtqt:upload')
const OVERRIDE_MIME: Record<string, string> = {
// 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 MtCuteArgumentError(
throw new MtqtArgumentError(
'Local paths are only supported for NodeJS!'
)
file = fs.createReadStream(file)
@ -163,7 +163,7 @@ export async function uploadFile(
}
if (!file.body)
throw new MtCuteArgumentError('Fetch response contains `null` body')
throw new MtqtArgumentError('Fetch response contains `null` body')
if (
typeof ReadableStream !== 'undefined' &&
@ -188,13 +188,13 @@ export async function uploadFile(
}
if (!(file instanceof Readable))
throw new MtCuteArgumentError(
throw new MtqtArgumentError(
'Could not convert input `file` to stream!'
)
const partSizeKb = params.partSize ?? determinePartSize(fileSize)
if (partSizeKb > 512)
throw new MtCuteArgumentError(`Invalid part size: ${partSizeKb}KB`)
throw new MtqtArgumentError(`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 MtCuteArgumentError(
throw new MtqtArgumentError(
`Unexpected EOS (there were only ${idx} parts, but expected ${partCount})`
)
if (!Buffer.isBuffer(part))
throw new MtCuteArgumentError(`Part ${idx} was not a Buffer!`)
throw new MtqtArgumentError(`Part ${idx} was not a Buffer!`)
if (part.length > partSize)
throw new MtCuteArgumentError(
throw new MtqtArgumentError(
`Part ${idx} had invalid size (expected ${partSize}, got ${part.length})`
)

View file

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

View file

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

View file

@ -2,13 +2,13 @@ import { TelegramClient } from '../../client'
import {
ChatInviteLink,
InputPeerLike,
MtCuteInvalidPeerTypeError,
MtqtInvalidPeerTypeError,
} from '../../types'
import {
createUsersChatsIndex,
normalizeToInputUser,
} from '../../utils/peer-utils'
import { tl } from '@mtcute/tl'
import { tl } from '@mtqt/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 MtCuteInvalidPeerTypeError(adminId, 'user')
if (!admin) throw new MtqtInvalidPeerTypeError(adminId, 'user')
let offsetDate: number | undefined = undefined
let offsetLink: string | undefined = undefined

View file

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

View file

@ -1,5 +1,5 @@
import { TelegramClient } from '../../client'
import { InputPeerLike, MtCuteTypeAssertionError, Poll } from '../../types'
import { InputPeerLike, MtqtTypeAssertionError, 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 MtCuteTypeAssertionError(
throw new MtqtTypeAssertionError(
'messages.editMessage (@ .updates[0].poll)',
'poll',
'undefined'

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -4,11 +4,11 @@ import {
InputMediaLike,
InputPeerLike,
Message,
MtCuteArgumentError,
MtCuteTypeAssertionError,
MtqtArgumentError,
MtqtTypeAssertionError,
} from '../../types'
import { MaybeArray } from '@mtcute/core'
import { tl } from '@mtcute/tl'
import { MaybeArray } from '@mtqt/core'
import { tl } from '@mtqt/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 MtCuteArgumentError(
throw new MtqtArgumentError(
'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 MtCuteArgumentError(
throw new MtqtArgumentError(
'You can either pass `caption` or `captionMedia`'
)

View file

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

View file

@ -1,5 +1,5 @@
import { TelegramClient } from '../../client'
import { InputPeerLike, Message, MtCuteTypeAssertionError } from '../../types'
import { InputPeerLike, Message, MtqtTypeAssertionError } 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 MtCuteTypeAssertionError(
throw new MtqtTypeAssertionError(
'messages.getHistory',
'!messages.messagesNotModified',
res._

View file

@ -1,5 +1,5 @@
import { TelegramClient } from '../../client'
import { InputPeerLike, MtCuteArgumentError, Message } from '../../types'
import { InputPeerLike, MtqtArgumentError, 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 MtCuteArgumentError('This message is not grouped')
if (!groupedId) throw new MtqtArgumentError('This message is not grouped')
return messages.filter(
(it) => it && it.groupedId?.eq(groupedId)

View file

@ -1,10 +1,10 @@
import { TelegramClient } from '../../client'
import { MaybeArray } from '@mtcute/core'
import { MaybeArray } from '@mtqt/core'
import {
createUsersChatsIndex,
} from '../../utils/peer-utils'
import { tl } from '@mtcute/tl'
import { Message, MtCuteTypeAssertionError } from '../../types'
import { tl } from '@mtqt/tl'
import { Message, MtqtTypeAssertionError } 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 MtCuteTypeAssertionError(
throw new MtqtTypeAssertionError(
'getMessages',
'!messages.messagesNotModified',
res._

View file

@ -1,12 +1,12 @@
import { TelegramClient } from '../../client'
import { MaybeArray } from '@mtcute/core'
import { MaybeArray } from '@mtqt/core'
import {
createUsersChatsIndex,
isInputPeerChannel,
normalizeToInputChannel,
} from '../../utils/peer-utils'
import { tl } from '@mtcute/tl'
import { Message, InputPeerLike, MtCuteTypeAssertionError } from '../../types'
import { tl } from '@mtqt/tl'
import { Message, InputPeerLike, MtqtTypeAssertionError } 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 MtCuteTypeAssertionError(
throw new MtqtTypeAssertionError(
'getMessages',
'!messages.messagesNotModified',
res._

View file

@ -1,12 +1,12 @@
import { TelegramClient } from '../../client'
import { MaybeArray } from '@mtcute/core'
import { MaybeArray } from '@mtqt/core'
import {
createUsersChatsIndex,
isInputPeerChannel,
normalizeToInputChannel,
} from '../../utils/peer-utils'
import { tl } from '@mtcute/tl'
import { Message, InputPeerLike, MtCuteTypeAssertionError } from '../../types'
import { tl } from '@mtqt/tl'
import { Message, InputPeerLike, MtqtTypeAssertionError } 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 MtCuteTypeAssertionError(
throw new MtqtTypeAssertionError(
'getMessages',
'!messages.messagesNotModified',
res._

View file

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

View file

@ -1,7 +1,7 @@
import { tl } from '@mtcute/tl'
import { tl } from '@mtqt/tl'
import { TelegramClient } from '../../client'
import { normalizeToInputUser } from '../../utils/peer-utils'
import { FormattedString, MtCuteError } from '../../types'
import { FormattedString, MtqtError } 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 MtCuteError(`Parse mode ${mode} is not registered.`)
throw new MtqtError(`Parse mode ${mode} is not registered.`)
}
;[text, entities] = await this._parseModes[mode].parse(text)

View file

@ -1,6 +1,6 @@
import { TelegramClient } from '../../client'
import { Message, MtCuteTypeAssertionError } from '../../types'
import { tl } from '@mtcute/tl'
import { Message, MtqtTypeAssertionError } from '../../types'
import { tl } from '@mtqt/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 MtCuteTypeAssertionError(
throw new MtqtTypeAssertionError(
'messages.searchGlobal',
'!messages.messagesNotModified',
res._

View file

@ -1,6 +1,6 @@
import { TelegramClient } from '../../client'
import { InputPeerLike, Message, MtCuteTypeAssertionError } from '../../types'
import { tl } from '@mtcute/tl'
import { InputPeerLike, Message, MtqtTypeAssertionError } from '../../types'
import { tl } from '@mtqt/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 MtCuteTypeAssertionError(
throw new MtqtTypeAssertionError(
'messages.search',
'!messages.messagesNotModified',
res._

View file

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

View file

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

View file

@ -3,7 +3,7 @@ import {
BotKeyboard, FormattedString,
InputMediaLike,
InputPeerLike,
Message, MtCuteArgumentError,
Message, MtqtArgumentError,
ReplyMarkup,
} from '../../types'
import {
@ -11,8 +11,8 @@ import {
normalizeMessageId,
randomUlong,
} from '../../utils/misc-utils'
import { tl } from '@mtcute/tl'
import { MessageNotFoundError } from '@mtcute/tl/errors'
import { tl } from '@mtqt/tl'
import { MessageNotFoundError } from '@mtqt/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 MtCuteArgumentError(
throw new MtqtArgumentError(
'mustReply used, but replyTo was not passed'
)

View file

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

View file

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

View file

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

View file

@ -1,11 +1,11 @@
import { TelegramClient } from '../../client'
import {
InputPeerLike,
MtCuteArgumentError,
MtCuteTypeAssertionError,
MtqtArgumentError,
MtqtTypeAssertionError,
Poll,
} from '../../types'
import { MaybeArray, MessageNotFoundError } from '@mtcute/core'
import { MaybeArray, MessageNotFoundError } from '@mtqt/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 MtCuteArgumentError(
throw new MtqtArgumentError(
'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 MtCuteTypeAssertionError(
throw new MtqtTypeAssertionError(
'messages.sendVote (@ .updates[0].poll)',
'poll',
'undefined'

View file

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

View file

@ -1,5 +1,5 @@
import { TelegramClient } from '../../client'
import { MtCuteError, IMessageEntityParser } from '../../types'
import { MtqtError, IMessageEntityParser } from '../../types'
/**
* Register a given {@link IMessageEntityParser} as a parse mode
@ -7,7 +7,7 @@ import { MtCuteError, IMessageEntityParser } from '../../types'
* mode is also set as default.
*
* @param parseMode Parse mode to register
* @throws MtCuteError When the parse mode with a given name is already registered.
* @throws MtqtError When the parse mode with a given name is already registered.
* @internal
*/
export function registerParseMode(
@ -17,7 +17,7 @@ export function registerParseMode(
const name = parseMode.name
if (name in this._parseModes) {
throw new MtCuteError(
throw new MtqtError(
`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 MtCuteError When the provided parse mode is not registered
* @throws MtCuteError When `name` is omitted and there is no default parse mode
* @throws MtqtError When the provided parse mode is not registered
* @throws MtqtError 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 MtCuteError('There is no default parse mode')
throw new MtqtError('There is no default parse mode')
name = this._defaultParseMode
}
if (!(name in this._parseModes)) {
throw new MtCuteError(`Parse mode ${name} is not registered.`)
throw new MtqtError(`Parse mode ${name} is not registered.`)
}
return this._parseModes[name]
@ -75,12 +75,12 @@ export function getParseMode(
* Set a given parse mode as a default one.
*
* @param name Name of the parse mode
* @throws MtCuteError When given parse mode is not registered.
* @throws MtqtError When given parse mode is not registered.
* @internal
*/
export function setDefaultParseMode(this: TelegramClient, name: string): void {
if (!(name in this._parseModes)) {
throw new MtCuteError(`Parse mode ${name} is not registered.`)
throw new MtqtError(`Parse mode ${name} is not registered.`)
}
this._defaultParseMode = name

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