Documentation ¶
Overview ¶
Package files contains some additional file logic.
Index ¶
- Constants
- func Extract(msgs []types.Message, idxParentMsg int, ...) error
- func Update(msgs []types.Message, addr Addr, fn func(*slack.File) error) error
- func UpdateFileLinksAll(f *slack.File, fn func(ptrS *string) error) error
- func UpdateFileLinksPrivate(f *slack.File, fn func(ptrS *string) error) error
- type Addr
- type UpdateFunc
Constants ¶
const Root = -1
Root is the parent address for the topmost message chunk.
Variables ¶
This section is empty.
Functions ¶
func Extract ¶
func Extract(msgs []types.Message, idxParentMsg int, fn func(file slack.File, addr Addr) error) error
Extract scans the message slice msgs, and calls fn for each file it finds. fn is called with the copy of the file and the files' address in the provided message slice. idxParentMsg is the index of the parent message (for message replies slice), or refRoot if it's the topmost messages slice (see invocation in downloadFn).
func Update ¶ added in v2.2.0
Update locates the file by address addr, and calls fn with the pointer to that file. Addr contains an address of the message and the file within the message slice to update. It will return an error if the address references out of range.
func UpdateFileLinksAll ¶ added in v2.2.0
UpdateFileLinksAll calls fn with pointer to each file URL except permalinks. fn can modify the string pointed by ptrS.
Types ¶
type Addr ¶
type Addr struct {
// contains filtered or unexported fields
}
Addr is the address of the file in the messages slice.
idxMsg - index of the message or message reply in the provided slice idxParMsg - index of the parent message. If it is not equal to Root constant, then it's the address of the message: msg[idxMsg].File[idxFile] if it is not equal to Root, then it is assumed that it is an address of a message (thread) reply: msg[idxParMsg].ThreadReplies[idxMsg].File[idxFile] idxFile - index of the file in the message's file slice.
type UpdateFunc ¶ added in v2.2.0
UpdateFunc is the signature of the function that modifies the file passed as an argument.
func UpdatePathFn ¶ added in v2.2.0
func UpdatePathFn(path string) UpdateFunc
UpdatePathFn sets the URLPrivate and URLPrivateDownload for the file at addr to the specified path.
func UpdateTokenFn ¶ added in v2.2.0
func UpdateTokenFn(token string) UpdateFunc
UpdateTokenFn returns a file update function that adds the t= query parameter with token value. If token value is empty, the function does nothing.