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

41 lines
996 B
Go

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 CommandProcessor interface {
ProcessSlashCommand(event *socketmode.Event)
}
type SlashCommandProcessor struct {
socketModeClient *socketmode.Client
slashCommandAction *action.HoustonCommandAction
}
func NewSlashCommandProcessor(
socketModeClient *socketmode.Client,
slackBot *slackbot.Client,
rcaService *rcaService.RcaService,
) *SlashCommandProcessor {
return &SlashCommandProcessor{
socketModeClient: socketModeClient,
slashCommandAction: action.NewHoustonCommandAction(socketModeClient, slackBot, rcaService),
}
}
func (scp *SlashCommandProcessor) ProcessSlashCommand(event *socketmode.Event) {
defer func() {
if r := recover(); r != nil {
logger.Error(fmt.Sprintf("[SCP] Exception occurred: %v", r.(error)))
}
}()
scp.slashCommandAction.PerformAction(event)
}