forked from BotBuilderCommunity/botbuilder-community-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SpellCheckMiddleware.cs
29 lines (25 loc) · 1006 Bytes
/
SpellCheckMiddleware.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using Microsoft.Bot.Builder;
using Microsoft.Extensions.Configuration;
using System.Threading;
using System.Threading.Tasks;
namespace Bot.Builder.Community.Middleware.SpellCheck
{
public class SpellCheckMiddleware :IMiddleware
{
public SpellCheckMiddleware(IConfiguration configuration)
{
ApiKey = configuration.GetValue<string>("SpellCheckKey");
CountryCode = configuration.GetValue<string>("SpellCheckCountryCode");
Market = configuration.GetValue<string>("SpellCheckMarket");
}
public string ApiKey { get; }
public string CountryCode { get; }
public string Market { get; }
public async Task OnTurnAsync(ITurnContext context, NextDelegate next,
CancellationToken cancellationToken = new CancellationToken())
{
context.Activity.Text = await context.Activity.Text.SpellCheck(ApiKey, CountryCode, Market);
await next(cancellationToken);
}
}
}