Documentation ¶
Index ¶
- Variables
- func TestAuth(ctx context.Context, provider auth.Provider) error
- type Option
- func CacheDir(dir string) Option
- func DownloadFiles(b bool) Option
- func MaxUserCacheAge(d time.Duration) Option
- func NumWorkers(n int) Option
- func RetryDownloads(attempts int) Option
- func RetryThreads(attempts int) Option
- func Tier2Boost(eventsPerMin uint) Option
- func Tier2Burst(eventsPerSec uint) Option
- func Tier3Boost(eventsPerMin uint) Option
- func Tier3Burst(eventsPerSec uint) Option
- func UserCacheFilename(s string) Option
- func WithLogger(l logger.Interface) Option
- type Options
- type ProcessFunc
- type ProcessResult
- type ProcessResults
- type Session
- func (sd *Session) Client() *slack.Client
- func (sd *Session) CurrentUserID() string
- func (sd *Session) Dump(ctx context.Context, link string, oldest, latest time.Time, ...) (*types.Conversation, error)
- func (sd *Session) DumpAll(ctx context.Context, link string) (*types.Conversation, error)
- func (sd *Session) DumpAllMessages(ctx context.Context, channelID string) (*types.Conversation, error)deprecated
- func (sd *Session) DumpAllURL(ctx context.Context, slackURL string) (*types.Conversation, error)deprecated
- func (s *Session) DumpEmojis(ctx context.Context) (map[string]string, error)
- func (sd *Session) DumpMessages(ctx context.Context, channelID string, oldest, latest time.Time, ...) (*types.Conversation, error)deprecated
- func (sd *Session) DumpMessagesRaw(ctx context.Context, channelID string, oldest, latest time.Time, ...) (*types.Conversation, error)deprecated
- func (sd *Session) DumpRaw(ctx context.Context, link string, oldest, latest time.Time, ...) (*types.Conversation, error)
- func (sd *Session) DumpThread(ctx context.Context, channelID, threadTS string, oldest, latest time.Time, ...) (*types.Conversation, error)deprecated
- func (sd *Session) DumpURL(ctx context.Context, slackURL string, oldest, latest time.Time, ...) (*types.Conversation, error)deprecated
- func (sd *Session) GetChannelMembers(ctx context.Context, channelID string) ([]string, error)
- func (sd *Session) GetChannels(ctx context.Context, chanTypes ...string) (types.Channels, error)
- func (sd *Session) GetUsers(ctx context.Context) (types.Users, error)
- func (sd *Session) Me() (slack.User, error)
- func (sd *Session) SetFS(fs fsadapter.FS)
- func (sd *Session) StreamChannels(ctx context.Context, chanTypes []string, cb func(ch slack.Channel) error) error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var AllChanTypes = []string{"mpim", "im", "public_channel", "private_channel"}
AllChanTypes enumerates all API-supported channel types as of 03/2023.
var DefOptions = Options{ DumpFiles: false, Workers: defNumWorkers, DownloadRetries: 3, Tier2Boost: 20, Tier2Burst: 1, Tier2Retries: 20, Tier3Boost: 120, Tier3Burst: 1, Tier3Retries: 3, Tier4Boost: 1, Tier4Burst: 1, Tier4Retries: 3, ConversationsPerReq: 200, ChannelsPerReq: 100, RepliesPerReq: 200, UserCacheFilename: "users.cache", MaxUserCacheAge: 4 * time.Hour, CacheDir: ".", Logger: logger.Default, }
DefOptions is the default options used when initialising slackdump instance.
var ( // ErrNoUserCache is returned when the user cache is not available. ErrNoUserCache = errors.New("user cache unavailable") )
Functions ¶
Types ¶
type Option ¶
type Option func(*Options)
Option is the signature of the option-setting function.
func DownloadFiles ¶
DownloadFiles enables or disables the conversation/thread file downloads.
func MaxUserCacheAge ¶
MaxUserCacheAge allows to set the maximum user cache age. If set to 0 - it will always use the API output, and never load cache.
func NumWorkers ¶
NumWorkers allows to set the number of file download workers. n should be in range [1, NumCPU]. If not in range, will be reset to a defNumWorkers number, which seems reasonable.
func RetryDownloads ¶
RetryDownloads sets the number of attempts to download a file when getting rate limited.
func RetryThreads ¶
RetryThreads sets the number of attempts when dumping conversations and threads, and getting rate limited.
func Tier2Boost ¶
Tier2Boost allows to deliver a magic kick to the limiter, to override the base slack Tier limits. The resulting events per minute will be calculated like this:
events_per_sec = (<slack_tier_epm> + <eventsPerMin>) / 60.0
func Tier2Burst ¶
Tier2Burst allows to set the limiter burst value.
func Tier3Boost ¶
Tier3Boost allows to deliver a magic kick to the limiter, to override the base slack Tier limits. The resulting events per minute will be calculated like this:
events_per_sec = (<slack_tier_epm> + <eventsPerMin>) / 60.0
func Tier3Burst ¶
Tier3Burst allows to set the limiter burst value.
func UserCacheFilename ¶
UserCacheFilename allows to set the user cache filename.
func WithLogger ¶ added in v2.0.1
WithLogger allows to set the custom logger.
type Options ¶
type Options struct { DumpFiles bool // will we save the conversation files? Workers int // number of file-saving workers DownloadRetries int // if we get rate limited on file downloads, this is how many times we're going to retry Tier2Boost uint // Tier-2 limiter boost Tier2Burst uint // Tier-2 limiter burst Tier2Retries int // Tier-2 retries when getting 429 on channels fetch Tier3Boost uint // Tier-3 limiter boost allows to increase or decrease the slack Tier req/min rate. Affects all tiers. Tier3Burst uint // Tier-3 limiter burst allows to set the limiter burst in req/sec. Default of 1 is safe. Tier3Retries int // number of retries to do when getting 429 on conversation fetch Tier4Boost uint // Tier-4 limiter boost allows to increase or decrease the slack Tier req/min rate. Affects all tiers. Tier4Burst uint // Tier-4 limiter burst allows to set the limiter burst in req/sec. Default of 1 is safe. Tier4Retries int // number of retries to do when getting 429 on conversation fetch ConversationsPerReq int // number of messages we get per 1 API request. bigger the number, less requests, but they become more beefy. ChannelsPerReq int // number of channels to fetch per 1 API request. RepliesPerReq int // number of thread replies per request (slack default: 1000) UserCacheFilename string // user cache filename MaxUserCacheAge time.Duration // how long the user cache is valid for. NoUserCache bool // disable fetching users from the API. CacheDir string // cache directory Logger logger.Interface }
Options is the option set for the Session.
type ProcessFunc ¶
type ProcessFunc func(msg []types.Message, channelID string) (ProcessResult, error)
ProcessFunc is the signature of the function Dump* functions accept and call for each API call result. It can be used to modify in-place the slice of messages, returned from API, before they are appended to the slice that will be returned by Dump*. Messages passed to this function are unsorted.
type ProcessResult ¶
type ProcessResult struct { // Entity is the type of entity that this result is related to. Entity string // Count is the number of items processed during processing. Count int }
ProcessResult contains the result of processing.
func (ProcessResult) String ¶
func (pr ProcessResult) String() string
type ProcessResults ¶
type ProcessResults []ProcessResult
ProcessResults is the slice of ProcessResult
func (ProcessResults) String ¶
func (prs ProcessResults) String() string
type Session ¶
type Session struct { // Users contains the list of users and populated on NewSession Users types.Users `json:"users"` UserIndex structures.UserIndex `json:"-"` // contains filtered or unexported fields }
Session stores basic session parameters.
func New ¶
New creates new session with the default options and populates the internal cache of users and channels for lookups.
Example (BrowserAuth) ¶
provider, err := auth.NewBrowserAuth(context.Background()) if err != nil { log.Print(err) return } sd, err := New(context.Background(), provider) if err != nil { log.Print(err) return } _ = sd
Output:
Example (CookieFile) ¶
provider, err := auth.NewCookieFileAuth("xoxc-...", "cookies.txt") if err != nil { log.Print(err) return } sd, err := New(context.Background(), provider) if err != nil { log.Print(err) return } _ = sd
Output:
Example (TokenAndCookie) ¶
provider, err := auth.NewValueAuth("xoxc-...", "xoxd-...") if err != nil { log.Print(err) return } sd, err := New(context.Background(), provider) if err != nil { log.Print(err) return } _ = sd
Output:
func NewWithOptions ¶
func NewWithOptions(ctx context.Context, authProvider auth.Provider, opts Options) (*Session, error)
New creates new Session with provided options, and populates the internal cache of users and channels for lookups. If it fails to authenticate, AuthError is returned.
func (*Session) CurrentUserID ¶ added in v2.0.1
func (*Session) Dump ¶ added in v2.0.1
func (sd *Session) Dump(ctx context.Context, link string, oldest, latest time.Time, processFn ...ProcessFunc) (*types.Conversation, error)
Dump dumps messages or threads specified by link. link can be one of the following:
- Channel URL - i.e. https://ora600.slack.com/archives/CHM82GF99
- Thread URL - i.e. https://ora600.slack.com/archives/CHM82GF99/p1577694990000400
- ChannelID - i.e. CHM82GF99
- ChannelID:ThreadTS - i.e. CHM82GF99:1577694990.000400
oldest and latest timestamps set a timeframe within which the messages should be retrieved, also one can provide process functions.
func (*Session) DumpAll ¶ added in v2.0.1
DumpAll dumps all messages. See description of Dump for what can be provided in link.
func (*Session) DumpAllMessages
deprecated
func (*Session) DumpAllURL
deprecated
func (*Session) DumpEmojis ¶ added in v2.2.0
func (*Session) DumpMessages
deprecated
func (sd *Session) DumpMessages(ctx context.Context, channelID string, oldest, latest time.Time, processFn ...ProcessFunc) (*types.Conversation, error)
DumpMessages dumps messages in the given timeframe between oldest and latest. If oldest or latest are zero time, they will not be accounted for. Having both oldest and latest as Zero-time, will make this function behave similar to DumpMessages. ProcessFn is a slice of post-processing functions that will be called for each message chunk downloaded from the Slack API.
Deprecated: Use Dump, this function will be unexported in v3.
func (*Session) DumpMessagesRaw
deprecated
func (sd *Session) DumpMessagesRaw(ctx context.Context, channelID string, oldest, latest time.Time, processFn ...ProcessFunc) (*types.Conversation, error)
DumpMessagesRaw dumps all messages, but does not account for any options defined, such as DumpFiles, instead, the caller must hassle about any processFns they want to apply.
Deprecated: Use DumpRaw, this function will be unexported in v3.
func (*Session) DumpRaw ¶ added in v2.0.1
func (sd *Session) DumpRaw(ctx context.Context, link string, oldest, latest time.Time, processFn ...ProcessFunc) (*types.Conversation, error)
DumpRaw dumps all messages, but does not account for any options defined, such as DumpFiles, instead, the caller must hassle about any processFns they want to apply.
func (*Session) DumpThread
deprecated
func (sd *Session) DumpThread( ctx context.Context, channelID, threadTS string, oldest, latest time.Time, processFn ...ProcessFunc, ) (*types.Conversation, error)
DumpThread dumps a single thread identified by (channelID, threadTS). Optionally one can provide a number of processFn that will be applied to each chunk of messages returned by a one API call.
Deprecated: Use Dump, this function will be unexported in v3.
func (*Session) DumpURL
deprecated
func (sd *Session) DumpURL(ctx context.Context, slackURL string, oldest, latest time.Time, processFn ...ProcessFunc) (*types.Conversation, error)
DumpURL acts like DumpAllURL but allows to specify oldest and latest timestamps to define a window within which the messages should be retrieved, also one can provide process functions.
Deprecated: Use Dump, this function will be removed in v3.
func (*Session) GetChannelMembers ¶ added in v2.4.0
GetChannelMembers returns a list of all members in a channel.
func (*Session) GetChannels ¶
GetChannels list all conversations for a user. `chanTypes` specifies the type of messages to fetch. See github.com/rusq/slack docs for possible values. If large number of channels is to be returned, consider using StreamChannels.
func (*Session) Me ¶
Me returns the current authenticated user in a rather dirty manner. If the user cache is unitnitialised, it returns ErrNoUserCache.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
browser/pwcompat
Package pwcompat provides a compatibility layer, so when the playwright-go team decides to break compatibility again, there's a place to write a workaround.
|
Package pwcompat provides a compatibility layer, so when the playwright-go team decides to break compatibility again, there's a place to write a workaround. |
cmd
|
|
contrib
|
|
Package downloader provides the sync and async file download functionality.
|
Package downloader provides the sync and async file download functionality. |
internal
|
|
app/emoji
Package emoji provides functions to dump the all slack emojis for a workspace.
|
Package emoji provides functions to dump the all slack emojis for a workspace. |
edge
Package edge provides a limited implementation of undocumented Slack Edge API necessary to get the data from a slack workspace.
|
Package edge provides a limited implementation of undocumented Slack Edge API necessary to get the data from a slack workspace. |
encio
Package encio provides encrypted using AES-256-CFB input/output functions.
|
Package encio provides encrypted using AES-256-CFB input/output functions. |
mocks/mock_app
Code generated by MockGen.
|
Code generated by MockGen. |
mocks/mock_auth
Code generated by MockGen.
|
Code generated by MockGen. |
mocks/mock_dl
Code generated by MockGen.
|
Code generated by MockGen. |
mocks/mock_downloader
Code generated by MockGen.
|
Code generated by MockGen. |
mocks/mock_fsadapter
Code generated by MockGen.
|
Code generated by MockGen. |
mocks/mock_io
Code generated by MockGen.
|
Code generated by MockGen. |
mocks/mock_os
Code generated by MockGen.
|
Code generated by MockGen. |
structures
Package structures provides functions to parse Slack data types.
|
Package structures provides functions to parse Slack data types. |
structures/files
Package files contains some additional file logic.
|
Package files contains some additional file logic. |
ui
Package ui contains some common UI elements, that use Survey library.
|
Package ui contains some common UI elements, that use Survey library. |
ui/ask
Package ask provides common functions for asking questions for getting user input on dump and export parameters.
|
Package ask provides common functions for asking questions for getting user input on dump and export parameters. |
tools
|
|
slackutil
Command slackutil is an utility that provides some useful functions for testing, i.e.
|
Command slackutil is an utility that provides some useful functions for testing, i.e. |