rename back to mtcute
idk lol
This commit is contained in:
parent
b7751f0a57
commit
4b22ee5b25
276 changed files with 768 additions and 768 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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 <me@tei.su>",
|
||||
"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",
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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<Chat[]>
|
||||
/**
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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'
|
||||
)
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { TelegramClient } from '../../client'
|
||||
import { tl } from '@mtqt/tl'
|
||||
import { tl } from '@mtcute/tl'
|
||||
import { BotInline, InputInlineResult } from '../../types'
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { TelegramClient } from '../../client'
|
||||
import { tl } from '@mtqt/tl'
|
||||
import { tl } from '@mtcute/tl'
|
||||
import { BotCommands } from '../../types'
|
||||
|
||||
/**
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { TelegramClient } from '../../client'
|
||||
import { tl } from '@mtqt/tl'
|
||||
import { tl } from '@mtcute/tl'
|
||||
import { BotCommands } from '../../types'
|
||||
|
||||
/**
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { TelegramClient } from '../../client'
|
||||
import { tl } from '@mtqt/tl'
|
||||
import { tl } from '@mtcute/tl'
|
||||
import { BotCommands } from '../../types'
|
||||
|
||||
/**
|
||||
|
|
|
@ -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')
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { TelegramClient } from '../../client'
|
||||
import { Chat, MtqtTypeAssertionError } from '../../types'
|
||||
import { Chat, MtTypeAssertionError } from '../../types'
|
||||
import { assertIsUpdatesGroup } from '../../utils/updates-utils'
|
||||
|
||||
/**
|
||||
|
|
|
@ -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'
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { TelegramClient } from '../../client'
|
||||
import { Chat, MtqtTypeAssertionError } from '../../types'
|
||||
import { Chat, MtTypeAssertionError } from '../../types'
|
||||
import { assertIsUpdatesGroup } from '../../utils/updates-utils'
|
||||
|
||||
/**
|
||||
|
|
|
@ -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<void> {
|
||||
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',
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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<void> {
|
||||
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',
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<void> {
|
||||
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',
|
||||
|
|
|
@ -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<void> {
|
||||
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',
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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')
|
||||
}
|
||||
|
|
|
@ -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')
|
||||
}
|
||||
|
|
|
@ -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<ChatPreview> {
|
||||
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)
|
||||
|
|
|
@ -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)}`
|
||||
)
|
||||
}
|
||||
|
|
|
@ -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)}`
|
||||
)
|
||||
}
|
||||
|
|
|
@ -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'
|
||||
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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')
|
||||
}
|
||||
|
|
|
@ -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<void> {
|
||||
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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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'
|
||||
|
||||
/**
|
||||
|
|
|
@ -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<void> {
|
||||
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)) {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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<void> {
|
||||
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',
|
||||
|
|
|
@ -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<void> {
|
||||
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',
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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')
|
||||
}
|
||||
|
|
|
@ -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<User> {
|
||||
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',
|
||||
|
|
|
@ -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'
|
||||
)
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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'
|
||||
|
||||
/**
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { TelegramClient } from '../../client'
|
||||
import { tl } from '@mtqt/tl'
|
||||
import { tl } from '@mtcute/tl'
|
||||
|
||||
/**
|
||||
* Delete a folder by its ID
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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<tl.RawDialogFilter | null> {
|
||||
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()
|
||||
|
||||
|
|
|
@ -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}`
|
||||
)
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { TelegramClient } from '../../client'
|
||||
import { tl } from '@mtqt/tl'
|
||||
import { tl } from '@mtcute/tl'
|
||||
|
||||
/**
|
||||
* Get list of folders.
|
||||
|
|
|
@ -3,7 +3,7 @@ import {
|
|||
Dialog,
|
||||
InputPeerLike,
|
||||
} from '../../types'
|
||||
import { MaybeArray } from '@mtqt/core'
|
||||
import { MaybeArray } from '@mtcute/core'
|
||||
|
||||
/**
|
||||
* Get dialogs with certain peers.
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TelegramConnection } from '@mtqt/core'
|
||||
import { TelegramConnection } from '@mtcute/core'
|
||||
|
||||
import { TelegramClient } from '../../client'
|
||||
|
||||
|
|
|
@ -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<void> {
|
||||
if (!fs)
|
||||
throw new MtqtUnsupportedError(
|
||||
throw new MtUnsupportedError(
|
||||
'Downloading to file is only supported in NodeJS'
|
||||
)
|
||||
|
||||
|
|
|
@ -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)'
|
||||
)
|
||||
}
|
||||
|
|
|
@ -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'
|
||||
|
||||
/**
|
||||
|
|
|
@ -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<tl.TypeInputFile> {
|
||||
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"
|
||||
)
|
||||
}
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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<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 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})`
|
||||
)
|
||||
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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`'
|
||||
)
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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._
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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._
|
||||
|
|
|
@ -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._
|
||||
|
|
|
@ -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._
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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._
|
||||
|
|
|
@ -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._
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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'
|
||||
)
|
||||
|
||||
|
|
|
@ -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'
|
||||
)
|
||||
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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._
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { TelegramClient } from '../../client'
|
||||
import { tl } from '@mtqt/tl'
|
||||
import { tl } from '@mtcute/tl'
|
||||
import { InputPeerLike, TypingStatus } from '../../types'
|
||||
|
||||
/**
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { TelegramClient } from '../../client'
|
||||
import { tl } from '@mtqt/tl'
|
||||
import { tl } from '@mtcute/tl'
|
||||
import { TakeoutSession } from '../../types'
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue