replyWithPhoto method

Future<Message> replyWithPhoto(
  1. InputFile photo, {
  2. int? messageThreadId,
  3. String? caption,
  4. ParseMode? parseMode,
  5. List<MessageEntity>? captionEntities,
  6. bool? disableNotification,
  7. bool? protectContent,
  8. ReplyMarkup? replyMarkup,
  9. bool? hasSpoiler,
  10. ReplyParameters? replyParameters,
  11. String? businessConnectionId,
  12. String? messageEffectId,
  13. bool? showCaptionAboveMedia,
  14. bool? allowPaidBroadcast,
  15. int? directMessagesTopicId,
  16. SuggestedPostParameters? suggestedPostParameters,
})

Replies to the current message with a photo.

This is a convenience method that sends a photo to the same chat where the current update originated from.

Parameters:

  • photo: Photo to send (InputFile)
  • caption: Photo caption (0-1024 characters)
  • parseMode: Mode for parsing entities in the photo caption
  • captionEntities: List of special entities that appear in the caption
  • disableNotification: Sends the message silently
  • protectContent: Protects the contents from forwarding and saving
  • replyParameters: Description of the message to reply to
  • replyMarkup: Additional interface options
  • hasSpoiler: Pass True if the photo needs to be covered with a spoiler animation

Returns the sent Message.

Throws TeleverseException if there's no chat to reply to.

Example:

final photo = InputFile.fromFile(File('photo.jpg'));
await ctx.replyWithPhoto(photo, caption: 'Beautiful sunset! 🌅');

Implementation

Future<Message> replyWithPhoto(
  InputFile photo, {
  int? messageThreadId,
  String? caption,
  ParseMode? parseMode,
  List<MessageEntity>? captionEntities,
  bool? disableNotification,
  bool? protectContent,
  ReplyMarkup? replyMarkup,
  bool? hasSpoiler,
  ReplyParameters? replyParameters,
  String? businessConnectionId,
  String? messageEffectId,
  bool? showCaptionAboveMedia,
  bool? allowPaidBroadcast,
  int? directMessagesTopicId,
  SuggestedPostParameters? suggestedPostParameters,
}) async {
  final chatId = _getChatId();
  _verifyInfo([chatId], APIMethod.sendPhoto);

  return api.sendPhoto(
    chatId!,
    photo,
    messageThreadId: _threadId(messageThreadId),
    caption: caption,
    parseMode: parseMode,
    captionEntities: captionEntities,
    disableNotification: disableNotification,
    protectContent: protectContent,
    replyMarkup: replyMarkup,
    hasSpoiler: hasSpoiler,
    replyParameters: replyParameters,
    businessConnectionId: _businessConnectionId(businessConnectionId),
    messageEffectId: messageEffectId,
    showCaptionAboveMedia: showCaptionAboveMedia,
    allowPaidBroadcast: allowPaidBroadcast,
    directMessagesTopicId: directMessagesTopicId,
    suggestedPostParameters: suggestedPostParameters,
  );
}