Improve tweet read reliability and test coverage
This commit is contained in:
+1
-13
@@ -11,6 +11,7 @@
|
||||
|
||||
import { Command } from 'commander';
|
||||
import { resolveCredentials } from './lib/cookies.js';
|
||||
import { extractTweetId } from './lib/extract-tweet-id.js';
|
||||
import { TwitterClient } from './lib/twitter-client.js';
|
||||
|
||||
const program = new Command();
|
||||
@@ -23,19 +24,6 @@ program
|
||||
.option('--ct0 <token>', 'Twitter ct0 cookie')
|
||||
.option('--chrome-profile <name>', 'Chrome profile name for cookie extraction');
|
||||
|
||||
/**
|
||||
* Extract tweet ID from URL or return as-is if already an ID
|
||||
*/
|
||||
function extractTweetId(input: string): string {
|
||||
// If it's a URL, extract the tweet ID
|
||||
const urlMatch = input.match(/(?:twitter\.com|x\.com)\/\w+\/status\/(\d+)/);
|
||||
if (urlMatch) {
|
||||
return urlMatch[1];
|
||||
}
|
||||
// Assume it's already an ID
|
||||
return input;
|
||||
}
|
||||
|
||||
// Tweet command
|
||||
program
|
||||
.command('tweet')
|
||||
|
||||
Reference in New Issue
Block a user