feat(client): unpinAllMessages method
This commit is contained in:
parent
79a8962284
commit
4f40571455
3 changed files with 37 additions and 1 deletions
|
@ -95,6 +95,7 @@ import { sendMedia } from './methods/messages/send-media'
|
||||||
import { sendText } from './methods/messages/send-text'
|
import { sendText } from './methods/messages/send-text'
|
||||||
import { sendTyping } from './methods/messages/send-typing'
|
import { sendTyping } from './methods/messages/send-typing'
|
||||||
import { sendVote } from './methods/messages/send-vote'
|
import { sendVote } from './methods/messages/send-vote'
|
||||||
|
import { unpinAllMessages } from './methods/messages/unpin-all-messages'
|
||||||
import { unpinMessage } from './methods/messages/unpin-message'
|
import { unpinMessage } from './methods/messages/unpin-message'
|
||||||
import { initTakeoutSession } from './methods/misc/init-takeout-session'
|
import { initTakeoutSession } from './methods/misc/init-takeout-session'
|
||||||
import {
|
import {
|
||||||
|
@ -2313,6 +2314,12 @@ export interface TelegramClient extends BaseTelegramClient {
|
||||||
message: number,
|
message: number,
|
||||||
options: null | MaybeArray<number | Buffer>
|
options: null | MaybeArray<number | Buffer>
|
||||||
): Promise<Poll>
|
): Promise<Poll>
|
||||||
|
/**
|
||||||
|
* Unpin all pinned messages in a chat.
|
||||||
|
*
|
||||||
|
* @param chatId Chat or user ID
|
||||||
|
*/
|
||||||
|
unpinAllMessages(chatId: InputPeerLike): Promise<void>
|
||||||
/**
|
/**
|
||||||
* Unpin a message in a group, supergroup, channel or PM.
|
* Unpin a message in a group, supergroup, channel or PM.
|
||||||
*
|
*
|
||||||
|
@ -2937,6 +2944,7 @@ export class TelegramClient extends BaseTelegramClient {
|
||||||
sendText = sendText
|
sendText = sendText
|
||||||
sendTyping = sendTyping
|
sendTyping = sendTyping
|
||||||
sendVote = sendVote
|
sendVote = sendVote
|
||||||
|
unpinAllMessages = unpinAllMessages
|
||||||
unpinMessage = unpinMessage
|
unpinMessage = unpinMessage
|
||||||
initTakeoutSession = initTakeoutSession
|
initTakeoutSession = initTakeoutSession
|
||||||
registerParseMode = registerParseMode
|
registerParseMode = registerParseMode
|
||||||
|
|
|
@ -31,7 +31,7 @@ export async function deleteMessages(
|
||||||
channel,
|
channel,
|
||||||
id: ids
|
id: ids
|
||||||
})
|
})
|
||||||
upd = createDummyUpdate(res.pts, res.ptsCount, (channel as tl.RawInputChannel).channelId)
|
upd = createDummyUpdate(res.pts, res.ptsCount, peer.channelId)
|
||||||
} else {
|
} else {
|
||||||
const res = await this.call({
|
const res = await this.call({
|
||||||
_: 'messages.deleteMessages',
|
_: 'messages.deleteMessages',
|
||||||
|
|
28
packages/client/src/methods/messages/unpin-all-messages.ts
Normal file
28
packages/client/src/methods/messages/unpin-all-messages.ts
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
import { TelegramClient } from '../../client'
|
||||||
|
import { InputPeerLike } from '../../types'
|
||||||
|
import { isInputPeerChannel, normalizeToInputPeer } from '../../utils/peer-utils'
|
||||||
|
import { createDummyUpdate } from '../../utils/updates-utils'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unpin all pinned messages in a chat.
|
||||||
|
*
|
||||||
|
* @param chatId Chat or user ID
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
export async function unpinAllMessages(
|
||||||
|
this: TelegramClient,
|
||||||
|
chatId: InputPeerLike
|
||||||
|
): Promise<void> {
|
||||||
|
const peer = normalizeToInputPeer(await this.resolvePeer(chatId))
|
||||||
|
|
||||||
|
const res = await this.call({
|
||||||
|
_: 'messages.unpinAllMessages',
|
||||||
|
peer
|
||||||
|
})
|
||||||
|
|
||||||
|
if (isInputPeerChannel(peer)) {
|
||||||
|
this._handleUpdate(createDummyUpdate(res.pts, res.ptsCount, peer.channelId))
|
||||||
|
} else {
|
||||||
|
createDummyUpdate(res.pts, res.ptsCount)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue