2021-04-11 16:25:17 +03:00
|
|
|
import { TelegramClient } from '../../client'
|
|
|
|
import { InputPeerLike } from '../../types'
|
|
|
|
import { normalizeToInputPeer } from '../../utils/peer-utils'
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pin a message in a group, supergroup, channel or PM.
|
|
|
|
*
|
|
|
|
* For supergroups/channels, you must have appropriate permissions,
|
|
|
|
* either as an admin, or as default permissions
|
|
|
|
*
|
|
|
|
* @param chatId Chat ID, username, phone number, `"self"` or `"me"`
|
|
|
|
* @param messageId Message ID
|
|
|
|
* @param notify Whether to send a notification (only for legacy groups and supergroups)
|
|
|
|
* @param bothSides Whether to pin for both sides (only for private chats)
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
export async function pinMessage(
|
|
|
|
this: TelegramClient,
|
|
|
|
chatId: InputPeerLike,
|
|
|
|
messageId: number,
|
|
|
|
notify = false,
|
|
|
|
bothSides = false
|
|
|
|
): Promise<void> {
|
2021-04-24 16:23:30 +03:00
|
|
|
const res = await this.call({
|
2021-04-11 16:25:17 +03:00
|
|
|
_: 'messages.updatePinnedMessage',
|
|
|
|
peer: normalizeToInputPeer(await this.resolvePeer(chatId)),
|
|
|
|
id: messageId,
|
|
|
|
silent: !notify,
|
|
|
|
pmOneside: !bothSides
|
|
|
|
})
|
2021-04-24 16:23:30 +03:00
|
|
|
|
|
|
|
this._handleUpdate(res)
|
2021-04-11 16:25:17 +03:00
|
|
|
}
|