Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #28 , added CLI parameter --exclude-channels, and README updates #29

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ npx slack-archive
--automatic: Don't prompt and automatically fetch all messages from all channels.
--channel-types Comma-separated list of channel types to fetch messages from.
(public_channel, private_channel, mpim, im)
--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.
--no-file-download: Don't download files.
Expand Down Expand Up @@ -107,4 +108,4 @@ your values.
https://{your-team-name}.slack.com/api/oauth.access?client_id={your-client-id}&client_secret={your-client-secret}&code={your-code}"
```

Your browser should now be returning some JSON including a token. Make a note of it - that's what we'll use.
Your browser should now be returning some JSON including a token. Make a note of it - that's what we'll use. Paste it in the command line, OR create a file called `.TOKEN` in the slack-archive directory (created when the command is first run) and paste it in there.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file should be .token (not uppercase)

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

if (AUTOMATIC_MODE || NO_SLACK_CONNECT) {
if (EXCLUDE_CHANNELS) {
const excludeChannels = EXCLUDE_CHANNELS.split(',');
return channels.filter((channel) => !excludeChannels.includes(channel.name || ''));
}
return channels;
}

Expand Down
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const NO_SLACK_CONNECT = findCliParameter("--no-slack-connect");
export const FORCE_HTML_GENERATION = findCliParameter(
"--force-html-generation"
);
export const EXCLUDE_CHANNELS = getCliParameter("--exclude-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
10 changes: 5 additions & 5 deletions src/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ export async function downloadUser(
return users[item.user];

const spinner = ora(`Downloading info for user ${item.user}...`).start();
const user = (
await getWebClient().users.info({
user: item.user,
})
).user;
const user = (item.user === 'U00') ? {} as User : (
await getWebClient().users.info({
user: item.user,
})
).user;

if (user) {
usersRefetchedThisRun.push(item.user);
Expand Down