示例#1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IBot bot)
        {
            //Register Syncfusion license
            Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("NDI4MTgxQDMxMzkyZTMxMmUzMGd1TVFlMXFneE95Z08yVC85cGUyOWFiL1VYakcvUHBDdWtROUJ2aURLaUU9");

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }
            //app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
                endpoints.MapRazorPages();
            });

            //Bot Configurations
            bot.GetBotClientAsync().Wait();
        }
示例#2
0
        public async Task <OkResult> Post([FromBody] Update update)
        {
            if (update == null)
            {
                return(Ok());
            }

            var callbackQuery = update.CallbackQuery;
            var message       = update.Message;

            if (callbackQuery != null)
            {
                message = callbackQuery.Message;
                message.NewChatTitle = message.Text;
                message.Text         = callbackQuery.Data;
            }

            if (message != null && message.Text != null)
            {
                var mainCommand = _bot.Commands.Where(x => x.Contains(message)).FirstOrDefault();
                var botClient   = await _bot.GetBotClientAsync();

                //if (_adminService.Admin.Type == "Удалить Мифы" || _adminService.Admin.Type == "Удалить Общее инфо")
                //{
                //    if (message.Text == "Y" && !string.IsNullOrEmpty(_adminService.Admin.QuestionRemove))
                //    {
                //        string path = _adminService.Admin.Type == "Удалить Мифы" ? _adminService.Admin.MythFile : _adminService.Admin.InfoFile;
                //        await _adminService.RemoveValue(message, botClient, path);
                //    }
                //    else if (message.Text == "N" && !string.IsNullOrEmpty(_adminService.Admin.QuestionRemove))
                //    {
                //        _adminService.Admin.QuestionRemove = string.Empty;
                //        await botClient.SendTextMessageAsync(message.Chat.Id, "Выберите пункт, который хотите удалить", parseMode: Telegram.Bot.Types.Enums.ParseMode.Html);
                //    }
                //    else if (message.Text == "Главное меню")
                //    {
                //        _adminService.Admin.QuestionRemove = string.Empty;
                //        _adminService.Admin.Type = string.Empty;
                //        message.Text = "Отмена";
                //        await _adminService.CancelOrQuit(message, botClient);
                //    }
                //    else
                //    {
                //        _adminService.Admin.QuestionRemove = message.Text;
                //        await botClient.SendTextMessageAsync(message.Chat.Id, "Вы уверены? Y/N", parseMode: Telegram.Bot.Types.Enums.ParseMode.Html);
                //    }
                //}
                //else if (mainCommand != null)
                //{
                //    await mainCommand.Execute(message, botClient);
                //}
                //else if (message.Text.Equals("Отмена") || message.Text.Equals("Выйти"))
                //{
                //    await _adminService.CancelOrQuit(message, botClient);
                //}
                //else
                //{
                //    await _adminService.CheckAdmin(message, botClient);
                //}

                if (mainCommand != null)
                {
                    await mainCommand.Execute(message, botClient);

                    await _logService.SendLog(message);
                }
            }

            return(Ok());
        }