Files
houston-be/internal/processor/houston_command_processor.go

39 lines
1.0 KiB
Go
Raw Normal View History

package processor
import (
"fmt"
"github.com/slack-go/slack/socketmode"
"houston/internal/processor/action"
"houston/logger"
"houston/pkg/slackbot"
rcaService "houston/service/rca/impl"
)
type HoustonCommandProcessor struct {
socketModeClient *socketmode.Client
houstonCommandAction *action.HoustonCommandAction
}
const houstonCommandProcessorLogTag = "[houston_command_processor]"
func NewHoustonCommandProcessor(
socketModeClient *socketmode.Client,
slackBot *slackbot.Client,
rcaService *rcaService.RcaService,
) *HoustonCommandProcessor {
return &HoustonCommandProcessor{
socketModeClient: socketModeClient,
houstonCommandAction: action.NewHoustonCommandAction(socketModeClient, slackBot, rcaService),
}
}
func (processor *HoustonCommandProcessor) ProcessSlashCommand(event *socketmode.Event) {
defer func() {
if r := recover(); r != nil {
logger.Error(fmt.Sprintf("%s Exception occurred: %+v", houstonCommandProcessorLogTag, r.(error)))
}
}()
processor.houstonCommandAction.PerformAction(event)
}