* TP-49403 | parameterized slash command * TP-49403 | handeling resolve and rca params also implemented Help-Commands button * TP-49403 | using command pattern for command resolutiuon and execution * TP-49403 | made find team by name and find severity by name queries case insensitive * TP-49403 | updating help message keys
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
package processor
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/slack-go/slack"
|
|
"github.com/slack-go/slack/socketmode"
|
|
"houston/internal/processor/action"
|
|
"houston/logger"
|
|
)
|
|
|
|
type HelpCommandProcessor struct {
|
|
socketModeClient *socketmode.Client
|
|
helpCommandAction *action.HelpCommandsAction
|
|
}
|
|
|
|
const helpCommandProcessorLogTag = "[help_command_processor]"
|
|
|
|
func NewHelpCommandProcessor(
|
|
socketModeClient *socketmode.Client,
|
|
) *HelpCommandProcessor {
|
|
return &HelpCommandProcessor{
|
|
socketModeClient: socketModeClient,
|
|
helpCommandAction: action.NewHelpCommandsAction(socketModeClient),
|
|
}
|
|
}
|
|
|
|
func (processor *HelpCommandProcessor) ProcessSlashCommand(event *socketmode.Event) {
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
logger.Error(fmt.Sprintf("%s Exception occurred: %+v", helpCommandProcessorLogTag, r.(error)))
|
|
}
|
|
}()
|
|
cmd, ok := event.Data.(slack.SlashCommand)
|
|
if !ok {
|
|
logger.Error(fmt.Sprintf("%s failed to convert event data into slash command for data: %+v", helpCommandProcessorLogTag, event.Data))
|
|
return
|
|
}
|
|
processor.helpCommandAction.ProcessAction(cmd.UserID, cmd.ChannelID, event.Request)
|
|
}
|