Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ slack-archive
.DS_Store
*.log
.token
lib
lib
.env
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ npx slack-archive
--use-previous-channel-config: Fetch messages from channels selected in previous run instead of prompting.
--channel-types Comma-separated list of channel types to fetch messages from.
(public_channel, private_channel, mpim, im)
--include-channels Comma-separated list of channels to include, in automatic mode
--exclude-channels Comma-separated list of channels to exclude, in automatic mode
--no-backup: Don't create backups. Not recommended.
--no-search: Don't create a search file, saving disk space.
Expand All @@ -53,7 +54,7 @@ This will be mostly painless, I promise.
Head over to https://api.slack.com/apps and `Create New App`. Select `From scratch`.
Give it a name and choose the workspace you'd like to export.

Then, from the `Features` menu on the left, select `OAuth & Permission`.
Then, from the `Features` menu on the left, select `OAuth & Permission`.

As a redirect URL, enter something random that doesn't actually exist, or a domain you control. For instace:

Expand Down Expand Up @@ -100,9 +101,9 @@ https://notarealurl.com/?code={code}&state=
Copy everything between `?code=` and `&state`. This is your `code`. We'll need it in the
next step.

Next, we'll exchange your code for a token. To do so, we'll also need your `client secret`
from the first step when we created your app. In a browser, open this URL - replacing
`{your-team-name}`, `{your-client-id}`, `{your-code}` and `{your-client-secret}` with
Next, we'll exchange your code for a token. To do so, we'll also need your `client secret`
from the first step when we created your app. In a browser, open this URL - replacing
`{your-team-name}`, `{your-client-id}`, `{your-code}` and `{your-client-secret}` with
your values.

```
Expand Down
5 changes: 5 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
EMOJIS_DATA_PATH,
NO_SLACK_CONNECT,
EXCLUDE_CHANNELS,
INCLUDE_CHANNELS,
} from "./config.js";
import { downloadExtras } from "./messages.js";
import { downloadMessages } from "./messages.js";
Expand Down Expand Up @@ -116,6 +117,10 @@ async function selectChannels(
}));

if (AUTOMATIC_MODE || NO_SLACK_CONNECT) {
if (INCLUDE_CHANNELS) {
const includeChannels = INCLUDE_CHANNELS.split(',');
return channels.filter((channel) => includeChannels.includes(channel.name || ''));
}
if (EXCLUDE_CHANNELS) {
const excludeChannels = EXCLUDE_CHANNELS.split(',');
return channels.filter((channel) => !excludeChannels.includes(channel.name || ''));
Expand Down
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const FORCE_HTML_GENERATION = findCliParameter(
"--force-html-generation"
);
export const EXCLUDE_CHANNELS = getCliParameter("--exclude-channels");
export const INCLUDE_CHANNELS = getCliParameter("--include-channels");
export const BASE_DIR = process.cwd();
export const OUT_DIR = path.join(BASE_DIR, "slack-archive");
export const TOKEN_FILE = path.join(OUT_DIR, ".token");
Expand Down