diff --git a/README.md b/README.md index eb074f5..bbd764b 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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. diff --git a/src/cli.ts b/src/cli.ts index 9967cd8..244fc0c 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -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"; @@ -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; } diff --git a/src/config.ts b/src/config.ts index c59a011..3107087 100644 --- a/src/config.ts +++ b/src/config.ts @@ -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"); diff --git a/src/users.ts b/src/users.ts index be58a46..eaf8fef 100644 --- a/src/users.ts +++ b/src/users.ts @@ -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);