Skip to content

Commit

Permalink
PlanBGmbH#105 Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusMeyer13 committed Mar 5, 2020
1 parent ec81698 commit f0466cc
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 9 deletions.
2 changes: 2 additions & 0 deletions PlanB.Butler.Bot/Bots/TeamsBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public TeamsBot(ConversationState conversationState, UserState userState, T dial
/// are joining the conversation, it calls this method.
/// </remarks>
/// <seealso cref="M:Microsoft.Bot.Builder.ActivityHandler.OnConversationUpdateActivityAsync(Microsoft.Bot.Builder.ITurnContext{Microsoft.Bot.Schema.IConversationUpdateActivity},System.Threading.CancellationToken)" />
/// <returns>Task.</returns>
protected override async Task OnMembersAddedAsync(IList<ChannelAccount> membersAdded, ITurnContext<IConversationUpdateActivity> turnContext, CancellationToken cancellationToken)
{
await turnContext.SendActivityAsync(teamBotsWelcomeMessage, cancellationToken: cancellationToken);
Expand All @@ -66,6 +67,7 @@ protected override async Task OnMembersAddedAsync(IList<ChannelAccount> membersA
/// </summary>
/// <param name="turnContext">The turn context.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
protected override async Task OnSigninVerifyStateAsync(ITurnContext<IInvokeActivity> turnContext, CancellationToken cancellationToken)
{
this.Logger.LogInformation("Running dialog with signin/verifystate from an Invoke Activity.");
Expand Down
41 changes: 32 additions & 9 deletions PlanB.Butler.Bot/Controllers/BotController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,53 @@

namespace PlanB.Butler.Bot.Controllers
{
// This ASP Controller is created to handle a request. Dependency Injection will provide the Adapter and IBot
// implementation at runtime. Multiple different IBot implementations running at different endpoints can be
// achieved by specifying a more specific type for the bot constructor argument.
/// <summary>
/// This ASP Controller is created to handle a request. Dependency Injection will provide the Adapter and IBot
/// implementation at runtime. Multiple different IBot implementations running at different endpoints can be
/// achieved by specifying a more specific type for the bot constructor argument.
/// </summary>
/// <seealso cref="Microsoft.AspNetCore.Mvc.ControllerBase" />
[Route("api/messages")]
[ApiController]
public class BotController : ControllerBase
{
private readonly IBotFrameworkHttpAdapter Adapter;
private readonly IBot Bot;
/// <summary>
/// The adapter.
/// </summary>
private readonly IBotFrameworkHttpAdapter adapter;

/// <summary>
/// The bot.
/// </summary>
private readonly IBot bot;

/// <summary>
/// The bot configuration.
/// </summary>
private readonly IOptions<BotConfig> botConfig;

public BotController(IBotFrameworkHttpAdapter adapter, IBot bot, IOptions<BotConfig> config)
/// <summary>
/// Initializes a new instance of the <see cref="BotController"/> class.
/// </summary>
/// <param name="botFrameworkHttpAdapter">The adapter.</param>
/// <param name="bot">The bot.</param>
/// <param name="config">The configuration.</param>
public BotController(IBotFrameworkHttpAdapter botFrameworkHttpAdapter, IBot bot, IOptions<BotConfig> config)
{
this.Adapter = adapter;
this.Bot = bot;
this.adapter = botFrameworkHttpAdapter;
this.bot = bot;
this.botConfig = config;
}

/// <summary>
/// Posts the asynchronous.
/// </summary>
[HttpPost]
public async Task PostAsync()
{
// Delegate the processing of the HTTP POST to the adapter.
// The adapter will invoke the bot.
await this.Adapter.ProcessAsync(this.Request, this.Response, this.Bot);
await this.adapter.ProcessAsync(this.Request, this.Response, this.bot);
}
}
}
1 change: 1 addition & 0 deletions PlanB.Butler.Bot/Dialogs/NextOrder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ private async Task<DialogTurnResult> CompanyStepAsync(WaterfallStepContext stepC
{
valid = false;
}

stepContext.Values["name"] = stepContext.Context.Activity.From.Name;
if (companyStatus == "extern")
{
Expand Down

0 comments on commit f0466cc

Please sign in to comment.