Skip to content

ngocpt1906/page-bot

Repository files navigation

Page Bot

A Telegram bot built with TypeScript that automates content generation and social media posting. It leverages Google's Generative AI (Gemini) to create engaging content and Puppeteer to interact with Facebook groups.

Features

  • AI-Powered Content Generation: Uses Google Gemini (models/gemini-2.0-flash) to generate witty and engaging posts based on keywords.
  • Automated Facebook Posting: Automates the process of posting content to specified Facebook groups using Puppeteer.
  • Telegram Interface: Interact with the bot directly through Telegram commands.
  • MongoDB Integration: Stores user states and post history.
  • Docker Support: Easily containerized for deployment.

Prerequisites

Installation

  1. Clone the repository:

    git clone https://github.com/ngocpt1906/page-bot.git
    cd page-bot
  2. Install dependencies:

    yarn install
    # or
    npm install

Configuration

Create a .env file in the root directory with the following environment variables:

# Telegram Bot Token (Get from @BotFather)
BOT_TOKEN=your_telegram_bot_token_here
TELEGRAM_BOT_TOKEN=your_telegram_bot_token_here # Required for FileHandler

# Google Generative AI API Key
GEMINI_API_KEY=your_gemini_api_key

# MongoDB Connection String
MONGODB_URI=mongodb://localhost:27017/page-bot

# Facebook Authentication (Cookies for Puppeteer)
FACEBOOK_C_USER=your_c_user_cookie_value
FACEBOOK_XS=your_xs_cookie_value

Running the Bot

Local Development

To run the bot in development mode with hot reloading:

yarn dev
# or
npm run dev

Production

To build and run the bot for production:

yarn build
yarn start
# or
npm run build
npm start

Using Docker

You can also run the bot and MongoDB using Docker Compose:

  1. Ensure you have Docker and Docker Compose installed.

  2. Update docker-compose.yml or your .env file with the necessary credentials.

  3. Run the containers:

    docker-compose up -d

Project Structure

  • src/index.ts: Entry point of the application.
  • src/botFactory.ts: configuration and command registration for the Telegram bot.
  • src/commands/: Contains command handlers (e.g., /start, /post).
  • src/crawler/: Puppeteer scripts for browser automation (Facebook interaction).
  • src/services/: Database and file handling services.
  • src/utils/: Utility functions and helper classes.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors