diff --git a/Documents/GeneratedContext/xDashboard-xBotService-20261112_220350.txt b/Documents/GeneratedContext/xDashboard-xBotService-20261112_220350.txt new file mode 100644 index 0000000..c4a796a --- /dev/null +++ b/Documents/GeneratedContext/xDashboard-xBotService-20261112_220350.txt @@ -0,0 +1,3079 @@ + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Configuration\XBotServiceConfiguration.cs + +namespace xBotService.Configuration +{ + public class XBotServiceConfiguration + { + /// + /// Bot Required Token ... + /// + public string Token { get; set; } + + /// + /// Base Route of Bot Api ... + /// + public string BaseRoute { get; set; } + + /// + /// Verification Code Time to Live ... + /// + public int VerificationCodeTTL { get; set; } = 300; + + /// + /// Verification Code Length ... + /// + public int VerificationCodeLength { get; set; } = 6; + + /// + /// Default Timeout ... + /// + public int DefaultClientTimeout { get; set; } = 360; + } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Configuration\Entities\XBotUserEntityConfiguration.cs + +using xBotService.Constants; +using xDataService.Providers; +using xBotService.Models.Entities; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace xBotService.Configuration.Entities +{ + public class XBotUserEntityConfiguration: XBaseEntityTypeConfiguration + { + public override void Configure(EntityTypeBuilder builder) + { + builder.ToTable(XBotServiceConstants.XBotUserTable); + } + } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Constants\ConfigurationNodeNames.cs + +namespace xBotService.Constants +{ + public partial struct ConfigurationNodeNames + { + public const string BOT_SERVICE_NODE = "BotServiceConfiguration"; + } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Constants\XBaleBotEndpoints.cs + +using xExceptions.Attributes; + +namespace xBotService.Constants +{ + public enum XBotEndpoints + { + [StringValue("/bot{xBotToken}/getMe")] + GetMe, + + [StringValue("/bot{xBotToken}/getChat")] + GetChat, + + [StringValue("/bot{xBotToken}/sendMessage")] + SendMessage, + + [StringValue("/bot{xBotToken}/getUpdates")] + GetUpdates, + + [StringValue("/bot{xBotToken}/setWebhook")] + SetWebhook, + + [StringValue("/bot{xBotToken}/deleteWebhook")] + DeleteWebhook, + + [StringValue("/bot{xBotToken}/answerCallbackQuery")] + AnswerCallbackQuery, + + [StringValue("/bot{xBotToken}/editMessageReplyMarkup")] + EditMessageReplyMarkup, + } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Constants\XBotMessageParseMode.cs + +using xExceptions.Attributes; + +namespace xBotService.Constants +{ + public enum XBotMessageParseMode + { + [StringValue("HTML")] + Html, + + [StringValue("Markdown")] + Markdown + } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Constants\XBotParams.cs + +namespace xBotService.Constants +{ + public struct XBotParams + { + public const string XLimit = "limit"; + public const string XOffest = "offset"; + public const string XTimeout = "timeout"; + public const string XTokenParam = "{xBotToken}"; + } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Constants\XBotServiceConstants.cs + +namespace xBotService.Constants +{ + public struct XBotServiceConstants + { + // + // Bot Service Log Tag ... + public const string XBotServiceDILogTag = "XBotService"; + + // + // Table Mapping ... + public const string XBotUserTable = "BotUsers"; + + // + // GraphQL Mappings ... + public const string XBotUserSingleName = "botUser"; + public const string XBotUserCollectionName = "botUsers"; + + // + // Hubs ... + public const string XBotUserDtoHub = "botUserDto"; + public const string XBotUserEntityHub = "botUserEntity"; + + // + // Helper Method Names ... + public const string GetXBotUserEFRepositoryDescriptor = "GetXBotUserEFRepositoryDescriptor"; + } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Constants\XBotStyle.cs + +using xExceptions.Attributes; + +namespace xBotService.Constants +{ + public enum XBotStyle + { + [StringValue("primary")] + Primary, + + [StringValue("success")] + Success, + + [StringValue("danger")] + Danger, + } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Controllers\XBotProviderControllerBase.cs + +using System; +using System.Threading; +using xCommons.Providers; +using xBotService.Models; +using xCommons.Extensions; +using xExceptions.Constants; +using xBotService.Interfaces; +using System.Threading.Tasks; +using xCommons.Configurations; +using Microsoft.AspNetCore.Mvc; +using System.Collections.Generic; +using xIdentityService.Interfaces; +using xIdentityService.Controllers; +using Microsoft.Extensions.Logging; + +namespace xBotService.Controllers +{ + public abstract class XBotProviderControllerBase : XBaseIdentityApiV1Controller + { + private readonly IXBotProvider botProvider; + + protected XBotProviderControllerBase( + IXBotProvider botProvider, + ILogger logger, + XAppConfiguration appConfiguration, + IXIdentityProvider identityProvider, + XValidationProvider validationProvider + ) : base( + logger, + appConfiguration, + identityProvider, + validationProvider + ) + { + this.botProvider = botProvider; + } + + // + #region Actions ... + [HttpGet("Me")] + public virtual async Task> GetMe( + CancellationToken cancellationToken = default + ) + { + // + try + { + // + var result = await botProvider.GetMe(cancellationToken); + + // + return Ok(result.ToDynamicObject()); + } + catch (Exception ex) + { + // + var result = GetExceptionActionResult(ex); + return result; + } + } + + [HttpGet("Updates")] + public virtual async Task>> GetUpdates( + [FromQuery] XBotUpdatesRequest request, + CancellationToken cancellationToken = default + ) + { + // + try + { + // + // Validation ... + if (!ModelState.IsValid) + { + XException.InvalidArgs.Throw(); + } + + // + var result = await botProvider.GetUpdates( + requestModel: request, + cancellationToken: cancellationToken + ); + + // + return Ok(result.ToDynamicObject()); + } + catch (Exception ex) + { + // + var result = GetExceptionActionResult(ex); + return result; + } + } + + [HttpPost("Message")] + public virtual async Task> SendMessage( + [FromBody] XBotSendMessageRequest request, + CancellationToken cancellationToken = default + ) + { + // + try + { + // + // Validation ... + if (!ModelState.IsValid) + { + XException.InvalidArgs.Throw(); + } + await ValidationProvider.GroupValidationBuilder() + .AddNotNull(request) + .AddNotEmpty(request.Text) + .AddNotZero(request.ChatId) + .ValidateGroupAsync(); + + // + var result = await botProvider.SendMessage( + requestModel: request, + cancellationToken: cancellationToken + ); + + // + return Ok(result.ToDynamicObject()); + } + catch (Exception ex) + { + // + var result = GetExceptionActionResult(ex); + return result; + } + } + + // [HttpPost("{chatId}/ShowVerificationMenu")] + // public virtual async Task> ShowVerificationMenu( + // [FromRoute] long chatId, + // CancellationToken cancellationToken = default + // ) + // { + // // + // try + // { + // // + // // Validation ... + // if (!ModelState.IsValid) + // { + // XException.InvalidArgs.Throw(); + // } + // if (chatId <= 0) + // { + // XException.InvalidArgs.Throw(); + // } + + // // + // var result = await botProvider.SendVerificationMenu( + // chatId: chatId, + // cancellationToken: cancellationToken + // ); + + // // + // return Ok(result.ToDynamicObject()); + // } + // catch (Exception ex) + // { + // // + // var result = GetExceptionActionResult(ex); + // return result; + // } + // } + + // [HttpPost("{chatId}/SendVerificationCode")] + // public virtual async Task> SendVerificationCode( + // [FromRoute] long chatId, + // [FromQuery] string code, + // [FromQuery] int ttlSeconds, + // CancellationToken cancellationToken = default + // ) + // { + // // + // try + // { + // // + // // Validation ... + // if (!ModelState.IsValid) + // { + // XException.InvalidArgs.Throw(); + // } + // if (chatId <= 0 || code.IsNullOrEmpty() || ttlSeconds < 60) + // { + // XException.InvalidArgs.Throw(); + // } + + // // + // var result = await botProvider.SendVerificationCode( + // code: code, + // chatId: chatId, + // ttlSeconds: ttlSeconds, + // cancellationToken: cancellationToken + // ); + + // // + // return Ok(result.ToDynamicObject()); + // } + // catch (Exception ex) + // { + // // + // var result = GetExceptionActionResult(ex); + // return result; + // } + // } + + // [HttpPost("{id}/AnswerCallback")] + // public virtual async Task> AnswerCallbackQuery( + // [FromRoute] string callbackQueryId, + // [FromQuery] string text = null, + // [FromQuery] bool showAlert = false, + // CancellationToken cancellationToken = default + // ) + // { + // // + // try + // { + // // + // // Validation ... + // if (!ModelState.IsValid || + // callbackQueryId.IsNullOrEmpty()) + // { + // XException.InvalidArgs.Throw(); + // } + + // // + // var result = await botProvider.AnswerCallbackQuery( + // text: text, + // showAlert: showAlert, + // callbackQueryId: callbackQueryId, + // cancellationToken: cancellationToken + // ); + + // // + // return Ok(result.ToDynamicObject()); + // } + // catch (Exception ex) + // { + // // + // var result = GetExceptionActionResult(ex); + // return result; + // } + // } + + // [HttpPost("{chatId}/RemoveInlineKeyboard")] + // public virtual async Task> RemoveInlineKeyboard( + // [FromRoute] long chatId, + // [FromQuery] long messageId, + // CancellationToken cancellationToken = default + // ) + // { + // // + // try + // { + // // + // // Validation ... + // if (!ModelState.IsValid) + // { + // XException.InvalidArgs.Throw(); + // } + // if (chatId <= 0 || messageId <= 0) + // { + // XException.InvalidArgs.Throw(); + // } + + // // + // var result = await botProvider.RemoveInlineKeyboard( + // chatId: chatId, + // messageId: messageId, + // cancellationToken: cancellationToken + // ); + + // // + // return Ok(result.ToDynamicObject()); + // } + // catch (Exception ex) + // { + // // + // var result = GetExceptionActionResult(ex); + // return result; + // } + // } + + // [HttpPost("Webhook")] + // public virtual async Task> SetWebhook( + // [FromQuery] string webhookUrl, + // [FromQuery] string secretToken = null, + // CancellationToken cancellationToken = default + // ) + // { + // // + // try + // { + // // + // // Validation ... + // if (!ModelState.IsValid) + // { + // XException.InvalidArgs.Throw(); + // } + // await ValidationProvider + // .GroupValidationBuilder() + // .AddNotEmpty(webhookUrl) + // .AddUrl(webhookUrl) + // .ValidateGroupAsync(); + + // // + // var result = await botProvider.SetWebhook( + // webhookUrl: webhookUrl, + // secretToken: secretToken, + // cancellationToken: cancellationToken + // ); + + // // + // return Ok(result); + // } + // catch (Exception ex) + // { + // // + // var result = GetExceptionActionResult(ex); + // return result; + // } + // } + #endregion + } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\DI\XDIHelperExtension.cs + +using System; +using xDataService.Db; +using xDataService.DI; +using xPushService.DI; +using xCommons.Helpers; +using xCommons.Extensions; +using xDataService.Models; +using xPushService.Helpers; +using xExceptions.Constants; +using xBotService.Constants; +using xBotService.Providers; +using xDataService.Constants; +using xBotService.Interfaces; +using XBotUserService.Helpers; +using xHttpService.Interfaces; +using xBotService.Configuration; +using xBotService.Providers.Dtos; +using xBotService.Interfaces.Dtos; +using Microsoft.AspNetCore.Builder; +using xBotService.Providers.Entities; +using xBotService.Interfaces.Entities; +using Microsoft.Extensions.Configuration; +using xBotService.Interfaces.Entities.Dtos; +using Microsoft.Extensions.DependencyInjection; +using ConfigurationNodeNames = xBotService.Constants.ConfigurationNodeNames; +using xBotService.Reciever; + +namespace xBotService.DI +{ + public static class XDIHelperExtension + { + /// + /// Retrieve Bot Service Configuration ... + /// + /// + /// + public static XBotServiceConfiguration GetXBotServiceConfiguration( + this IConfiguration source + ) + { + // + var section = source + .GetSection(ConfigurationNodeNames.BOT_SERVICE_NODE); + + // + var result = section.Get(); + if (result.IsNull()) + { + result = new(); + } + + // + return result; + } + + /// + /// Extract Service Configurations and Register it ... + /// + /// + /// + public static void AddXBotServiceConfiguration( + this IServiceCollection source, + IConfiguration configuration + ) + { + // + var config = configuration.GetXBotServiceConfiguration(); + source.AddXBotServiceConfiguration(config); + } + + /// + /// Register Service Configuration ... + /// + /// + /// + public static void AddXBotServiceConfiguration( + this IServiceCollection source, + XBotServiceConfiguration configuration + ) + { + // + if (configuration.IsNullOrDefault()) + { + // + Log("Service Registration faild, Invalid Configuration ..."); + XException.InvalidConfiguration.Throw(); + } + + // + source.AddSingleton(configuration); + Log("Service Configuration, Registered ..."); + } + + /// + /// Register Service ... + /// + /// + /// + /// + /// + public static void AddXBotService( + this IServiceCollection services, + IConfiguration configuration, + XRepositoryType repositoryType, + ServiceLifetime lifeTime = ServiceLifetime.Scoped + ) + { + // + var config = configuration.GetXBotServiceConfiguration(); + + // + AddBotService( + contextType: null, + services: services, + lifeTime: lifeTime, + configuration: config, + repositoryType: repositoryType + ); + } + + /// + /// Register Service with Context ... + /// + /// + /// + /// + /// + /// + public static void AddXBotService( + this IServiceCollection services, + IConfiguration configuration, + XRepositoryType repositoryType, + ServiceLifetime lifeTime = ServiceLifetime.Scoped + ) where TContext : XDbContext + { + // + var config = configuration.GetXBotServiceConfiguration(); + + // + AddBotService( + services: services, + lifeTime: lifeTime, + configuration: config, + contextType: typeof(TContext), + repositoryType: repositoryType + ); + } + + /// + /// Register Service ... + /// + /// + /// + /// + /// + public static void AddXBotService( + this IServiceCollection services, + XBotServiceConfiguration configuration, + XRepositoryType repositoryType, + ServiceLifetime lifeTime = ServiceLifetime.Scoped + ) + { + // + AddBotService( + contextType: null, + services: services, + lifeTime: lifeTime, + configuration: configuration, + repositoryType: repositoryType + ); + } + + /// + /// Register Service with Context ... + /// + /// + /// + /// + /// + /// + public static void AddXBotService( + this IServiceCollection services, + XBotServiceConfiguration configuration, + XRepositoryType repositoryType, + ServiceLifetime lifeTime = ServiceLifetime.Scoped + ) where TContext : XDbContext + { + // + AddBotService( + services: services, + lifeTime: lifeTime, + configuration: configuration, + contextType: typeof(TContext), + repositoryType: repositoryType + ); + } + + /// + /// Use XBotService Middleware ... + /// + /// + /// + public static void UseXBotService( + this IApplicationBuilder app, + bool isDevelopmentEnvironment = false + ) + { + // + #region Using XTag Hubs ... + // + var pushHelper = new XPushServiceHelper(); + + // + pushHelper.AddHub(XBotServiceConstants.XBotUserDtoHub); + pushHelper.AddHub(XBotServiceConstants.XBotUserEntityHub); + + // + app.UseXPushService(pushHelper); + #endregion + + // + // Using XBotUser Repository Descriptor ... + if (!botUserDescriptor.IsNull()) + { + // + app.UseXRepository( + descriptor: botUserDescriptor, + isDevelopmentEnvironment: isDevelopmentEnvironment + ); + } + } + + // + #region Private ... + private static XRepositoryDescriptor botUserDescriptor = null; + private static string XLogTag = XBotServiceConstants.XBotServiceDILogTag; + + private static void Log(string message) + { + Console.WriteLine($"{XLogTag} => {message}"); + } + + private static void AddBotService( + IServiceCollection services, + XBotServiceConfiguration configuration, + XRepositoryType repositoryType, + Type contextType = null, + ServiceLifetime lifeTime = ServiceLifetime.Scoped + ) + { + // + var exception = XException.InvalidArgs.ToException(); + + // + // Validate Services + if (services.IsNull()) + { + // + Log("Service Registration failed, services not provided ..."); + throw exception; + } + + // + // Check Requirements ... + var httpService = services.GetRegisteredService(); + if (httpService.IsNull()) + { + // + Log("Service Registration failed, HttpService not provided ..."); + throw exception; + } + + // + // Validate Configuration ... + services.AddXBotServiceConfiguration(configuration); + + // + // Validate Repository Type + var isRepositoryTypeValid = + (repositoryType == XRepositoryType.EF && !contextType.IsNull()) || + ((repositoryType == XRepositoryType.Mongo || repositoryType == XRepositoryType.InMemory) && contextType.IsNull()); + if (!isRepositoryTypeValid) + { + // + Log("Service Registration failed, Invalid Repository Type and Context Type ..."); + throw exception; + } + + // + // Make Instance of Repository Descriptor ... + switch (repositoryType) + { + // + case XRepositoryType.EF: + botUserDescriptor = typeof(XBotServiceHelper) + .InvokeGenericMethod( + args: null, + runtimeType: contextType, + methodName: XBotServiceConstants.GetXBotUserEFRepositoryDescriptor + ); + break; + + // + case XRepositoryType.Mongo: + botUserDescriptor = XBotServiceHelper.GetXBotUserMongoRepositoryDescriptor(); + break; + + // + case XRepositoryType.InMemory: + botUserDescriptor = XBotServiceHelper.GetXBotUserInMemoryRepositoryDescriptor(); + break; + } + + // + // Register XBotUser Repository Descriptor ... + services.AddXRepository( + lifeTime: lifeTime, + descriptor: botUserDescriptor + ); + + // + // Register Dto Services ... + services.Add( + new ServiceDescriptor(typeof(IXBotUserServiceProvider), typeof(XBotUserServiceProvider), lifeTime) + ); + services.Add( + new ServiceDescriptor(typeof(IXBotUserRepositoryService), typeof(XBotUserRepositoryService), lifeTime) + ); + services.Add( + new ServiceDescriptor(typeof(IXBotUserRepositoryProvider), typeof(XBotUserRepositoryProvider), lifeTime) + ); + + // + // Bot Provider Registration ... + services.Add( + new ServiceDescriptor(typeof(IXBotProvider), typeof(XBotProvider), lifeTime) + ); + + // + // Using Bot Update Reciever ... + services.AddXBackgroundService(); + + // + Log("Service Registration Succeed ..."); + } + #endregion + } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Extensions\XBotServiceExtensions.cs + +using xBotService.Models; +using xCommons.Extensions; +using xExceptions.Constants; + +namespace xBotService.Extensions +{ + public static class XBotServiceExtensions + { + /// + /// Make Sure a Response Message is Valid ... + /// + /// + public static void EnsureBotResponseSucceed( + this XBotResponse source + ) + { + // + var isValid = + !source.IsNull() && + source.Ok; + if (!isValid) + { + XException.ActionFailed.Throw(); + } + } + + /// + /// Validate a Message Send Request ... + /// + /// + /// + public static bool IsValid( + this XBotSendMessageRequest source + ) + { + // + var result = + !source.IsNull() && + source.ChatId > 0; + + // + return result; + } + + /// + /// Normalize ot Update Request ... + /// + /// + /// + public static XBotUpdatesRequest Normalize( + this XBotUpdatesRequest source + ) + { + // + if (source.IsNull()) + { + source = new(); + } + + // + // Limit ... + if (source.Limit <= 0 || source.Limit > 100) + { + source.Limit = 100; + } + + // + if (source.Offset < 0) + { + source.Offset = 0; + } + + // + if (source.Timeout <= 30) + { + source.Timeout = 30; + } + + // + return source; + } + + /// + /// Converts To Dto ... + /// + /// + /// + public static XBotSendMessageRequestDto ToDto( + this XBotSendMessageRequest source + ) + { + // + XBotSendMessageRequestDto result = null; + if (source.IsNull()) + { + return result; + } + + // + result = new(); + result.UpdateData(source); + + // + return result; + } + } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Helper\XBotServiceHelper.cs + +using GraphQL.Types; +using xDataService.Db; +using xDataService.Models; +using xDataService.Providers; +using xBotService.Models.Entities; +using xBotService.Providers.GraphQL; +using xBotService.Providers.Entities; +using xBotService.Interfaces.Entities; + +namespace XBotUserService.Helpers +{ + public static class XBotServiceHelper + { + // + #region EF Repository Descriptor Provider(s) ... + public static XEFRepositoryDescriptor< + XBotUser, + int, + IXBotUserKeyGenerator, + XBotUserKeyGenerator, + IXBotUserRepositoryEvents, + XBotUserRepositoryEvents, + XBotUserGraphType, + IntGraphType, + XBotUserGraphQuery, + IXBotUserGraphQLTypeHelper, + XBotUserGraphQLTypeHelper, + XBotUserGraphSchema, + IXBotUserRepository, + XBotUserEFRepository, + TContext + > GetXBotUserEFRepositoryDescriptor() + where TContext : XDbContext + { + // + var result = new XEFRepositoryDescriptor< + XBotUser, + int, + IXBotUserKeyGenerator, + XBotUserKeyGenerator, + IXBotUserRepositoryEvents, + XBotUserRepositoryEvents, + XBotUserGraphType, + IntGraphType, + XBotUserGraphQuery, + IXBotUserGraphQLTypeHelper, + XBotUserGraphQLTypeHelper, + XBotUserGraphSchema, + IXBotUserRepository, + XBotUserEFRepository, + TContext + >(); + + // + return result; + } + + public static XEFRepositoryDescriptor< + XBotUser, + int, + IXBotUserKeyGenerator, + XBotUserKeyGenerator, + IXBotUserRepositoryEvents, + XBotUserRepositoryEvents, + XBotUserGraphType, + IntGraphType, + XBotUserGraphQuery, + IXBotUserGraphQLTypeHelper, + XBotUserGraphQLTypeHelper, + XBotUserGraphSchema, + IXBotUserRepository, + XBotUserEFRepository, + TContext, + IXBotUserSeeder, + TSeederImplementation + > GetXBotUserEFRepositoryDescriptor() + where TContext : XDbContext + where TSeederImplementation : XBaseDbSeeder + { + // + var result = new XEFRepositoryDescriptor< + XBotUser, + int, + IXBotUserKeyGenerator, + XBotUserKeyGenerator, + IXBotUserRepositoryEvents, + XBotUserRepositoryEvents, + XBotUserGraphType, + IntGraphType, + XBotUserGraphQuery, + IXBotUserGraphQLTypeHelper, + XBotUserGraphQLTypeHelper, + XBotUserGraphSchema, + IXBotUserRepository, + XBotUserEFRepository, + TContext, + IXBotUserSeeder, + TSeederImplementation + >(); + + // + return result; + } + #endregion + + // + #region Mongo Repository Descriptor Provider(s) ... + public static XMongoRepositoryDescriptor< + XBotUser, + int, + IXBotUserKeyGenerator, + XBotUserKeyGenerator, + IXBotUserRepositoryEvents, + XBotUserRepositoryEvents, + XBotUserGraphType, + IntGraphType, + XBotUserGraphQuery, + IXBotUserGraphQLTypeHelper, + XBotUserGraphQLTypeHelper, + XBotUserGraphSchema, + IXBotUserRepository, + XBotUserMongoRepository + > GetXBotUserMongoRepositoryDescriptor() + { + // + var result = new XMongoRepositoryDescriptor< + XBotUser, + int, + IXBotUserKeyGenerator, + XBotUserKeyGenerator, + IXBotUserRepositoryEvents, + XBotUserRepositoryEvents, + XBotUserGraphType, + IntGraphType, + XBotUserGraphQuery, + IXBotUserGraphQLTypeHelper, + XBotUserGraphQLTypeHelper, + XBotUserGraphSchema, + IXBotUserRepository, + XBotUserMongoRepository + >(); + + // + return result; + } + + public static XMongoRepositoryDescriptor< + XBotUser, + int, + IXBotUserKeyGenerator, + XBotUserKeyGenerator, + IXBotUserRepositoryEvents, + XBotUserRepositoryEvents, + XBotUserGraphType, + IntGraphType, + XBotUserGraphQuery, + IXBotUserGraphQLTypeHelper, + XBotUserGraphQLTypeHelper, + XBotUserGraphSchema, + IXBotUserRepository, + XBotUserMongoRepository, + IXBotUserSeeder, + TSeederImplementation + > GetXBotUserMongoRepositoryDescriptor() + where TSeederImplementation : XBaseDbSeeder + { + // + var result = new XMongoRepositoryDescriptor< + XBotUser, + int, + IXBotUserKeyGenerator, + XBotUserKeyGenerator, + IXBotUserRepositoryEvents, + XBotUserRepositoryEvents, + XBotUserGraphType, + IntGraphType, + XBotUserGraphQuery, + IXBotUserGraphQLTypeHelper, + XBotUserGraphQLTypeHelper, + XBotUserGraphSchema, + IXBotUserRepository, + XBotUserMongoRepository, + IXBotUserSeeder, + TSeederImplementation + >(); + + // + return result; + } + #endregion + + // + #region InMemory Repository Descriptor Provider(s) ... + public static XInMemoryRepositoryDescriptor< + XBotUser, + int, + IXBotUserKeyGenerator, + XBotUserKeyGenerator, + IXBotUserRepositoryEvents, + XBotUserRepositoryEvents, + XBotUserGraphType, + IntGraphType, + XBotUserGraphQuery, + IXBotUserGraphQLTypeHelper, + XBotUserGraphQLTypeHelper, + XBotUserGraphSchema, + IXBotUserRepository, + XBotUserInMemoryRepository + > GetXBotUserInMemoryRepositoryDescriptor() + { + // + var result = new XInMemoryRepositoryDescriptor< + XBotUser, + int, + IXBotUserKeyGenerator, + XBotUserKeyGenerator, + IXBotUserRepositoryEvents, + XBotUserRepositoryEvents, + XBotUserGraphType, + IntGraphType, + XBotUserGraphQuery, + IXBotUserGraphQLTypeHelper, + XBotUserGraphQLTypeHelper, + XBotUserGraphSchema, + IXBotUserRepository, + XBotUserInMemoryRepository + >(); + + // + return result; + } + + public static XInMemoryRepositoryDescriptor< + XBotUser, + int, + IXBotUserKeyGenerator, + XBotUserKeyGenerator, + IXBotUserRepositoryEvents, + XBotUserRepositoryEvents, + XBotUserGraphType, + IntGraphType, + XBotUserGraphQuery, + IXBotUserGraphQLTypeHelper, + XBotUserGraphQLTypeHelper, + XBotUserGraphSchema, + IXBotUserRepository, + XBotUserInMemoryRepository, + IXBotUserSeeder, + TSeederImplementation + > GetXBotUserInMemoryRepositoryDescriptor() + where TSeederImplementation : XBaseDbSeeder + { + // + var result = new XInMemoryRepositoryDescriptor< + XBotUser, + int, + IXBotUserKeyGenerator, + XBotUserKeyGenerator, + IXBotUserRepositoryEvents, + XBotUserRepositoryEvents, + XBotUserGraphType, + IntGraphType, + XBotUserGraphQuery, + IXBotUserGraphQLTypeHelper, + XBotUserGraphQLTypeHelper, + XBotUserGraphSchema, + IXBotUserRepository, + XBotUserInMemoryRepository, + IXBotUserSeeder, + TSeederImplementation + >(); + + // + return result; + } + #endregion + } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Interfaces\IXBotProvider.cs + +using System.Threading; +using xBotService.Models; +using xBotService.Constants; +using System.Threading.Tasks; +using System.Collections.Generic; +using xCommons.Extensions; + +namespace xBotService.Interfaces +{ + public interface IXBotProvider + { + /// + /// Retrieve Bot Info ... + /// + /// + /// + Task GetMe( + CancellationToken cancellationToken = default + ); + + /// + /// Retrieve Messages ... + /// + /// + /// + /// + Task> GetUpdates( + XBotUpdatesRequest requestModel, + CancellationToken cancellationToken = default + ); + + /// + /// Sending Simple String Message to Bot ... + /// + /// + /// + /// + Task SendMessage( + XBotSendMessageRequest requestModel, + CancellationToken cancellationToken = default + ); + + /// + /// Show Verification Request Menu ... + /// + /// + /// + /// + /// + Task ShowVerificationMenu( + long botUserId, + string label = "🔐 دریافت کد وریفیکیشن", + CancellationToken cancellationToken = default + ); + + /// + /// Send Verification Code to Requests ... + /// + /// + /// + /// + /// + /// + // Task SendVerificationCode( + // long chatId, + // string code, + // int ttlSeconds, + // CancellationToken cancellationToken = default + // ); + + /// + /// an Accept for Exit Loading on Bot ... + /// + /// + /// + /// + /// + /// + // Task AnswerCallbackQuery( + // string callbackQueryId, + // string text = null, + // bool showAlert = false, + // CancellationToken cancellationToken = default + // ); + + /// + /// Remove Inline Keyboard After Click (Optional) ... + /// + /// + /// + /// + /// + // Task RemoveInlineKeyboard( + // long chatId, + // long messageId, + // CancellationToken cancellationToken = default + // ); + + /// + /// Set Webhook for Retrieve Messages on Recieved ... + /// + /// + /// + /// + /// + // Task SetWebhook( + // string webhookUrl, + // string secretToken = null, + // CancellationToken cancellationToken = default + // ); + } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Interfaces\Dtos\IXBotUserDtoHub.cs + +using xBotService.Models.Dtos; +using xPushService.Interfaces; +using xBotService.Models.Entities; + +namespace xBotService.Interfaces.Dtos +{ + public interface IXBotUserDtoHub : IXBaseDtoHub + { } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Interfaces\Dtos\IXBotUserRepositoryService.cs + +using xBotService.Models.Dtos; +using xDataService.Interfaces; +using xBotService.Models.Entities; + +namespace xBotService.Interfaces.Entities.Dtos +{ + public interface IXBotUserRepositoryService : IXBaseRepositoryService + { } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Interfaces\Dtos\IXBotUserServiceProvider.cs + +using xBotService.Models.Dtos; +using xPushService.Interfaces; +using xBotService.Models.Entities; +using xBotService.Providers.Dtos; + +namespace xBotService.Interfaces.Dtos +{ + public interface IXBotUserServiceProvider : IXBaseDtoProvider + { } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Interfaces\Entities\IXBotUserEntityHub.cs + +using xPushService.Interfaces; +using xBotService.Models.Entities; + +namespace xBotService.Interfaces.Entities +{ + public interface IXBotUserEntityHub : IXBaseEntityHub + { } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Interfaces\Entities\IXBotUserGraphQLTypeHelper.cs + +using xDataService.Interfaces; +using xBotService.Models.Entities; + +namespace xBotService.Interfaces.Entities +{ + public interface IXBotUserGraphQLTypeHelper : IXBaseGraphQLTypeHelper + { } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Interfaces\Entities\IXBotUserKeyGenerator.cs + +using xDataService.Interfaces; +using xBotService.Models.Entities; + +namespace xBotService.Interfaces.Entities +{ + public interface IXBotUserKeyGenerator : IXKeyGenerator + { } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Interfaces\Entities\IXBotUserRepository.cs + +using xDataService.Interfaces; +using xBotService.Models.Entities; + +namespace xBotService.Interfaces.Entities +{ + public interface IXBotUserRepository : IXBaseRepository + { } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Interfaces\Entities\IXBotUserRepositoryEvents.cs + +using xDataService.Interfaces; +using xBotService.Models.Entities; + +namespace xBotService.Interfaces.Entities +{ + public interface IXBotUserRepositoryEvents : IXBaseRepositoryEvents + { } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Interfaces\Entities\IXBotUserRepositoryProvider.cs + +using xPushService.Interfaces; +using xBotService.Models.Entities; +using xBotService.Providers.Entities; + +namespace xBotService.Interfaces.Entities +{ + public interface IXBotUserRepositoryProvider : IXBaseEntityProvider + { } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Interfaces\Entities\IXBotUserSeeder.cs + +using xDataService.Interfaces; +using xBotService.Models.Entities; + +namespace xBotService.Interfaces.Entities +{ + public interface IXBotUserSeeder: IXBaseDbSeeder + { } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Models\XBotModels.cs + +using System; +using Newtonsoft.Json; +using xCommons.Extensions; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; + +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; } + } + + /// + /// a Bot Button Keyboard ... + /// + public class XBotKeyboardButton + { + [JsonProperty("text", + NullValueHandling = NullValueHandling.Ignore)] + public string Text { get; set; } + + [JsonProperty("style", + NullValueHandling = NullValueHandling.Ignore)] + public string Style { get; set; } + + [JsonProperty("request_contact", + NullValueHandling = NullValueHandling.Ignore)] + public bool RequestContact { get; set; } + + [JsonProperty("request_location", + NullValueHandling = NullValueHandling.Ignore)] + public bool RequestLocation { get; set; } + + [JsonProperty("web_app", + NullValueHandling = NullValueHandling.Ignore)] + public XBotWebAppInfo WebApp { get; set; } = null; + } + + /// + /// XBot Web App Info ... + /// + public class XBotWebAppInfo + { + public string Url { get; set; } + } + + /// + /// a Bot Copy Text Button ... + /// + public class XBotCopyTextButton + { + [StringLength(256)] + public string Text { get; set; } + } + + /// + /// An Inline Keyboard Button ... + /// + public class XBotInlineKeyboardButton + { + [JsonProperty("url", + NullValueHandling = NullValueHandling.Ignore)] + public string Url { get; set; } + + [JsonProperty("text", + NullValueHandling = NullValueHandling.Ignore)] + public string Text { get; set; } + + [JsonProperty("style", + NullValueHandling = NullValueHandling.Ignore)] + public string Style { get; set; } + + [JsonProperty("callback_data", + NullValueHandling = NullValueHandling.Ignore)] + public string CallbackData { get; set; } + + [JsonProperty("disabled", + NullValueHandling = NullValueHandling.Ignore)] + public object Disabled { get; set; } = null; + + [JsonProperty("web_app", + NullValueHandling = NullValueHandling.Ignore)] + public XBotWebAppInfo WebApp { get; set; } = null; + + [JsonProperty("copy_text", + NullValueHandling = NullValueHandling.Ignore)] + public XBotCopyTextButton CopyText { get; set; } = null; + } + + /// + /// Bot Inline Keyboard ... + /// + public class XBotInlineKeyboardMarkup + { + [JsonProperty("inline_keyboard", + NullValueHandling = NullValueHandling.Ignore)] + public IList InlineKeyboard { get; set; } = []; + } + + /// + /// Bot Reply Keyboard Markup ... + /// + public class XBotReplyKeyboardMarkup + { + [JsonProperty("keyboard", + NullValueHandling = NullValueHandling.Ignore)] + public IList Keyboard { get; set; } = []; + } + + /// + /// Reply Bot Keyboard Remove ... + /// + public class XBotReplyKeyboardRemoveMarkup + { + [JsonProperty("remove_keyboard", + NullValueHandling = NullValueHandling.Ignore)] + public bool RemoveKeyboard { get; set; } + } + + /// + /// Bot Reply Markup ... + /// + public class XBotReplyMarkup + { + [JsonProperty("reply_markup", + NullValueHandling = NullValueHandling.Ignore)] + public IList Keyboard { get; set; } = []; + public object ReplyMarkup { get; set; } + + public static XBotReplyMarkup InlineKeyboardMarkup( + XBotInlineKeyboardMarkup source + ) + { + // + var data = source.ToJSON(); + var result = new XBotReplyMarkup + { + ReplyMarkup = data + }; + + // + return result; + } + + public static XBotReplyMarkup ReplyKeyboardMarkup( + XBotReplyKeyboardMarkup source + ) + { + // + var data = source.ToJSON(); + var result = new XBotReplyMarkup + { + ReplyMarkup = data + }; + + // + return result; + } + + public static XBotReplyMarkup ReplyKeyboardRemoveMarkup( + XBotReplyKeyboardRemoveMarkup source + ) + { + // + var data = source.ToJSON(); + var result = new XBotReplyMarkup + { + ReplyMarkup = data + }; + + // + return result; + } + } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Models\Dtos\XBotUserDto.cs + +using xModels.Base; +using xModels.Dtos; + +namespace xBotService.Models.Dtos +{ + /// + /// Bot User / System User Relation ... + /// + public class XBotUserDto : XBaseIntIDEntityDto + { + /// + /// User Id ... + /// + /// + public string UserId { get; set; } + + /// + /// System Person Information ... + /// + /// + public virtual XPersonDto User { get; set; } = null; + + /// + /// Check Bot User is Verified or not ... + /// + /// + public bool Verified { get; set; } + + /// + /// Bot User Id ... + /// + /// + public long BotUserId { get; set; } + + /// + /// Chat Bot User Name ... + /// + /// + public string BotUserName { get; set; } + + /// + /// Bot Last Name ... + /// + /// + public string BotLastname { get; set; } + + /// + /// Bot First Name ... + /// + /// + public string BotFirstname { get; set; } + } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Models\Entities\XBotUser.cs + +using xModels.Base; + +namespace xBotService.Models.Entities +{ + /// + /// Bot User / System User Relation ... + /// + public class XBotUser : XBaseIntIDEntity + { + /// + /// User Id ... + /// + /// + public string UserId { get; set; } + + /// + /// Check Bot User is Verified or not ... + /// + /// + public bool Verified { get; set; } + + /// + /// Bot User Id ... + /// + /// + public long BotUserId { get; set; } + + /// + /// Chat Bot User Name ... + /// + /// + public string BotUserName { get; set; } + + /// + /// Bot Last Name ... + /// + /// + public string BotLastname { get; set; } + + /// + /// Bot First Name ... + /// + /// + public string BotFirstname { get; set; } + } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Providers\XBotProvider.cs + +using RestSharp; +using System.Threading; +using xCommons.Providers; +using xBotService.Models; +using xCommons.Extensions; +using xBotService.Constants; +using xBotService.Extensions; +using xBotService.Interfaces; +using xIdentityModels.Models; +using System.Threading.Tasks; +using xHttpService.Constants; +using xBotService.Configuration; +using System.Collections.Generic; +using xIdentityService.Interfaces; +using Microsoft.Extensions.Logging; +using xExceptions.Constants; + +namespace xBotService.Providers +{ + public class XBotProvider : IXBotProvider + { + // + private readonly ILogger logger; + private readonly IXIdentityHttpProvider httpProvider; + private readonly XValidationProvider validationProvider; + private readonly XBotServiceConfiguration configuration; + + public XBotProvider( + ILogger logger, + IXIdentityHttpProvider httpProvider, + XValidationProvider validationProvider, + XBotServiceConfiguration configuration + ) + { + // + this.logger = logger; + this.httpProvider = httpProvider; + this.configuration = configuration; + this.validationProvider = validationProvider; + } + + // + #region Tools ... + /// + /// Get an Instance of RestClient ... + /// + /// + public RestClient GetRestClient( + XTokenResponse tokens = null + ) + { + // + var result = httpProvider.GetRestClient( + tokens: tokens, + baseUrl: configuration.BaseRoute + ); + + // + return result; + } + + /// + /// Get an Instance of RestRequest ... + /// + public RestRequest GetRestRequest( + XBotEndpoints endpoint, + bool addXPoweredValue = true, + IDictionary @params = null, + IDictionary headers = null, + IDictionary queryStrings = null + ) + { + // + var result = httpProvider.GetRestRequest( + @params: @params, + headers: headers, + queryStrings: queryStrings, + addXPoweredValue: addXPoweredValue, + endpoint: endpoint.GetStringValue() + ); + + // + return result; + } + #endregion + + // + #region Service ... + /// + /// Retrieve Bot Info ... + /// + /// + /// + public virtual async Task GetMe( + CancellationToken cancellationToken = default + ) + { + // + var client = GetRestClient(); + var request = GetRestRequest( + endpoint: XBotEndpoints.GetMe, + @params: new Dictionary + { + { XBotParams.XTokenParam, configuration.Token } + } + ); + + // + var response = await httpProvider.RunRestRequest>( + client: client, + request: request, + method: XHttpMethod.GET, + cancellationToken: cancellationToken + ); + + // + // Ensure Success ... + response.EnsureBotResponseSucceed(); + + // + var result = response.Result; + + // + return result; + } + + /// + /// Retrieve Messages ... + /// + /// + /// + /// + public virtual async Task> GetUpdates( + XBotUpdatesRequest requestModel, + CancellationToken cancellationToken = default + ) + { + // + requestModel = requestModel.Normalize(); + + // + var client = GetRestClient(); + var request = GetRestRequest( + endpoint: XBotEndpoints.GetUpdates, + @params: new Dictionary + { + { XBotParams.XTokenParam, configuration.Token } + }, + queryStrings: new Dictionary + { + { XBotParams.XLimit, requestModel.Limit.ToString() }, + { XBotParams.XOffest, requestModel.Offset.ToString() }, + { XBotParams.XTimeout, requestModel.Timeout.ToString() } + } + ); + + // + var response = await httpProvider.RunRestRequest>>( + client: client, + request: request, + method: XHttpMethod.GET, + cancellationToken: cancellationToken + ); + + // + // Ensure Success ... + response.EnsureBotResponseSucceed(); + + // + var result = response.Result; + + // + return result; + } + + /// + /// Sending Simple String Message to Bot ... + /// + /// + /// + /// + public virtual async Task SendMessage( + XBotSendMessageRequest requestModel, + CancellationToken cancellationToken = default + ) + { + // + // Validate ... + if (!requestModel.IsValid()) + { + XException.InvalidArgs.Throw(); + } + + // + var client = GetRestClient(); + var request = GetRestRequest( + endpoint: XBotEndpoints.SendMessage, + @params: new Dictionary + { + { XBotParams.XTokenParam, configuration.Token } + } + ); + + // + var req = requestModel.ToDto(); + request.AddJsonBody(req.ToJSON()); + + // + var response = await httpProvider.RunRestRequest>( + client: client, + request: request, + method: XHttpMethod.POST, + cancellationToken: cancellationToken + ); + + // + // Ensure Success ... + response.EnsureBotResponseSucceed(); + + // + var result = response.Result; + + // + return result; + } + + /// + /// Show Verification Request Menu ... + /// + /// + /// + /// + /// + public virtual async Task ShowVerificationMenu( + long botUserId, + string label = "🔐 دریافت کد وریفیکیشن", + CancellationToken cancellationToken = default + ) + { + // + // Validate ... + if (botUserId <= 0 || label.IsNullOrEmpty()) + { + XException.InvalidArgs.Throw(); + } + + // + // Markup for Keyboards ... + var markup = XBotReplyMarkup + .InlineKeyboardMarkup(new XBotInlineKeyboardMarkup + { + InlineKeyboard = [ + new XBotInlineKeyboardButton{ + Text = label, + CallbackData = "request_verification_code" + } + ] + }); + + // + var result = await SendMessage( + cancellationToken: cancellationToken, + requestModel: new XBotSendMessageRequest + { + ChatId = botUserId, + ReplyMarkup = markup.ReplyMarkup.ToJSON(), + Text = "برای دریافت کد وریفیکیشن روی دکمه زیر کلیک کنید:", + } + ); + + // + return result; + } + + /// + /// Send Verification Code to Requests ... + /// + /// + /// + /// + /// + /// + // public virtual async Task SendVerificationCode( + // long chatId, + // string code, + // int ttlSeconds, + // CancellationToken cancellationToken = default + // ) + // { + // // + // // Validate ... + // if (chatId <= 0 || ttlSeconds < 60 || code.IsNullOrEmpty()) + // { + // XException.InvalidArgs.Throw(); + // } + + // // + // var minutes = ttlSeconds / 60; + // var response = await SendMessage( + // chatId: chatId, + // cancellationToken: cancellationToken, + // text: $"✅ کد وریفیکیشن شما:\n\n{code}\n\n⏱ این کد تا {minutes} دقیقه معتبر است." + // ); + + // // + // return response; + // } + + /// + /// an Accept for Exit Loading on Bot ... + /// + /// + /// + /// + /// + /// + // public virtual async Task AnswerCallbackQuery( + // string callbackQueryId, + // string text = null, + // bool showAlert = false, + // CancellationToken cancellationToken = default + // ) + // { + // // + // // Validation ... + // validationProvider.GroupValidationBuilder() + // .AddNotEmpty(callbackQueryId) + // .ValidateGroup(); + + // // + // var client = GetRestClient(); + // var request = GetRestRequest( + // endpoint: XBotEndpoints.AnswerCallbackQuery, + // @params: new Dictionary + // { + // { XBotParams.XTokenParam, configuration.Token } + // } + // ); + + // // + // request.AddJsonBody(new + // { + // text = text, + // show_alert = showAlert, + // callback_query_id = callbackQueryId, + // }); + + // // + // var response = await httpProvider.RunRestRequest( + // client: client, + // request: request, + // method: XHttpMethod.POST, + // cancellationToken: cancellationToken + // ); + + // // + // return response; + // } + + /// + /// Remove Inline Keyboard After Click (Optional) ... + /// + /// + /// + /// + /// + // public virtual async Task RemoveInlineKeyboard( + // long chatId, + // long messageId, + // CancellationToken cancellationToken = default + // ) + // { + // // + // // Validation ... + // if (chatId <= 0 || messageId <= 0) + // { + // XException.InvalidArgs.Throw(); + // } + + // // + // var client = GetRestClient(); + // var request = GetRestRequest( + // endpoint: XBotEndpoints.EditMessageReplyMarkup, + // @params: new Dictionary + // { + // { XBotParams.XTokenParam, configuration.Token } + // } + // ); + + // // + // request.AddJsonBody(new + // { + // chat_id = chatId, + // message_id = messageId, + // reply_markup = new { inline_keyboard = new List>() } + // }); + + // // + // var response = await httpProvider.RunRestRequest( + // client: client, + // request: request, + // method: XHttpMethod.POST, + // cancellationToken: cancellationToken + // ); + + // // + // return response; + // } + + /// + /// Set Webhook for Retrieve Messages on Recieved ... + /// + /// + /// + /// + /// + // public virtual async Task SetWebhook( + // string webhookUrl, + // string secretToken = null, + // CancellationToken cancellationToken = default + // ) + // { + // // + // var client = GetRestClient(); + // var request = GetRestRequest( + // endpoint: XBotEndpoints.SetWebhook, + // @params: new Dictionary + // { + // { XBotParams.XTokenParam, configuration.Token } + // } + // ); + + // // + // request.AddJsonBody(new + // { + // url = webhookUrl, + // secret_token = secretToken + // }); + + // // + // var iResponse = await httpProvider.RunRestRequest( + // client: client, + // request: request, + // method: XHttpMethod.POST, + // cancellationToken: cancellationToken + // ); + // var response = iResponse?.Ok ?? false; + + // // + // return response; + // } + #endregion + + // + #region Private ... + #endregion + } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Providers\XBotUserEntityRegisterar.cs + +using xDataService.Providers; +using xDataService.Interfaces; +using xBotService.Models.Entities; +using Microsoft.EntityFrameworkCore; +using xBotService.Configuration.Entities; + +namespace xBotService.Providers +{ + public class XBotUserEntityRegisterar : XBaseEntityRegisterar, IXEntityRegisterar + { + public XBotUserEntityRegisterar() + : base(nameof(XBotUserEntityRegisterar)) + { + // + // Add XBotUser Entity ... + AddEntity(); + } + + /// + /// Configure Entities ... + /// + /// + public override void ConfigureEntities(ModelBuilder modelBuilder) + { + // + // Configure Entity Using Provided ... + modelBuilder + .ApplyConfigurationsFromAssembly(typeof(XBotUserEntityConfiguration).Assembly); + + // + base.ConfigureEntities(modelBuilder); + } + } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Providers\Dtos\XBotUserDtoHub.cs + +using xPushService.Base; +using xBotService.Models.Dtos; +using xBotService.Interfaces.Dtos; +using xBotService.Models.Entities; +using Microsoft.Extensions.Logging; + +namespace xBotService.Providers.Dtos +{ + public class XBotUserDtoHub : XBaseDtoHub, IXBotUserDtoHub + { + public XBotUserDtoHub( + ILogger logger + ) : base(logger) + { } + } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Providers\Dtos\XBotUserRepositoryService.cs + +using AutoMapper; +using xDataService.Providers; +using xBotService.Models.Dtos; +using xBotService.Models.Entities; +using System.Collections.Generic; +using xBotService.Interfaces.Entities; +using xBotService.Interfaces.Entities.Dtos; + +namespace xBotService.Providers.Dtos +{ + public class XBotUserRepositoryService : XBaseRepositoryService, IXBotUserRepositoryService + { + public XBotUserRepositoryService( + IXBotUserRepository repository, + IEnumerable mapperProfiles = null + ) : base(repository, mapperProfiles) + { } + } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Providers\Dtos\XBotUserServiceProvider.cs + +using xPushService.Base; +using xBotService.Models.Dtos; +using xDataService.Configuration; +using xBotService.Interfaces.Dtos; +using xBotService.Models.Entities; +using xIdentityService.Interfaces; +using Microsoft.AspNetCore.SignalR; +using xBotService.Interfaces.Entities.Dtos; + +namespace xBotService.Providers.Dtos +{ + public class XBotUserServiceProvider : XBaseDtoProvider, IXBotUserServiceProvider + { + public XBotUserServiceProvider( + IHubContext hub, + XDataServiceConfiguration dataConfiguration, + IXBotUserRepositoryService service, + IXIdentityProvider identityProvider = null + ) : base( + hub, + dataConfiguration, + service, + identityProvider + ) + { } + } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Providers\Entities\XBotUserEFRepository.cs + +using xDataService.Db; +using xDataService.Providers; +using xDataService.Interfaces; +using xDataService.Configuration; +using xBotService.Models.Entities; +using xBotService.Interfaces.Entities; + +namespace xBotService.Providers.Entities +{ + public class XBotUserEFRepository : XBaseEFRepository, IXBotUserRepository + where TContext : XDbContext + { + public XBotUserEFRepository( + IXUnitOfWorks unitOfWorks, + XDataServiceConfiguration configuration, + IXBotUserKeyGenerator keyGenerator = null, + IXBotUserRepositoryEvents baseRepositoryEvents = null + ) : base(unitOfWorks, configuration, keyGenerator, baseRepositoryEvents) + { } + } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Providers\Entities\XBotUserEntityHub.cs + +using xPushService.Base; +using xBotService.Models.Entities; +using Microsoft.Extensions.Logging; +using xBotService.Interfaces.Entities; + +namespace xBotService.Providers.Entities +{ + public class XBotUserEntityHub : XBaseEntityHub, IXBotUserEntityHub + { + public XBotUserEntityHub( + ILogger logger + ) : base(logger) + { } + } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Providers\Entities\XBotUserInMemoryRepository.cs + +using xDataService.Providers; +using xDataService.Configuration; +using xBotService.Models.Entities; +using xBotService.Interfaces.Entities; + +namespace xBotService.Providers.Entities +{ + public class XBotUserInMemoryRepository : XBaseInMemoryRepository, IXBotUserRepository + { + public XBotUserInMemoryRepository( + XDataServiceConfiguration configuration, + IXBotUserKeyGenerator keyGenerator = null, + IXBotUserRepositoryEvents baseRepositoryEvents = null + ) : base( + configuration, + keyGenerator, + baseRepositoryEvents + ) + { } + } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Providers\Entities\XBotUserKeyGenerator.cs + +using xDataService.Providers; +using xBotService.Models.Entities; +using xBotService.Interfaces.Entities; + +namespace xBotService.Providers.Entities +{ + public class XBotUserKeyGenerator : XIntKeyGenerator, IXBotUserKeyGenerator + { } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Providers\Entities\XBotUserMongoRepository.cs + +using xDataService.Providers; +using xDataService.Configuration; +using xBotService.Models.Entities; +using xBotService.Interfaces.Entities; + +namespace xBotService.Providers.Entities +{ + public class XBotUserMongoRepository : XBaseMongoRepository, IXBotUserRepository + { + public XBotUserMongoRepository( + XDataBaseConfiguration dbConfiguration, + XDataServiceConfiguration configuration, + string collectionName = null, + IXBotUserKeyGenerator keyGenerator = null, + IXBotUserRepositoryEvents baseRepositoryEvents = null + ) : base( + dbConfiguration, + configuration, + collectionName, + keyGenerator, + baseRepositoryEvents + ) + { } + } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Providers\Entities\XBotUserRepositoryEvents.cs + +using xDataService.Providers; +using xBotService.Models.Entities; +using xBotService.Interfaces.Entities; + +namespace xBotService.Providers.Entities +{ + public class XBotUserRepositoryEvents : XBaseRepositoryEvents, IXBotUserRepositoryEvents + { } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Providers\Entities\XBotUserRepositoryProvider.cs + +using xPushService.Base; +using xDataService.Configuration; +using xBotService.Models.Entities; +using xIdentityService.Interfaces; +using Microsoft.AspNetCore.SignalR; +using xBotService.Interfaces.Entities; + +namespace xBotService.Providers.Entities +{ + public class XBotUserRepositoryProvider : XBaseEntityProvider, IXBotUserRepositoryProvider + { + public XBotUserRepositoryProvider( + IHubContext hub, + IXBotUserRepository repository, + XDataServiceConfiguration dataConfiguration, + IXIdentityProvider identityProvider = null + ) : base( + hub, + repository, + dataConfiguration, + identityProvider + ) + { } + } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Providers\Entities\XBotUserSeederBase.cs + +using xDataService.Providers; +using xDataService.Configuration; +using xBotService.Models.Entities; +using xBotService.Interfaces.Entities; + +namespace xBotService.Providers.Entities +{ + public abstract class XBotUserSeederBase : XBaseDbSeeder, IXBotUserSeeder + { + protected XBotUserSeederBase( + string entity, + string database, + IXBotUserRepository repository, + XDataServiceConfiguration dataServiceConfiguration + ) : base( + entity, + database, + repository, + dataServiceConfiguration + ) + { } + } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Providers\GraphQL\XBotUserGraphQLTypeHelper.cs + +using xDataService.GraphQL; +using xDataService.Configuration; +using xBotService.Models.Entities; +using xBotService.Interfaces.Entities; +using xBotService.Constants; + +namespace xBotService.Providers.GraphQL +{ + public class XBotUserGraphQLTypeHelper : XBaseGraphQLTypeHelper, IXBotUserGraphQLTypeHelper + { + public XBotUserGraphQLTypeHelper( + XDataServiceConfiguration configuration + ) + : base(configuration) + { + } + + public override string GetInQueryCollectionName() + { + return XBotServiceConstants.XBotUserCollectionName; + } + + public override string GetInQuerySingleName() + { + return XBotServiceConstants.XBotUserSingleName; + } + } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Providers\GraphQL\XBotUserGraphQuery.cs + +using GraphQL.Types; +using xDataService.GraphQL; +using xDataService.Configuration; +using xBotService.Models.Entities; +using xBotService.Interfaces.Entities; + +namespace xBotService.Providers.GraphQL +{ + public class XBotUserGraphQuery : XBaseGraphQLQuery + { + public XBotUserGraphQuery( + XDataServiceConfiguration configuration, + IXBotUserRepository repository, + IXBotUserGraphQLTypeHelper helper + ) : base(configuration, repository, helper) + { } + } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Providers\GraphQL\XBotUserGraphSchema.cs + +using System; +using GraphQL.Types; + +namespace xBotService.Providers.GraphQL +{ + public class XBotUserGraphSchema : Schema + { + public XBotUserGraphSchema(IServiceProvider services) : base(services) + { + Query = (XBotUserGraphQuery)services.GetService(typeof(XBotUserGraphQuery)); + } + } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Providers\GraphQL\XBotUserGraphType.cs + +using xDataService.GraphQL; +using xBotService.Models.Entities; + +namespace xBotService.Providers.GraphQL +{ + public class XBotUserGraphType : XBaseGraphObjectType + { + public XBotUserGraphType() : base() + { + Field(x => x.UserId); + Field(x => x.Verified); + Field(x => x.BotUserId); + Field(x => x.BotUserName); + Field(x => x.BotLastname); + Field(x => x.BotFirstname); + } + } +} + +### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Reciever\XBotBotUpdateRecieverBackgroundService.cs + +using System; +using System.Threading; +using xCommons.Providers; +using xBotService.Models; +using xModels.Extensions; +using xCommons.Extensions; +using System.Threading.Tasks; +using xBotService.Interfaces; +using xBotService.Models.Dtos; +using System.Collections.Generic; +using xBotService.Interfaces.Dtos; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.DependencyInjection; + +namespace xBotService.Reciever +{ + public class XBotBotUpdateRecieverBackgroundService : XTimeBasedBackgroundService + { + // + public XBotBotUpdateRecieverBackgroundService( + IServiceProvider serviceProvider, + ILogger logger, + int intervalInMinutes = 5 + ) : base(serviceProvider, logger, intervalInMinutes) + { } + + public override async Task DoWorkAsync( + CancellationToken cancellationToken = default + ) + { + // + // Inject Provider ... + using var scope = serviceProvider.CreateScope(); + var botProvider = scope.ServiceProvider.GetRequiredService(); + var botUserProvider = scope.ServiceProvider.GetRequiredService(); + + // + // Check Provider Service Registered Successfully ... + if (botProvider.IsNull() || + botUserProvider.IsNull()) + { + // + logger.LogInformation("xBotProvider Service not Provided, ignore ..."); + return; + } + + // + // Try to Retrieve Updates ... + IList updates = []; + try + { + // + updates = await botProvider.GetUpdates( + requestModel: new(), + cancellationToken: cancellationToken + ); + } + catch (Exception ex) + { + // + logger.LogError(ex, "Retrieve Updates failed ..."); + return; + } + + // + // Check Updates Exists ... + if (!updates.HasChild()) + { + // + logger.LogInformation("there is not any new Updates ..."); + return; + } + + // + // Log ... + logger.LogInformation($"Updates: {Environment.NewLine}{updates.ToJSON()}"); + + // + // HandleRecieved Updates ... + foreach (var update in updates) + { + // + logger + .LogInformation($"Handle Bot Update: {Environment.NewLine} {update}"); + + // + // Check Item Exists in Db ... + var item = await botUserProvider.FindOneAsync( + predicate: x => x.BotUserId.Equals(update.Message.From.Id) + ); + if (item.IsNullOrDefault()) + { + // + // Not Exists ... + item = await botUserProvider.AddAsync( + saveChanges: true, + connectionId: null, + item: new XBotUserDto + { + BotUserId = update.Message.From.Id, + BotUserName = update.Message.From.Username, + BotLastname = update.Message.From.LastName, + BotFirstname = update.Message.From.FirstName, + }, + cancellationToken: cancellationToken + ); + + // + logger.LogInformation("Add new BotUser ..."); + } + else + { + // + // Exists ... + logger.LogInformation("BotUser exists ..."); + } + + // + // Check Verified ... + if (item.Verified) + { + // + logger.LogInformation("User Verified ..."); + continue; + } + + // + // TODO: Remove this ... + if (item.BotUserName != "llhajamir") + { + continue; + } + + // + // Try to Show Verification Menu on User ... + logger + .LogInformation($"Show Verification Request Method to User: {item.User.GetFullname()}"); + var response = await botProvider.ShowVerificationMenu( + botUserId: item.BotUserId, + cancellationToken: cancellationToken + ); + + // + logger.LogInformation($"Verification Menu Shown for User: {item.BotUserId}"); + } + } + } +} diff --git a/Documents/Resources/Json/Requests.md b/Documents/Resources/Json/Requests.md index 2d34b38..2d8b698 100644 --- a/Documents/Resources/Json/Requests.md +++ b/Documents/Resources/Json/Requests.md @@ -836,6 +836,90 @@ Response: } ] } + }, + { + "update_id": 3, + "message": { + "message_id": 5, + "message_thread_id": 0, + "from": { + "id": 1014883194, + "is_bot": false, + "last_name": "", + "username": "llhajamir", + "first_name": "llHajAmir", + "has_topics_enabled": false, + "allows_users_to_create_topics": false + }, + "date": 1794496444, + "chat": { + "id": 1014883194, + "type": "private", + "username": "llhajamir", + "first_name": "llHajAmir" + }, + "forward_from_message_id": 0, + "forward_date": 0, + "edit_date": 0, + "text": "/start", + "entities": [ + { + "type": "bot_command", + "offset": 0, + "length": 6 + } + ] + } + }, + { + "update_id": 4, + "callback_query": { + "id": "6895626100094890049", + "data": "request_verification_code", + "from": { + "id": 1014883194, + "is_bot": false, + "last_name": "", + "username": "llhajamir", + "first_name": "llHajAmir", + "has_topics_enabled": false, + "allows_users_to_create_topics": false + }, + "message": { + "message_id": 11, + "message_thread_id": 0, + "from": { + "id": 57317004, + "is_bot": true, + "last_name": "", + "username": "xsaherelmbot", + "first_name": "xBaleBot", + "has_topics_enabled": false, + "allows_users_to_create_topics": false + }, + "date": 1794509749, + "chat": { + "id": 1014883194, + "type": "private", + "username": "llhajamir", + "first_name": "llHajAmir" + }, + "forward_from_message_id": 0, + "forward_date": 0, + "edit_date": 0, + "text": "برای دریافت کد وریفیکیشن روی دکمه زیر کلیک کنید:", + "reply_markup": { + "inline_keyboard": [ + [ + { + "text": "🔐 دریافت کد وریفیکیشن", + "callback_data": "request_verification_code" + } + ] + ] + } + } + } } ] ``` diff --git a/Modules/xBotService b/Modules/xBotService index fa59823..2b7209c 160000 --- a/Modules/xBotService +++ b/Modules/xBotService @@ -1 +1 @@ -Subproject commit fa598230084c5f1a5f88681c2a171af6ba733192 +Subproject commit 2b7209c5fbc44fd96d70802bcbbabe22d7ecf7f0 diff --git a/Modules/xCommons b/Modules/xCommons index cba7637..5e31f8f 160000 --- a/Modules/xCommons +++ b/Modules/xCommons @@ -1 +1 @@ -Subproject commit cba7637255572404da61accb9fe53cd20533aed4 +Subproject commit 5e31f8f99a6ecf817e01b86963e4c55c0d9843e2