| | | 1 | | using Newtonsoft.Json; |
| | | 2 | | |
| | | 3 | | namespace Services.ApiServices.TelegramBotApi.Models; |
| | | 4 | | |
| | | 5 | | /// <summary>Конверт ответа Bot API: <c>ok</c> + <c>result</c> либо <c>description</c>/<c>error_code</c>.</summary> |
| | | 6 | | public class TelegramEnvelope<T> |
| | | 7 | | { |
| | | 8 | | [JsonProperty("ok")] public bool Ok { get; set; } |
| | | 9 | | [JsonProperty("result")] public T? Result { get; set; } |
| | | 10 | | [JsonProperty("description")] public string? Description { get; set; } |
| | | 11 | | [JsonProperty("error_code")] public int? ErrorCode { get; set; } |
| | | 12 | | } |
| | | 13 | | |
| | | 14 | | public class TelegramBotInfo |
| | | 15 | | { |
| | | 16 | | [JsonProperty("id")] public long Id { get; set; } |
| | | 17 | | [JsonProperty("username")] public string? Username { get; set; } |
| | | 18 | | [JsonProperty("first_name")] public string? FirstName { get; set; } |
| | | 19 | | } |
| | | 20 | | |
| | | 21 | | public class TelegramSentMessage |
| | | 22 | | { |
| | | 23 | | [JsonProperty("message_id")] public long MessageId { get; set; } |
| | | 24 | | } |
| | | 25 | | |
| | | 26 | | public class TelegramChat |
| | | 27 | | { |
| | | 28 | | [JsonProperty("id")] public long Id { get; set; } |
| | | 29 | | [JsonProperty("type")] public string? Type { get; set; } |
| | | 30 | | [JsonProperty("title")] public string? Title { get; set; } |
| | | 31 | | [JsonProperty("username")] public string? Username { get; set; } |
| | | 32 | | } |
| | | 33 | | |
| | | 34 | | public class TelegramUser |
| | | 35 | | { |
| | | 36 | | [JsonProperty("id")] public long Id { get; set; } |
| | | 37 | | [JsonProperty("is_bot")] public bool IsBot { get; set; } |
| | | 38 | | } |
| | | 39 | | |
| | | 40 | | /// <summary>Ответ <c>getChat</c>: нужен закреплённый пост (если он есть).</summary> |
| | | 41 | | public class TelegramChatInfo |
| | | 42 | | { |
| | 0 | 43 | | [JsonProperty("id")] public long Id { get; set; } |
| | 0 | 44 | | [JsonProperty("pinned_message")] public TelegramIncomingMessage? PinnedMessage { get; set; } |
| | | 45 | | } |
| | | 46 | | |
| | | 47 | | public class TelegramIncomingMessage |
| | | 48 | | { |
| | | 49 | | [JsonProperty("from")] public TelegramUser? From { get; set; } |
| | | 50 | | [JsonProperty("message_id")] public long MessageId { get; set; } |
| | | 51 | | [JsonProperty("chat")] public TelegramChat? Chat { get; set; } |
| | | 52 | | [JsonProperty("text")] public string? Text { get; set; } |
| | | 53 | | } |
| | | 54 | | |
| | | 55 | | public class TelegramUpdate |
| | | 56 | | { |
| | | 57 | | [JsonProperty("update_id")] public long UpdateId { get; set; } |
| | | 58 | | [JsonProperty("message")] public TelegramIncomingMessage? Message { get; set; } |
| | | 59 | | } |
| | | 60 | | |
| | | 61 | | public class SendMessageRequest |
| | | 62 | | { |
| | | 63 | | [JsonProperty("chat_id")] public long ChatId { get; set; } |
| | | 64 | | [JsonProperty("message_thread_id", NullValueHandling = NullValueHandling.Ignore)] public int? MessageThreadId { get; |
| | | 65 | | [JsonProperty("text")] public string Text { get; set; } = ""; |
| | | 66 | | [JsonProperty("parse_mode", NullValueHandling = NullValueHandling.Ignore)] public string? ParseMode { get; set; } |
| | | 67 | | [JsonProperty("disable_notification")] public bool DisableNotification { get; set; } |
| | | 68 | | [JsonProperty("disable_web_page_preview")] public bool DisableWebPagePreview { get; set; } = true; |
| | | 69 | | } |
| | | 70 | | |
| | | 71 | | public class SendPhotoRequest |
| | | 72 | | { |
| | | 73 | | [JsonProperty("chat_id")] public long ChatId { get; set; } |
| | | 74 | | [JsonProperty("message_thread_id", NullValueHandling = NullValueHandling.Ignore)] public int? MessageThreadId { get; |
| | | 75 | | [JsonProperty("photo")] public string Photo { get; set; } = ""; |
| | | 76 | | [JsonProperty("caption", NullValueHandling = NullValueHandling.Ignore)] public string? Caption { get; set; } |
| | | 77 | | [JsonProperty("parse_mode", NullValueHandling = NullValueHandling.Ignore)] public string? ParseMode { get; set; } |
| | | 78 | | [JsonProperty("disable_notification")] public bool DisableNotification { get; set; } |
| | | 79 | | } |
| | | 80 | | |
| | | 81 | | public class EditMessageTextRequest |
| | | 82 | | { |
| | | 83 | | [JsonProperty("chat_id")] public long ChatId { get; set; } |
| | | 84 | | [JsonProperty("message_id")] public long MessageId { get; set; } |
| | | 85 | | [JsonProperty("text")] public string Text { get; set; } = ""; |
| | | 86 | | [JsonProperty("parse_mode", NullValueHandling = NullValueHandling.Ignore)] public string? ParseMode { get; set; } |
| | | 87 | | [JsonProperty("disable_web_page_preview")] public bool DisableWebPagePreview { get; set; } = true; |
| | | 88 | | } |
| | | 89 | | |
| | | 90 | | public class PinChatMessageRequest |
| | | 91 | | { |
| | | 92 | | [JsonProperty("chat_id")] public long ChatId { get; set; } |
| | | 93 | | [JsonProperty("message_id")] public long MessageId { get; set; } |
| | | 94 | | [JsonProperty("disable_notification")] public bool DisableNotification { get; set; } = true; |
| | | 95 | | } |
| | | 96 | | |
| | | 97 | | public class UnpinChatMessageRequest |
| | | 98 | | { |
| | | 99 | | [JsonProperty("chat_id")] public long ChatId { get; set; } |
| | | 100 | | [JsonProperty("message_id")] public long MessageId { get; set; } |
| | | 101 | | } |