/// <summary> /// Removes and disables webhooks for bot /// </summary> /// <typeparam name="TBot">Type of bot</typeparam> /// <param name="app">Instance of IApplicationBuilder</param> /// <param name="ensureWebhookDisabled">If true, a request is immediately made to delete webhook</param> /// <returns>Instance of IApplicationBuilder</returns> public static IApplicationBuilder UseTelegramBotLongPolling <TBot>(this IApplicationBuilder app, bool ensureWebhookDisabled = true) where TBot : BotBase <TBot> { IBotManager <TBot> botManager = FindBotManager <TBot>(app); if (ensureWebhookDisabled) { botManager.SetWebhookStateAsync(false).Wait(); } return(app); }
/// <summary> /// Add Telegram bot webhook handling functionality to the pipeline /// </summary> /// <typeparam name="TBot">Type of bot</typeparam> /// <param name="app">Instance of IApplicationBuilder</param> /// <param name="ensureWebhookEnabled">Whether to set the webhook immediately by making a request to Telegram bot API</param> /// <returns>Instance of IApplicationBuilder</returns> public static IApplicationBuilder UseTelegramBotWebhook <TBot>(this IApplicationBuilder app, bool ensureWebhookEnabled = true) where TBot : BotBase <TBot> { IBotManager <TBot> botManager = FindBotManager <TBot>(app); if (ensureWebhookEnabled) { botManager.SetWebhookStateAsync(true).Wait(); } return(app.UseMiddleware <TelegramBotMiddleware <TBot> >()); }