UNPKG

insta-meme-bot-cli

Version:

Production-ready Instagram meme bot that scrapes memes from Pinterest and posts them automatically with CLI and programmatic API support

91 lines (78 loc) 2.36 kB
/** * Instagram Meme Bot - Main Entry Point * * This is the main entry point for programmatic usage of the Instagram Meme Bot. * For CLI usage, use the bin command: instagram-meme-bot */ // Load environment variables require('dotenv').config(); // Export main classes for programmatic usage const InstagramMemeBot = require('./src/bot'); const PinterestScraper = require('./src/scrapers/pinterest'); const InstagramPoster = require('./src/instagram/poster'); const Utils = require('./src/utils'); /** * Quick start function for easy usage * @param {Object} config - Bot configuration * @returns {Promise<InstagramMemeBot>} Configured bot instance */ async function createBot(config = {}) { // Merge with environment variables const botConfig = { username: config.username || process.env.INSTA_USERNAME, password: config.password || process.env.INSTA_PASSWORD, memeType: config.memeType || 'funny', interval: config.interval || '60m', ...config }; // Validate required fields if (!botConfig.username || !botConfig.password) { throw new Error('Instagram username and password are required'); } return new InstagramMemeBot(botConfig); } /** * Post a single meme (convenience function) * @param {Object} config - Configuration options * @returns {Promise<Object>} Post result */ async function postMeme(config = {}) { const bot = await createBot(config); return await bot.postSingleMeme(); } /** * Start the bot in continuous mode (convenience function) * @param {Object} config - Configuration options * @returns {Promise<InstagramMemeBot>} Running bot instance */ async function startBot(config = {}) { const bot = await createBot(config); await bot.start(); return bot; } /** * Test bot configuration (convenience function) * @param {Object} config - Configuration options * @returns {Promise<Object>} Test results */ async function testBot(config = {}) { const bot = await createBot(config); return await bot.test(); } // Export everything module.exports = { // Main classes InstagramMemeBot, PinterestScraper, InstagramPoster, Utils, // Convenience functions createBot, postMeme, startBot, testBot, // Constants MEME_CATEGORIES: PinterestScraper.getMemeCategories() }; // Default export for ES6 modules module.exports.default = InstagramMemeBot;