2023-11-30 11:56:32 +05:30
|
|
|
package processor
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"github.com/slack-go/slack/socketmode"
|
|
|
|
|
"houston/internal/processor/action"
|
|
|
|
|
"houston/logger"
|
|
|
|
|
"houston/pkg/slackbot"
|
2024-02-01 15:23:15 +05:30
|
|
|
rcaService "houston/service/rca/impl"
|
2023-11-30 11:56:32 +05:30
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type HoustonCommandProcessor struct {
|
|
|
|
|
socketModeClient *socketmode.Client
|
|
|
|
|
houstonCommandAction *action.HoustonCommandAction
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const houstonCommandProcessorLogTag = "[houston_command_processor]"
|
|
|
|
|
|
|
|
|
|
func NewHoustonCommandProcessor(
|
|
|
|
|
socketModeClient *socketmode.Client,
|
|
|
|
|
slackBot *slackbot.Client,
|
2024-02-01 15:23:15 +05:30
|
|
|
rcaService *rcaService.RcaService,
|
2023-11-30 11:56:32 +05:30
|
|
|
) *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)
|
|
|
|
|
}
|