feat(client): support noforward flag when sending

This commit is contained in:
teidesu 2022-06-21 20:59:25 +03:00
parent 7d71728868
commit 1be12d9917
4 changed files with 52 additions and 3 deletions

View file

@ -95,6 +95,14 @@ export async function forwardMessages(
* Whether to forward without caption (implies {@link noAuthor}) * Whether to forward without caption (implies {@link noAuthor})
*/ */
noCaption?: boolean noCaption?: boolean
/**
* Whether to disallow further forwards of this message.
*
* Only for bots, works even if the target chat does not
* have content protection.
*/
forbidForwards?: boolean
} }
): Promise<Message> ): Promise<Message>
@ -184,6 +192,14 @@ export async function forwardMessages(
* Whether to forward without caption (implies {@link noAuthor}) * Whether to forward without caption (implies {@link noAuthor})
*/ */
noCaption?: boolean noCaption?: boolean
/**
* Whether to disallow further forwards of this message.
*
* Only for bots, works even if the target chat does not
* have content protection.
*/
forbidForwards?: boolean
} }
): Promise<MaybeArray<Message>> ): Promise<MaybeArray<Message>>
@ -258,6 +274,14 @@ export async function forwardMessages(
* Whether to forward without caption (implies {@link noAuthor}) * Whether to forward without caption (implies {@link noAuthor})
*/ */
noCaption?: boolean noCaption?: boolean
/**
* Whether to disallow further forwards of this message.
*
* Only for bots, works even if the target chat does not
* have content protection.
*/
forbidForwards?: boolean
} }
): Promise<MaybeArray<Message>> { ): Promise<MaybeArray<Message>> {
if (!params) params = {} if (!params) params = {}
@ -309,6 +333,7 @@ export async function forwardMessages(
), ),
dropAuthor: params.noAuthor, dropAuthor: params.noAuthor,
dropMediaCaptions: params.noCaption, dropMediaCaptions: params.noCaption,
noforwards: params.forbidForwards
}) })
assertIsUpdatesGroup('messages.forwardMessages', res) assertIsUpdatesGroup('messages.forwardMessages', res)

View file

@ -105,6 +105,14 @@ export async function sendMediaGroup(
* Defaults to `false` * Defaults to `false`
*/ */
clearDraft?: boolean clearDraft?: boolean
/**
* Whether to disallow further forwards of this message.
*
* Only for bots, works even if the target chat does not
* have content protection.
*/
forbidForwards?: boolean
} }
): Promise<Message[]> { ): Promise<Message[]> {
if (!params) params = {} if (!params) params = {}
@ -180,6 +188,7 @@ export async function sendMediaGroup(
scheduleDate: normalizeDate(params.schedule), scheduleDate: normalizeDate(params.schedule),
replyMarkup, replyMarkup,
clearDraft: params.clearDraft, clearDraft: params.clearDraft,
noforwards: params.forbidForwards
}) })
assertIsUpdatesGroup('_findMessageInUpdate', res) assertIsUpdatesGroup('_findMessageInUpdate', res)

View file

@ -114,6 +114,14 @@ export async function sendMedia(
* Defaults to `false` * Defaults to `false`
*/ */
clearDraft?: boolean clearDraft?: boolean
/**
* Whether to disallow further forwards of this message.
*
* Only for bots, works even if the target chat does not
* have content protection.
*/
forbidForwards?: boolean
} }
): Promise<Message> { ): Promise<Message> {
if (!params) params = {} if (!params) params = {}
@ -170,6 +178,7 @@ export async function sendMedia(
message, message,
entities, entities,
clearDraft: params.clearDraft, clearDraft: params.clearDraft,
noforwards: params.forbidForwards
}) })
const msg = this._findMessageInUpdate(res) const msg = this._findMessageInUpdate(res)

View file

@ -101,6 +101,14 @@ export async function sendText(
* Defaults to `false` * Defaults to `false`
*/ */
clearDraft?: boolean clearDraft?: boolean
/**
* Whether to disallow further forwards of this message.
*
* Only for bots, works even if the target chat does not
* have content protection.
*/
forbidForwards?: boolean
} }
): Promise<Message> { ): Promise<Message> {
if (!params) params = {} if (!params) params = {}
@ -146,10 +154,8 @@ export async function sendText(
message, message,
entities, entities,
clearDraft: params.clearDraft, clearDraft: params.clearDraft,
noforwards: params.forbidForwards
}) })
// } catch (e) {
//
// }
if (res._ === 'updateShortSentMessage') { if (res._ === 'updateShortSentMessage') {
const msg: tl.RawMessage = { const msg: tl.RawMessage = {