UNPKG

build-in-public-bot

Version:

AI-powered CLI bot for automating build-in-public tweets with code screenshots

68 lines • 3.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.showAutomationCommand = exports.configAutomationCommand = void 0; const commander_1 = require("commander"); const config_1 = require("../services/config"); const logger_1 = require("../utils/logger"); const errors_1 = require("../utils/errors"); exports.configAutomationCommand = new commander_1.Command('automation') .description('Configure Twitter automation method') .argument('<method>', 'Automation method: puppeteer, playwright, or nodriver') .action(async (method) => { try { const validMethods = ['puppeteer', 'playwright', 'nodriver']; if (!validMethods.includes(method)) { throw new errors_1.TwitterError(`Invalid automation method. Choose one of: ${validMethods.join(', ')}`); } const configService = config_1.ConfigService.getInstance(); const config = await configService.load(); config.twitter.automationMethod = method; await configService.save(config); logger_1.logger.success(`āœ… Twitter automation method set to: ${method}`); if (method === 'nodriver') { logger_1.logger.info('\nšŸ“ Note: nodriver requires Python 3 and the nodriver package.'); logger_1.logger.info('Install with: pip3 install nodriver'); } else if (method === 'playwright') { logger_1.logger.info('\nšŸ“ Note: playwright will be installed automatically.'); logger_1.logger.info('First run may take longer to download browser binaries.'); } logger_1.logger.info('\nšŸ” Method characteristics:'); switch (method) { case 'puppeteer': logger_1.logger.info('- Original implementation'); logger_1.logger.info('- Good compatibility'); logger_1.logger.info('- May be detected by Twitter'); break; case 'playwright': logger_1.logger.info('- Better performance than Puppeteer'); logger_1.logger.info('- Built-in stealth features'); logger_1.logger.info('- Works well with non-headless mode'); break; case 'nodriver': logger_1.logger.info('- Most advanced anti-detection'); logger_1.logger.info('- No WebDriver protocol'); logger_1.logger.info('- Requires Python environment'); break; } } catch (error) { logger_1.logger.error('Failed to configure automation method:', error); process.exit(1); } }); exports.showAutomationCommand = new commander_1.Command('show-automation') .description('Show current Twitter automation method') .action(async () => { try { const configService = config_1.ConfigService.getInstance(); const config = await configService.load(); const method = config.twitter.automationMethod || 'puppeteer'; logger_1.logger.info(`Current automation method: ${method}`); } catch (error) { logger_1.logger.error('Failed to show automation method:', error); process.exit(1); } }); //# sourceMappingURL=config-automation.js.map