using System; using Newtonsoft.Json; using xCommons.Extensions; using System.Collections.Generic; namespace xBotService.Models { /// /// Represent XBot Response User ... /// public class XBotResUser { [JsonProperty("id", NullValueHandling = NullValueHandling.Ignore)] public long Id { get; set; } [JsonProperty("is_bot", NullValueHandling = NullValueHandling.Ignore)] public bool IsBot { get; set; } [JsonProperty("last_name", NullValueHandling = NullValueHandling.Ignore)] public string LastName { get; set; } [JsonProperty("username", NullValueHandling = NullValueHandling.Ignore)] public string Username { get; set; } [JsonProperty("first_name", NullValueHandling = NullValueHandling.Ignore)] public string FirstName { get; set; } [JsonProperty("language_code", NullValueHandling = NullValueHandling.Ignore)] public string LanguageCode { get; set; } [JsonProperty("has_main_web_app", NullValueHandling = NullValueHandling.Ignore)] public string HasMainWebApp { get; set; } [JsonProperty("has_topics_enabled", NullValueHandling = NullValueHandling.Ignore)] public bool HasTopicsEnabled { get; set; } [JsonProperty("allows_users_to_create_topics", NullValueHandling = NullValueHandling.Ignore)] public bool AllowsUsersToCreateTopics { get; set; } } /// /// Base Bot Response ... /// public class XBotResponse : XBotResponse { } /// /// Base Bot Response ... /// /// public class XBotResponse { public bool Ok { get; set; } public T Result { get; set; } } /// /// Bot Update Request ... /// public class XBotUpdatesRequest { [JsonProperty("limit")] public int Limit { get; set; } = 100; [JsonProperty("offset")] public long Offset { get; set; } = 0; [JsonProperty("timeout")] public int Timeout { get; set; } = 30; } /// /// Represent an Event in Bot ... /// public class XBotUpdateResponse { [JsonProperty("update_id", NullValueHandling = NullValueHandling.Ignore)] public long UpdateId { get; set; } [JsonProperty("message", NullValueHandling = NullValueHandling.Ignore)] public XBotMessage Message { get; set; } [JsonProperty("edited_message", NullValueHandling = NullValueHandling.Ignore)] public XBotMessage EditedMessage { get; set; } [JsonProperty("callback_query", NullValueHandling = NullValueHandling.Ignore)] public XBotCallbackQuery CallbackQuery { get; set; } [JsonProperty("pre_checkout_query", NullValueHandling = NullValueHandling.Ignore)] public object PreCheckoutQuery { get; set; } public override string ToString() { // var result = string.Empty; if (this.IsNull()) { return result; } // result = $"{nameof(XBotUpdateResponse)}:{Environment.NewLine}"; result += $"{nameof(UpdateId)}: {UpdateId}{Environment.NewLine}"; result += $"{nameof(Message)}: {Message}{Environment.NewLine}"; result += $"{nameof(EditedMessage)}: {EditedMessage}{Environment.NewLine}"; // return result; } } /// /// Represent a Bot MEssage ... /// public class XBotMessage { [JsonProperty("message_id", NullValueHandling = NullValueHandling.Ignore)] public long MessageId { get; set; } [JsonProperty("message_thread_id", NullValueHandling = NullValueHandling.Ignore)] public long MessageThreadId { get; set; } [JsonProperty("from", NullValueHandling = NullValueHandling.Ignore)] public XBotResUser From { get; set; } [JsonProperty("date", NullValueHandling = NullValueHandling.Ignore)] public long Date { get; set; } [JsonProperty("chat", NullValueHandling = NullValueHandling.Ignore)] public object Chat { get; set; } [JsonProperty("sender_chat", NullValueHandling = NullValueHandling.Ignore)] public object SenderChat { get; set; } [JsonProperty("forward_from", NullValueHandling = NullValueHandling.Ignore)] public XBotResUser ForwardFrom { get; set; } [JsonProperty("forward_from_chat", NullValueHandling = NullValueHandling.Ignore)] public object ForwardFromChat { get; set; } [JsonProperty("forward_from_message_id", NullValueHandling = NullValueHandling.Ignore)] public long ForwardFromMessageId { get; set; } [JsonProperty("forward_date", NullValueHandling = NullValueHandling.Ignore)] public long ForwardDate { get; set; } [JsonProperty("reply_to_message", NullValueHandling = NullValueHandling.Ignore)] public XBotMessage ReplyToMessage { get; set; } [JsonProperty("edit_date", NullValueHandling = NullValueHandling.Ignore)] public long EditDate { get; set; } [JsonProperty("media_group_id", NullValueHandling = NullValueHandling.Ignore)] public string MediaGroupId { get; set; } [JsonProperty("text", NullValueHandling = NullValueHandling.Ignore)] public string Text { get; set; } [JsonProperty("entities", NullValueHandling = NullValueHandling.Ignore)] public IList Entities { get; set; } [JsonProperty("animation", NullValueHandling = NullValueHandling.Ignore)] public object Animation { get; set; } [JsonProperty("audio", NullValueHandling = NullValueHandling.Ignore)] public object Audio { get; set; } [JsonProperty("document", NullValueHandling = NullValueHandling.Ignore)] public object Document { get; set; } [JsonProperty("photo", NullValueHandling = NullValueHandling.Ignore)] public IList Photo { get; set; } [JsonProperty("sticker", NullValueHandling = NullValueHandling.Ignore)] public object Sticker { get; set; } [JsonProperty("video", NullValueHandling = NullValueHandling.Ignore)] public object Video { get; set; } [JsonProperty("voice", NullValueHandling = NullValueHandling.Ignore)] public object Voice { get; set; } [JsonProperty("caption", NullValueHandling = NullValueHandling.Ignore)] public string Caption { get; set; } [JsonProperty("caption_entities", NullValueHandling = NullValueHandling.Ignore)] public IList CaptionEntities { get; set; } [JsonProperty("contact", NullValueHandling = NullValueHandling.Ignore)] public object Contact { get; set; } [JsonProperty("location", NullValueHandling = NullValueHandling.Ignore)] public object Location { get; set; } [JsonProperty("new_chat_members", NullValueHandling = NullValueHandling.Ignore)] public IList NewChatMembers { get; set; } [JsonProperty("left_chat_member", NullValueHandling = NullValueHandling.Ignore)] public XBotResUser LeftChatMember { get; set; } [JsonProperty("invoice", NullValueHandling = NullValueHandling.Ignore)] public object Invoice { get; set; } [JsonProperty("successful_payment", NullValueHandling = NullValueHandling.Ignore)] public object SuccessfulPayment { get; set; } [JsonProperty("web_app_data", NullValueHandling = NullValueHandling.Ignore)] public object WebAppData { get; set; } [JsonProperty("reply_markup", NullValueHandling = NullValueHandling.Ignore)] public object ReplyMarkup { get; set; } [JsonProperty("forum_topic_created", NullValueHandling = NullValueHandling.Ignore)] public object ForumTopicCreated { get; set; } public override string ToString() { // if (this.IsNull()) { return string.Empty; } // var from = !From.IsNull() ? nameof(From) + ":" + From.Id + "," + From.Username + From.FirstName + From.LastName : string.Empty; var result = $""" {nameof(MessageId)}: {MessageId}, {Environment.NewLine} {nameof(Text)}: {Text}, {Environment.NewLine} """; if (!from.IsNullOrEmpty()) { result += from + Environment.NewLine; } // return result; } } /// /// a Callbacked From a Inline Keyboard ... /// public class XBotCallbackQuery { [JsonProperty("id", NullValueHandling = NullValueHandling.Ignore)] public string Id { get; set; } [JsonProperty("data", NullValueHandling = NullValueHandling.Ignore)] public string Data { get; set; } [JsonProperty("from", NullValueHandling = NullValueHandling.Ignore)] public XBotResUser User { get; set; } [JsonProperty("message", NullValueHandling = NullValueHandling.Ignore)] public XBotMessage Message { get; set; } } /// /// Bot Message Send Request ... /// public class XBotSendMessageRequest { public long ChatId { get; set; } public string Text { get; set; } public object ReplyMarkup { get; set; } public long MessageThreadId { get; set; } public long ReplyToMessageId { get; set; } } /// /// Bot Message Send Request ... /// public class XBotSendMessageRequestDto { [JsonProperty("chat_id", NullValueHandling = NullValueHandling.Ignore)] public long ChatId { get; set; } [JsonProperty("text", NullValueHandling = NullValueHandling.Ignore)] public string Text { get; set; } [JsonProperty("reply_markup", NullValueHandling = NullValueHandling.Ignore)] public object ReplyMarkup { get; set; } [JsonProperty("message_thread_id", NullValueHandling = NullValueHandling.Ignore)] public long MessageThreadId { get; set; } [JsonProperty("reply_to_message_id", NullValueHandling = NullValueHandling.Ignore)] public long ReplyToMessageId { get; set; } } }