Skip to content
This repository was archived by the owner on Sep 10, 2025. It is now read-only.
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Additionally you can set these environment variables to customize behavior:
- `API_DELAY` = Delay between Bluesky API calls in milliseconds
- `IGNORE_VIDEO_ERRORS` = if set to "1" continue processing tweets when a video submission fails
- `VIDEO_UPLOAD_RETRIES` = set to the number of times to attempt to upload a video if JOB_STATE_FAILED encountered
- `MENTIONS_TO_IGNORE` = one or more x/twitter handles without @, comma-separated, case-insensitive. Mentions to these handles will cause tweets to be skipped (e.g., 'ignoreduser1,ignoreduser2').

**Example of a `.env` file:**

Expand Down Expand Up @@ -119,6 +120,9 @@ These arguments are optional and help customize the import:
- `--video-upload-retries` - Number of times to retry uploading videos if JOB_STATE_FAILED encountered.
Example: `--video-upload-retries 5`

- `--mentions-to-ignore <handles>` - A list of Twitter handles (without @) whose mentions will be ignored during the import. Mentions to these handles will cause the tweets to be skipped.
Example: `--mentions-to-ignore ignoreduser1 ignoreduser2`

**Examples when running on Windows**

Assuming you stored the Twitter archive in `C:\Temp\twitter-archive` and you want to import tweets from two Twitter handles:
Expand Down
15 changes: 15 additions & 0 deletions app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -529,9 +529,16 @@ async function main() {
description: "Number of times to retry video uploads when error JOB_STATE_FAILED encountered",
default: process.env.VIDEO_UPLOAD_RETRIES ? parseInt(process.env.VIDEO_UPLOAD_RETRIES) : 1,
})
.option('mentions-to-ignore', {
type: 'array',
description: 'List of Twitter handles whose mentions should be ignored in the tweets',
default: process.env.MENTIONS_TO_IGNORE?.split(',') || [],
})
.help()
.argv;

const mentionsToIgnore = (argv.mentionsToIgnore as string[]).map(handle => handle.toLowerCase());

let minDate = argv.minDate ? new Date(argv.minDate) : undefined;
let maxDate = argv.maxDate ? new Date(argv.maxDate) : undefined;

Expand Down Expand Up @@ -592,6 +599,14 @@ async function main() {
console.log(` Created at ${tweet_createdAt}`);
console.log(` Full text '${tweet.full_text}'`);

if (tweet.entities?.user_mentions) {
const mentionedHandles = tweet.entities.user_mentions.map(mention => mention.screen_name.toLowerCase());
if (mentionsToIgnore.some(ignoreHandle => mentionedHandles.includes(ignoreHandle))) {
console.log(`Discarded (contains mention to ignored handle)`);
continue;
}
}

if (argv.disableImportReply && tweet.in_reply_to_screen_name) {
console.log("Discarded (reply)");
continue;
Expand Down