pinChatMessage method

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

Use this method to pin a message in a supergroup or a channel

The bot must be an administrator in the chat for this to work and must have the ‘canPinMessages’ admin right in the supergroup or ‘canEditMessages’ admin right in the channel.

Returns True on success.

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

Implementation

Future<bool> pinChatMessage(dynamic chatId, int messageId,
    {bool? disableNotification}) 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('pinChatMessage');
  var body = <String, dynamic>{
    'chat_id': chatId,
    'message_id': messageId,
    'disable_notification': disableNotification,
  };
  return await HttpClient.httpPost(requestUrl, body: body);
}