Skip to content

Commit

Permalink
Slack Adapter polish (#106)
Browse files Browse the repository at this point in the history
* Remove unused formatter, remove duplicate response code set, remove unnecessary casts

* Add Slack login correctly done

* Fix id assignation in SendActivitiesAsync method (#107)

* Add some minor stylecop corrections
LoginWithSlack method temporarily waited to test

* Fix minor stylecop warnings, fix response sending, remove unused inclusion, start partial implementation of previously unimplemented ChannelData message assignment, add property to NewSlackMessage class

* Remove ChatPostEphemeralMessageResult and ChatPostMessageResult classes

* Fix message.ThreadTS assignment and cast. Complete message ChannelData assignent. Some stylecop corrections

* Add stylecop corrections, not taking into account parameter documentations

* Change the return type of ActivityToSlack

* Remove references to Middleware

* Remove Middleware files

* Fix thread_ts assignation

* Add PR changes

* Remove commented out lines

* Add PR changes: commented out code removed, some dynamic casts removed

* Remove all dynamics cast to slackEvent

* Add more PR changes
  • Loading branch information
matiasroldan6 authored Jun 18, 2019
1 parent f4337a7 commit 30fcf87
Show file tree
Hide file tree
Showing 20 changed files with 339 additions and 424 deletions.
15 changes: 7 additions & 8 deletions Botkit/Microsoft.Bot.Sample.Slack/Controllers/BotController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// Generated with Bot Builder V4 SDK Template for Visual Studio EchoBot v4.3.0
Expand All @@ -18,24 +18,23 @@ namespace Microsoft.Bot.Sample.Slack.Controllers
[ApiController]
public class BotController : ControllerBase
{
private readonly SlackAdapter Adapter;
private readonly IBot Bot;
private readonly SlackAdapter adapter;
private readonly IBot bot;

public BotController(SlackAdapter adapter, IBot bot)
{
Adapter = adapter;
Bot = bot;
this.adapter = adapter;
this.bot = bot;

Adapter.Use(new SlackEventMiddleware());
this.adapter.Use(new SlackEventMiddleware());
}


[HttpPost]
public async Task PostAsync()
{
// Delegate the processing of the HTTP POST to the adapter.
// The adapter will invoke the bot.
await Adapter.ProcessAsync(Request, Response, Bot);
await this.adapter.ProcessAsync(this.Request, this.Response, this.bot);
}
}
}
24 changes: 15 additions & 9 deletions Botkit/Microsoft.Bot.Sample.Slack/SimpleSlackAdapterOptions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.Bot.Connector.Authentication;
using Microsoft.Bot.Connector.Authentication;
using Microsoft.BotKit.Adapters.Slack;
using System.Threading.Tasks;

Expand All @@ -12,16 +12,22 @@ public SimpleSlackAdapterOptions()

public SimpleSlackAdapterOptions(string verificationToken, string botToken)
{
VerificationToken = verificationToken;
BotToken = botToken;
this.VerificationToken = verificationToken;
this.BotToken = botToken;
}

public string VerificationToken { get; set; }
public string ClientSigningSecret { get; set; }
public string BotToken { get; set; }
public string ClientId { get; set; }
public string ClientSecret { get; set; }
public string[] Scopes { get; set; }
public string VerificationToken { get; set; }

public string ClientSigningSecret { get; set; }

public string BotToken { get; set; }

public string ClientId { get; set; }

public string ClientSecret { get; set; }

public string[] Scopes { get; set; }

public string RedirectUri { get; set; }

public Task<string> GetBotUserByTeam(string TeamId)
Expand Down
14 changes: 7 additions & 7 deletions Botkit/Microsoft.Bot.Sample.Slack/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// Generated with Bot Builder V4 SDK Template for Visual Studio EchoBot v4.3.0
Expand All @@ -9,19 +9,18 @@
using Microsoft.Bot.Builder;
using Microsoft.Bot.Builder.Integration.AspNet.Core;
using Microsoft.Bot.Connector.Authentication;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

using Microsoft.Bot.Sample.Slack.Bots;
using Microsoft.BotKit.Adapters.Slack;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace Microsoft.Bot.Sample.Slack
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
this.Configuration = configuration;
}

public IConfiguration Configuration { get; }
Expand All @@ -36,7 +35,8 @@ public void ConfigureServices(IServiceCollection services)

// Create the options for the SlackAdapter
services.AddSingleton<ISlackAdapterOptions, ConfigurationSlackAdapterOptions>();
//services.AddSingleton<IBotFrameworkHttpAdapter, BotFrameworkHttpAdapter>();

// services.AddSingleton<IBotFrameworkHttpAdapter, BotFrameworkHttpAdapter>();

// Create the Bot Framework Adapter.
services.AddSingleton<SlackAdapter>();
Expand All @@ -60,7 +60,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
app.UseDefaultFiles();
app.UseStaticFiles();

//app.UseHttpsRedirection();
// app.UseHttpsRedirection();
app.UseMvc();
}
}
Expand Down
7 changes: 3 additions & 4 deletions Botkit/Microsoft.BotKit.Adapters.Slack/AdapterError.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
// Copyright(c) Microsoft Corporation.All rights reserved.
// Copyright(c) Microsoft Corporation.All rights reserved.
// Licensed under the MIT License.

namespace Microsoft.BotKit.Adapters.Slack
{
public class AdapterError
{
string Name;
string Error;
public string Name;
public string Error;

public AdapterError()
{

}
}
}

This file was deleted.

16 changes: 0 additions & 16 deletions Botkit/Microsoft.BotKit.Adapters.Slack/ChatPostMessageResult.cs

This file was deleted.

19 changes: 12 additions & 7 deletions Botkit/Microsoft.BotKit.Adapters.Slack/DialogData.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright(c) Microsoft Corporation.All rights reserved.
// Copyright(c) Microsoft Corporation.All rights reserved.
// Licensed under the MIT License.

using System.Collections.Generic;
Expand All @@ -8,18 +8,23 @@ namespace Microsoft.BotKit.Adapters.Slack
public class DialogData
{
public string Title { get; set; }

public string CallbackId { get; set; }

public string SubmitLabel { get; set; }
public List<DialogElement> Elements { get; set; }
public string State { get; set; }

public List<DialogElement> Elements { get; set; }

public string State { get; set; }

public bool NotifyOnCancel { get; set; }

public DialogData(string title, string callback, string submit, List<DialogElement> elements)
{
Title = title;
CallbackId = callback;
SubmitLabel = submit;
Elements = elements;
this.Title = title;
this.CallbackId = callback;
this.SubmitLabel = submit;
this.Elements = elements;
}
}
}
16 changes: 11 additions & 5 deletions Botkit/Microsoft.BotKit.Adapters.Slack/DialogElement.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
// Copyright(c) Microsoft Corporation.All rights reserved.
// Copyright(c) Microsoft Corporation.All rights reserved.
// Licensed under the MIT License.

using System.Collections.Generic;

namespace Microsoft.BotKit.Adapters.Slack
{
public class DialogElement
{
{
public string Label { get; set; }

public string Name { get; set; }
public string Value { get; set; }
public Dictionary<string, string> OptionList { get; set; }
public ISlackAdapterOptions Options { get; set; }

public string Value { get; set; }

public Dictionary<string, string> OptionList { get; set; }

public ISlackAdapterOptions Options { get; set; }

public string Type { get; set; }

public string Subtype { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright(c) Microsoft Corporation.All rights reserved.
// Copyright(c) Microsoft Corporation.All rights reserved.
// Licensed under the MIT License.

using System.Threading.Tasks;
Expand Down Expand Up @@ -45,7 +45,7 @@ public interface ISlackAdapterOptions
/// <summary>
/// A method that receives a Slack team id and returns the bot token associated with that team. Required for multi-team apps.
/// </summary>
/// <param name="TeamId">Team ID</param>
/// <param name="TeamId">Team ID.</param>
/// <returns></returns>
Task<string> GetTokenForTeam(string TeamId);

Expand Down
6 changes: 6 additions & 0 deletions Botkit/Microsoft.BotKit.Adapters.Slack/NewSlackMessage.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
using System;
using SlackAPI.WebSocketMessages;

namespace Microsoft.BotKit.Adapters.Slack
{
public class NewSlackMessage : NewMessage
{
public string Ephemeral { get; set; }

public bool AsUser { get; set; }

public string IconUrl { get; set; }

public string IconEmoji { get; set; }

public string ThreadTS { get; set; }
}
}
Loading

0 comments on commit 30fcf87

Please sign in to comment.