-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Renaming IActionHandler to IInteractiveMessageHandler and ISlackActio…
…ns to ISlackInteractiveMessages
- Loading branch information
Showing
14 changed files
with
66 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using SlackNet.Interaction; | ||
|
||
namespace SlackNet.AspNetCore | ||
{ | ||
class SlackInteractiveMessagesService : ISlackInteractiveMessages | ||
{ | ||
private readonly ISlackInteractiveMessages _interactiveMessages = new SlackInteractiveMessages(); | ||
|
||
public SlackInteractiveMessagesService(IEnumerable<ResolvedInteractiveMessageHandler> handlers) | ||
{ | ||
foreach (var handler in handlers) | ||
_interactiveMessages.SetHandler(handler.ActionName, handler); | ||
} | ||
|
||
public Task<MessageResponse> Handle(InteractiveMessage request) => _interactiveMessages.Handle(request); | ||
public void SetHandler(string actionName, IInteractiveMessageHandler handler) => _interactiveMessages.SetHandler(actionName, handler); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
|
||
namespace SlackNet.Interaction | ||
{ | ||
public interface ISlackInteractiveMessages | ||
{ | ||
Task<MessageResponse> Handle(InteractiveMessage request); | ||
void SetHandler(string actionName, IInteractiveMessageHandler handler); | ||
} | ||
|
||
public class SlackInteractiveMessages : ISlackInteractiveMessages | ||
{ | ||
private readonly Dictionary<string, IInteractiveMessageHandler> _handlers = new Dictionary<string, IInteractiveMessageHandler>(); | ||
|
||
public Task<MessageResponse> Handle(InteractiveMessage request) => | ||
_handlers.TryGetValue(request.Actions[0].Name, out var handler) | ||
? handler.Handle(request) | ||
: Task.FromResult<MessageResponse>(null); | ||
|
||
public void SetHandler(string actionName, IInteractiveMessageHandler handler) => _handlers[actionName] = handler; | ||
} | ||
} |