Skip to content
Snippets Groups Projects
Commit 93a24012 authored by James Page's avatar James Page
Browse files

Merge branch '44-add-function-to-send-files-to-slack-channels' into 'main'

Resolve "Add function to send files to Slack channels"

See merge request !59
parents 3858fa25 0a7b47c9
No related branches found
No related tags found
1 merge request!59Resolve "Add function to send files to Slack channels"
......@@ -15,6 +15,18 @@ type SlackField struct {
Value any
}
type SlackFile struct {
File string
FileSize int
Content string
Filename string
Title string
InitialComment string
ThreadTimestamp string
AltTxt string
SnippetText string
}
type SlackClient struct {
Client *slack.Client
}
......@@ -116,6 +128,28 @@ func (s *SlackClient) postMessage(channel string, messageOptions []slack.MsgOpti
return messageTimestamp
}
func (s *SlackClient) SendFile(channel string, file SlackFile) error {
fileParameters := slack.UploadFileV2Parameters{
Channel: channel,
File: file.File,
FileSize: file.FileSize,
Content: file.Content,
Filename: file.Filename,
Title: file.Title,
InitialComment: file.InitialComment,
ThreadTimestamp: file.ThreadTimestamp,
AltTxt: file.AltTxt,
SnippetText: file.SnippetText,
}
_, err := s.Client.UploadFileV2(fileParameters)
if err != nil {
logs.ErrorWithMsg(err, "Error uploading file to slack:")
return err
}
return nil
}
func hasEmoji(message string) bool {
emojiRegex := regexp.MustCompile(`:[a-zA-Z0-9_]+:`)
return emojiRegex.MatchString(message)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment