Isolate functions
This commit is contained in:
@@ -177,26 +177,7 @@ func generateAttachmentsFromJobResponse(j *types.JobResult) (attachments []slack
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Slack) handleChannelMessage(
|
func scanImagesInMessages(api *slack.Client, ev *slackevents.MessageEvent) (*bytes.Buffer, string) {
|
||||||
a *agent.Agent,
|
|
||||||
api *slack.Client, ev *slackevents.MessageEvent, b *slack.AuthTestResponse, postMessageParams slack.PostMessageParameters) {
|
|
||||||
if t.channelID == "" && !t.alwaysReply || // If we have set alwaysReply and no channelID
|
|
||||||
t.channelID != ev.Channel { // If we have a channelID and it's not the same as the event channel
|
|
||||||
// Skip messages from other channels
|
|
||||||
xlog.Info("Skipping reply to channel", ev.Channel, t.channelID)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if b.UserID == ev.User {
|
|
||||||
// Skip messages from ourselves
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
currentConv := t.conversationTracker.GetConversation(t.channelID)
|
|
||||||
|
|
||||||
message := replaceUserIDsWithNamesInMessage(api, cleanUpUsernameFromMessage(ev.Text, b))
|
|
||||||
|
|
||||||
go func() {
|
|
||||||
imageBytes := new(bytes.Buffer)
|
imageBytes := new(bytes.Buffer)
|
||||||
mimeType := "image/jpeg"
|
mimeType := "image/jpeg"
|
||||||
|
|
||||||
@@ -226,6 +207,31 @@ func (t *Slack) handleChannelMessage(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return imageBytes, mimeType
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *Slack) handleChannelMessage(
|
||||||
|
a *agent.Agent,
|
||||||
|
api *slack.Client, ev *slackevents.MessageEvent, b *slack.AuthTestResponse, postMessageParams slack.PostMessageParameters) {
|
||||||
|
if t.channelID == "" && !t.alwaysReply || // If we have set alwaysReply and no channelID
|
||||||
|
t.channelID != ev.Channel { // If we have a channelID and it's not the same as the event channel
|
||||||
|
// Skip messages from other channels
|
||||||
|
xlog.Info("Skipping reply to channel", ev.Channel, t.channelID)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if b.UserID == ev.User {
|
||||||
|
// Skip messages from ourselves
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
currentConv := t.conversationTracker.GetConversation(t.channelID)
|
||||||
|
|
||||||
|
message := replaceUserIDsWithNamesInMessage(api, cleanUpUsernameFromMessage(ev.Text, b))
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
imageBytes, mimeType := scanImagesInMessages(api, ev)
|
||||||
|
|
||||||
agentOptions := []types.JobOption{
|
agentOptions := []types.JobOption{
|
||||||
types.WithUUID(ev.ThreadTimeStamp),
|
types.WithUUID(ev.ThreadTimeStamp),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user