public IActionResult Start(string secretKey)
        {
            if (String.CompareOrdinal(_bot.SecretKey, secretKey) != 0)
            {
                return(StatusCode(403));
            }

            _bot.Start();
            return(Json("startted"));
        }
示例#2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, ITelegramBot bot, IMessagesQueue messagesQueue)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();
            loggerFactory.AddNLog();
            app.UseMvc();

            app.AddNLogWeb();
            env.ConfigureNLog("nlog.config");

            var accessToken = Configuration.GetSection("TelegramAccessToken")?.Value;
            var botname     = Configuration.GetSection("TelegramBotName")?.Value;

            bot.Connect(accessToken, botname);
            bot.Start();

            messagesQueue.Start();
        }