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

41 lines
996 B
Go
Raw Normal View History

2023-04-10 17:30:28 +05:30
package processor
import (
"fmt"
2023-06-13 03:23:24 +05:30
"github.com/slack-go/slack/socketmode"
"houston/internal/processor/action"
"houston/logger"
"houston/pkg/slackbot"
rcaService "houston/service/rca/impl"
2023-04-10 17:30:28 +05:30
)
2023-06-13 03:23:24 +05:30
type CommandProcessor interface {
ProcessSlashCommand(event *socketmode.Event)
}
2023-04-10 17:30:28 +05:30
type SlashCommandProcessor struct {
socketModeClient *socketmode.Client
slashCommandAction *action.HoustonCommandAction
2023-04-10 17:30:28 +05:30
}
2023-06-13 03:23:24 +05:30
func NewSlashCommandProcessor(
socketModeClient *socketmode.Client,
slackBot *slackbot.Client,
rcaService *rcaService.RcaService,
2023-06-13 03:23:24 +05:30
) *SlashCommandProcessor {
2023-04-10 17:30:28 +05:30
return &SlashCommandProcessor{
socketModeClient: socketModeClient,
slashCommandAction: action.NewHoustonCommandAction(socketModeClient, slackBot, rcaService),
2023-04-10 17:30:28 +05:30
}
}
2023-06-13 03:23:24 +05:30
func (scp *SlashCommandProcessor) ProcessSlashCommand(event *socketmode.Event) {
2023-04-10 17:30:28 +05:30
defer func() {
if r := recover(); r != nil {
logger.Error(fmt.Sprintf("[SCP] Exception occurred: %v", r.(error)))
2023-04-10 17:30:28 +05:30
}
}()
2023-06-13 03:23:24 +05:30
scp.slashCommandAction.PerformAction(event)
}