feat(client): override caption and entities for sendMedia
This commit is contained in:
parent
cbb8549068
commit
e3b2f747a9
2 changed files with 35 additions and 2 deletions
|
@ -2359,6 +2359,22 @@ export interface TelegramClient extends BaseTelegramClient {
|
|||
chatId: InputPeerLike,
|
||||
media: InputMediaLike | string,
|
||||
params?: {
|
||||
/**
|
||||
* Override caption for `media`.
|
||||
*
|
||||
* Can be used, for example. when using File IDs
|
||||
* or when using existing InputMedia objects.
|
||||
*/
|
||||
caption?: string
|
||||
|
||||
/**
|
||||
* Override entities for `media`.
|
||||
*
|
||||
* Can be used, for example. when using File IDs
|
||||
* or when using existing InputMedia objects.
|
||||
*/
|
||||
entities?: tl.TypeMessageEntity[]
|
||||
|
||||
/**
|
||||
* Message to reply to. Either a message object or message ID.
|
||||
*/
|
||||
|
|
|
@ -11,6 +11,7 @@ import {
|
|||
normalizeMessageId,
|
||||
randomUlong,
|
||||
} from '../../utils/misc-utils'
|
||||
import { tl } from '@mtcute/tl'
|
||||
|
||||
/**
|
||||
* Send a single media (a photo or a document-based media)
|
||||
|
@ -29,6 +30,22 @@ export async function sendMedia(
|
|||
chatId: InputPeerLike,
|
||||
media: InputMediaLike | string,
|
||||
params?: {
|
||||
/**
|
||||
* Override caption for `media`.
|
||||
*
|
||||
* Can be used, for example. when using File IDs
|
||||
* or when using existing InputMedia objects.
|
||||
*/
|
||||
caption?: string
|
||||
|
||||
/**
|
||||
* Override entities for `media`.
|
||||
*
|
||||
* Can be used, for example. when using File IDs
|
||||
* or when using existing InputMedia objects.
|
||||
*/
|
||||
entities?: tl.TypeMessageEntity[]
|
||||
|
||||
/**
|
||||
* Message to reply to. Either a message object or message ID.
|
||||
*/
|
||||
|
@ -102,9 +119,9 @@ export async function sendMedia(
|
|||
// some types dont have `caption` field, and ts warns us,
|
||||
// but since it's JS, they'll just be `undefined` and properly
|
||||
// handled by _parseEntities method
|
||||
(media as any).caption,
|
||||
params.caption || (media as any).caption,
|
||||
params.parseMode,
|
||||
(media as any).entities
|
||||
params.entities || (media as any).entities
|
||||
)
|
||||
|
||||
let peer = await this.resolvePeer(chatId)
|
||||
|
|
Loading…
Reference in a new issue