/// <summary>
        /// Constructor. You may inject IServiceProvider to freely use you registered services in your modules
        /// </summary>
        /// <param name="key"></param>
        /// <param name="adminId"></param>
        /// <param name="serviceProvider"></param>
        /// <param name="alias"></param>

        public TelegramBotWrapperWithDb(ITelegramBotOptions options, IDbContextFactory <TDbContext> contextFactory)
        {
            DbContextFactory = contextFactory;

            Options = options;
            if (Options.InMemoryDb)
            {
                using (var db = DbContextFactory.CreateDbContext())
                {
                    db.Database.EnsureCreated();
                    db.Database.Migrate();
                }
            }
            if (!String.IsNullOrEmpty(options.Directory))
            {
                RootDirectory = options.Directory;
            }

            if (!Directory.Exists(Path.Combine(RootDirectory)))
            {
                Directory.CreateDirectory(Path.Combine(RootDirectory));
            }
            Log = new TelegramBotLogger(Path.Combine(RootDirectory, "Logs-" + Options.Alias));
            var setting = new TelegramBotSetting()
            {
                Alias = options.Alias, TelegramDefaultAdminUserId = Options.AdminId, TelegramBotAPIKey = Options.Key
            };

            LoadedSetting = setting;

            try
            {
                using (Db)
                {
                    Db.Database.EnsureCreated();

                    Db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                Log.WriteLine($"Db creating data error: {ex.ToString()}", LogLevel.Error, null, "error.log");
            }

            Console.OutputEncoding = Encoding.UTF8;
            Messenger.MessageSent += MessengerOnMessageSent;
            AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;

            //var telegramBotModuleDir = Path.Combine(RootDirectory, "AddonModules-" + alias);

            //WatchForNewModules(telegramBotModuleDir);
        }
        /// <summary>
        /// Constructor. You may inject IServiceProvider to freely use you registered services in your modules
        /// </summary>
        /// <param name="key"></param>
        /// <param name="adminId"></param>
        /// <param name="serviceProvider"></param>
        /// <param name="alias"></param>
        public TelegramBotWrapper(string key, int adminId, IServiceProvider serviceProvider = null, string alias = "TelegramBotFramework", bool needNewUserApproove = false, string paymentToken = null, string dir = "", string webHookUrl = null, bool shouldUseInMemoryDb = false)
        {
            if (!String.IsNullOrEmpty(webHookUrl))
            {
                _webHookUrl = webHookUrl;
            }
            if (!String.IsNullOrEmpty(dir))
            {
                RootDirectory = dir;
            }

            UserMustBeApprooved = needNewUserApproove;
            _paymentToken       = paymentToken;
            ServiceProvider     = serviceProvider;
            if (!Directory.Exists(Path.Combine(RootDirectory)))
            {
                Directory.CreateDirectory(Path.Combine(RootDirectory));
            }
            Log = new TelegramBotLogger(Path.Combine(RootDirectory, "Logs-" + alias));
            var setting = new TelegramBotSetting()
            {
                Alias = alias, TelegramDefaultAdminUserId = adminId, TelegramBotAPIKey = key
            };

            LoadedSetting = setting;

            try
            {
                Db = shouldUseInMemoryDb ? new TelegramBotDbContext() : new TelegramBotDbContext(Path.Combine(RootDirectory, alias));
                Db.Database.EnsureCreated();
                SeedDb(Db);
            }
            catch (Exception ex)
            {
                Log.WriteLine($"Db creating data error: {ex.ToString()}", LogLevel.Error, null, "error.log");
            }

            Console.OutputEncoding = Encoding.UTF8;
            Messenger.MessageSent += MessengerOnMessageSent;
            AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;

            //            var telegramBotModuleDir = Path.Combine(RootDirectory, "AddonModules-" + alias);

            //WatchForNewModules(telegramBotModuleDir);
        }