/// <summary> /// Adds a middleware delegate defined in-line to the application's request pipeline. /// </summary> /// <param name="app">The <see cref="IBotApplicationBuilder"/> instance.</param> /// <param name="middleware">A function that handles the request or calls the given next function.</param> /// <returns>The <see cref="IBotApplicationBuilder"/> instance.</returns> public static IBotApplicationBuilder Use(this IBotApplicationBuilder app, Func <MessageContext, Func <ValueTask>, ValueTask> middleware) { return(app.Use(next => { return context => { return middleware(context, () => next(context)); }; })); }
public void ConfigureBot(IBotApplicationBuilder app) { app.UseIgnoreBots(); app.Use((context, next) => { if (context.Request.Message == "ping") { context.Response.AddMessage("Pong"); } return(next()); }); }