fooocos-telegram-bot/README.md

3.5 KiB

fooocos-telegram-bot

bot

⚠️ The project may contain some bugs and errors, provided as is

Dynamic inline bot leveraging the robust capabilities of Fooocos for image generation. This bot integrates seamlessly with Telegram, offering an intuitive and engaging user experience.

Current FooocosAPI commit hash: bf2f2c745a159e13b8de93fd000470ed98c973c4

Mirror on my Git

Getting Started

System Requirements

Before diving in, ensure your system meets these prerequisites:

  • Git
  • Python >= 3.10
  • NodeJS >= 20
  • An Nvidia GPU with a minimum of 4GB VRAM (other GPUs may be supported; check the official Fooocos repository for details).

Installation Guide for Windows

This guide for Windows only, but for Linux the logic is exactly the same, but the commands may be slightly different

Install the correct FooocosAPI version locally:

  1. Clone the FooocosAPI repository:
git clone https://github.com/konieshadow/Fooocus-API/tree/bf2f2c745a159e13b8de93fd000470ed98c973c4
  1. Navigate to the cloned directory:
cd Fooocus-API
  1. Create and activate a Python virtual environment:
python -m venv venv
.\venv\Scripts\activate
  1. Install requirements:
pip install -r requirements.txt
  1. Launch FooocosAPI:
python .\main.py --host 0.0.0.0

If successful, you should see output similar to this:

output

For subsequent runs, simply activate the virtual environment and start the API:

.\venv\Scripts\activate
python .\main.py --host 0.0.0.0

Tip: You can also try the latest FooocosAPI version, but you might need to copy and replace openapi.json from http://localhost:8888/openapi.json (default) to fooocos directory, regenerate the client (npm run fooocos:typegen) and address any possible TypeScript compiler errors.

Setting Up the Bot:

  1. Clone this repository
git clone https://github.com/xzeldon/fooocos-telegram-bot.git
  1. Install dependencies:
npm i
  1. Prepare your configuration file:
  • Duplicate the .env.sample file and rename it to .env.
  • Edit the .env file with your specific details as per the table below:
Variable Type Description
NODE_ENV String Specifies the application environment. (development or production)
BOT_TOKEN String Telegram Bot API token obtained from @BotFather.
FOOOCOS_API_URL String URL of the Fooocos-API endpoint.
DUMMY_CHAT_ID String ID of a dummy chat for uploading images to retrieve their file_id for inline message editing.
  1. Start the bot:

    • For development with hot reload:

      npm run dev
      
    • For standard operation:

      npm run start
      

License

This project is open-source, licensed under the MIT License. Feel free to use, modify, and distribute it as you see fit.