unpinChatMessage method

Future<bool> unpinChatMessage(
  1. dynamic chatId, {
  2. int? messageId,
})

Use this method to remove a message from the list of pinned messages in a chat

If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'canPinMessages' admin right in a supergroup or 'canEditMessages' admin right in a channel.

Returns True on success.

If messageId not specified, the most recent pinned message (by sending date) will be unpinned.

https://core.telegram.org/bots/api#unpinchatmessage

Implementation

Future<bool> unpinChatMessage(dynamic chatId, {int? messageId}) async {
  if (chatId is! String && chatId is! int) {
    return Future.error(TelegramException(
        'Attribute \'chatId\' can only be either type of String or int'));
  }
  var requestUrl = _apiUri('unpinChatMessage');
  var body = <String, dynamic>{'chat_id': chatId, 'message_id': messageId};
  return await HttpClient.httpPost(requestUrl, body: body);
}