TelegramBot/TelegramBot/Requests/Available methods/Messages/CopyMessageRequest.cs
2026-08-03 22:52:44 +02:00

118 lines
4.1 KiB
C#

using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Telegram.Bot.Requests.Abstractions;
using Telegram.Bot.Types;
using Telegram.Bot.Types.Enums;
using Telegram.Bot.Types.ReplyMarkups;
// ReSharper disable once CheckNamespace
namespace Telegram.Bot.Requests {
/// <summary>
/// Use this method to copy messages of any kind. Service messages and invoice messages can't be copied.
/// The method is analogous to the method <see cref="ForwardMessageRequest"/>, but the copied message
/// doesn't have a link to the original message. Returns the <see cref="Types.MessageId"/> of the
/// sent <see cref="Message"/> on success.
/// </summary>
[JsonObject(MemberSerialization.OptIn, NamingStrategyType = typeof(SnakeCaseNamingStrategy))]
public class CopyMessageRequest : RequestBase<MessageId>, IChatTargetable {
/// <summary>
/// Unique identifier for the target chat or username of the target channel
/// (in the format <c>@channelusername</c>)
/// </summary>
[JsonProperty(Required = Required.Always)]
public ChatId ChatId {
get;
}
/// <summary>
/// Unique identifier for the chat where the original message was sent
/// (or channel username in the format <c>@channelusername</c>)
/// </summary>
[JsonProperty(Required = Required.Always)]
public ChatId FromChatId {
get;
}
/// <summary>
/// Message identifier in the chat specified in <see cref="FromChatId"/>
/// </summary>
[JsonProperty(Required = Required.Always)]
public int MessageId {
get;
}
/// <summary>
/// New caption for media, 0-1024 characters after entities parsing.
/// If not specified, the original caption is kept
/// </summary>
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public string? Caption {
get; set;
}
/// <inheritdoc cref="Abstractions.Documentation.ParseMode"/>
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public ParseMode? ParseMode {
get; set;
}
/// <inheritdoc cref="Abstractions.Documentation.CaptionEntities"/>
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public IEnumerable<MessageEntity>? CaptionEntities {
get; set;
}
/// <inheritdoc cref="Abstractions.Documentation.DisableNotification"/>
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool? DisableNotification {
get; set;
}
/// <inheritdoc cref="Abstractions.Documentation.ProtectContent"/>
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool? ProtectContent {
get; set;
}
/// <inheritdoc cref="Abstractions.Documentation.ReplyToMessageId"/>
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public int? ReplyToMessageId {
get; set;
}
/// <inheritdoc cref="Abstractions.Documentation.AllowSendingWithoutReply"/>
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool? AllowSendingWithoutReply {
get; set;
}
/// <inheritdoc cref="Abstractions.Documentation.ReplyMarkup"/>
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public IReplyMarkup? ReplyMarkup {
get; set;
}
/// <summary>
/// Initializes a new request with chatId, fromChatId and messageId
/// </summary>
/// <param name="chatId">Unique identifier for the target chat or username of the target channel
/// (in the format <c>@channelusername</c>)
/// </param>
/// <param name="fromChatId">
/// Unique identifier for the chat where the original message was sent
/// (or channel username in the format <c>@channelusername</c>)
/// </param>
/// <param name="messageId">
/// Message identifier in the chat specified in <see cref="FromChatId"/>
/// </param>
public CopyMessageRequest(ChatId chatId, ChatId fromChatId, int messageId)
: base("copyMessage") {
ChatId = chatId;
FromChatId = fromChatId;
MessageId = messageId;
}
}
}