refactor uncompleted works exists in Bot Service ...

This commit is contained in:
2026-11-12 20:17:51 +03:30
parent d3b5ba622f
commit fa59823008
16 changed files with 1567 additions and 111 deletions
+24
View File
@@ -20,10 +20,34 @@ namespace xBotService.Models.Dtos
/// <value></value>
public virtual XPersonDto User { get; set; } = null;
/// <summary>
/// Check Bot User is Verified or not ...
/// </summary>
/// <value></value>
public bool Verified { get; set; }
/// <summary>
/// Bot User Id ...
/// </summary>
/// <value></value>
public long BotUserId { get; set; }
/// <summary>
/// Chat Bot User Name ...
/// </summary>
/// <value></value>
public string BotUserName { get; set; }
/// <summary>
/// Bot Last Name ...
/// </summary>
/// <value></value>
public string BotLastname { get; set; }
/// <summary>
/// Bot First Name ...
/// </summary>
/// <value></value>
public string BotFirstname { get; set; }
}
}
+24
View File
@@ -13,10 +13,34 @@ namespace xBotService.Models.Entities
/// <value></value>
public string UserId { get; set; }
/// <summary>
/// Check Bot User is Verified or not ...
/// </summary>
/// <value></value>
public bool Verified { get; set; }
/// <summary>
/// Bot User Id ...
/// </summary>
/// <value></value>
public long BotUserId { get; set; }
/// <summary>
/// Chat Bot User Name ...
/// </summary>
/// <value></value>
public string BotUserName { get; set; }
/// <summary>
/// Bot Last Name ...
/// </summary>
/// <value></value>
public string BotLastname { get; set; }
/// <summary>
/// Bot First Name ...
/// </summary>
/// <value></value>
public string BotFirstname { get; set; }
}
}
-73
View File
@@ -1,73 +0,0 @@
using System.Collections.Generic;
namespace xBotService.Models
{
public class XBotMessageRequest
{
public long ChatId { get; set; }
public string Text { get; set; }
public string ParseMode { get; set; }
public XBotReplyMarkup ReplyMarkup { get; set; }
}
public class XBotReplyMarkup
{
public List<List<XBotInlineButton>> InlineKeyboard { get; set; }
}
public class XBotInlineButton
{
public string Text { get; set; }
public string Url { get; set; }
public string CallbackData { get; set; }
}
public class XBotMessageResponse
{
public bool Ok { get; set; }
public string Description { get; set; }
public XBotResMessage Result { get; set; }
}
public class XBotResMessage
{
public long Date { get; set; }
public string Text { get; set; }
public long MessageId { get; set; }
public XBotResUser From { get; set; }
public XBotResChat Chat { get; set; }
}
public class XBotResUser
{
public long Id { get; set; }
public bool IsBot { get; set; }
public string LastName { get; set; }
public string Username { get; set; }
public string FirstName { get; set; }
}
public class XBotResChat
{
public long Id { get; set; }
public string Type { get; set; }
public string Title { get; set; }
public string Username { get; set; }
public string FirstName { get; set; }
}
public class XBotUpdate
{
public long UpdateId { get; set; }
public XBotResMessage Message { get; set; }
public XBotCallbackQuery CallbackQuery { get; set; }
}
public class XBotCallbackQuery
{
public string Id { get; set; }
public string Data { get; set; }
public XBotResUser From { get; set; }
public XBotResMessage Message { get; set; }
}
}
+350
View File
@@ -0,0 +1,350 @@
using System;
using Newtonsoft.Json;
using xCommons.Extensions;
using System.Collections.Generic;
namespace xBotService.Models
{
/// <summary>
/// Represent XBot Response User ...
/// </summary>
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; }
}
/// <summary>
/// Base Bot Response ...
/// </summary>
public class XBotResponse : XBotResponse<object>
{ }
/// <summary>
/// Base Bot Response ...
/// </summary>
/// <typeparam name="T"></typeparam>
public class XBotResponse<T>
{
public bool Ok { get; set; }
public T Result { get; set; }
}
/// <summary>
/// Bot Update Request ...
/// </summary>
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;
}
/// <summary>
/// Represent an Event in Bot ...
/// </summary>
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;
}
}
/// <summary>
/// Represent a Bot MEssage ...
/// </summary>
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<object> 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<object> 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<object> 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<XBotResUser> 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;
}
}
/// <summary>
/// a Callbacked From a Inline Keyboard ...
/// </summary>
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; }
}
/// <summary>
/// Bot Message Send Request ...
/// </summary>
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; }
}
/// <summary>
/// Bot Message Send Request ...
/// </summary>
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; }
}
}