files

package
v2.5.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 7, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package files contains some additional file logic.

Index

Constants

View Source
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

func Update(msgs []types.Message, addr Addr, fn func(*slack.File) error) error

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

func UpdateFileLinksAll(f *slack.File, fn func(ptrS *string) error) error

UpdateFileLinksAll calls fn with pointer to each file URL except permalinks. fn can modify the string pointed by ptrS.

func UpdateFileLinksPrivate added in v2.2.0

func UpdateFileLinksPrivate(f *slack.File, fn func(ptrS *string) error) error

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

type UpdateFunc func(f *slack.File) error

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL