{"id":22432648,"url":"https://github.com/1999azzar/telegram-image-generation-bot","last_synced_at":"2025-07-18T11:04:02.722Z","repository":{"id":208710609,"uuid":"722309887","full_name":"1999AZZAR/telegram-image-generation-bot","owner":"1999AZZAR","description":"telegram bot for generating image using the stability.ai","archived":false,"fork":false,"pushed_at":"2024-11-17T20:20:25.000Z","size":94,"stargazers_count":3,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-17T20:36:49.809Z","etag":null,"topics":["ai","image-generation","python","stability-ai","telegram-bot"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/1999AZZAR.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-22T21:37:08.000Z","updated_at":"2024-11-17T20:20:28.000Z","dependencies_parsed_at":"2024-11-17T20:25:12.818Z","dependency_job_id":"41f66e00-7f41-43f4-afc0-08f92d36b6ca","html_url":"https://github.com/1999AZZAR/telegram-image-generation-bot","commit_stats":null,"previous_names":["1999azzar/telegram-image-generation-bot"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1999AZZAR%2Ftelegram-image-generation-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1999AZZAR%2Ftelegram-image-generation-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1999AZZAR%2Ftelegram-image-generation-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1999AZZAR%2Ftelegram-image-generation-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/1999AZZAR","download_url":"https://codeload.github.com/1999AZZAR/telegram-image-generation-bot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228377694,"owners_count":17910449,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","image-generation","python","stability-ai","telegram-bot"],"created_at":"2024-12-05T22:12:25.769Z","updated_at":"2025-06-15T22:33:25.552Z","avatar_url":"https://github.com/1999AZZAR.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Telegram Bot for Image Generation\n\nThis Telegram bot allows users to generate images based on provided prompts and styles using the Stability AI image generation API. The project is organized into two main files: `main.py` and `helper.py`.\n\n## Table of Contents\n\n- [Telegram Bot for Image Generation](#telegram-bot-for-image-generation)\n  - [Table of Contents](#table-of-contents)\n  - [1. Files and Structure](#1-files-and-structure)\n    - [1.1 `main.py`](#11-mainpy)\n    - [1.2 `helper.py`](#12-helperpy)\n  - [2. Getting Started](#2-getting-started)\n    - [2.1 Prerequisites](#21-prerequisites)\n    - [2.2 Setting up Environment Variables](#22-setting-up-environment-variables)\n    - [2.3 Running the Bot](#23-running-the-bot)\n  - [3. Usage](#3-usage)\n  - [4. Directory Structure](#4-directory-structure)\n  - [5. Flowchart](#5-flowchart)\n  - [6. Notes](#6-notes)\n\n---\n\n## 1. Files and Structure\n\n### 1.1 `main.py`\n\nThis file serves as the main entry point for the Telegram bot. It contains the following key components:\n\n- **Telegram Bot Setup**: Import required libraries, load environment variables, and configure logging.\n- **State Constants**: Constants for different states of the conversation.\n- **Conversation Handling**: Set up a ConversationHandler to manage user interactions.\n- **Image Generation data**: Functions like `image` and `handle_text` to handle user commands and inputs.\n- **Telegram Bot Initialization**: Set up the Telegram bot, add handlers, and start the bot.\n\n### 1.2 `helper.py`\n\nThis file contains utility functions related to image generation. It includes:\n\n- **Image Generation Function**: The `generate_image` function takes user prompts and styles as input and interacts with the Stability AI API to generate images.\n\n## 2. Getting Started\n\nFollow these steps to set up and run the Telegram bot:\n\n### 2.1 Prerequisites\n\n- Python 3.11 or higher installed on your system.\n\n- Required libraries: `python-telegram-bot`, `requests`, `dotenv`. Install them using:\n  \n  ```bash\n  pip install python-telegram-bot requests python-dotenv\n  ```\n\n### 2.2 Setting up Environment Variables\n\n1. Create a `.env` file in the project directory.\n\n2. Add the following entries to the `.env` file:\n   \n   ```dotenv\n   STABILITY_API_KEY=your_stability_api_key\n   TELEGRAM_BOT_TOKEN=your_telegram_bot_token\n   USER_ID=\"*\" # comma for separation, '*' to enable all user access.\n   ADMIN_ID=\"*\" # comma for separation, '*' to enable all user access.\n   ```\n   \n    Replace `your_stability_api_key`, `your_telegram_bot_token` and user and/or admin id  with your Stability AI API key, Telegram bot token and telegram id, respectively.\n\n### 2.3 Running the Bot\n\nRun the `main.py` script to start the Telegram bot:\n\n```bash\npython main.py\n```\n\nThe bot is now active and ready to respond to commands.\n\n## 3. Usage\n\n1. Start a conversation with the Telegram bot.\n2. Use the `/image` command to initiate the image generation process.\n3. Follow the prompts to provide input for image generation, including prompts and style selections.\n4. The bot will process the input, generate an image using the Stability AI API, and send the generated image back to the user.\n\n## 4. Directory Structure\n\nThe project directory is organized as follows:\n\n```plaintext\nproject-directory/\n│\n├── main.py\n├── helper.py\n├── .env\n└── out/\n    ├── (generated images)\n```\n\n- `main.py`: Main script for the Telegram bot.\n- `helper.py`: Helper script containing utility functions.\n- `.env`: Configuration file for storing environment variables.\n- `out/`: Directory to store generated images.\n\n## 5. Flowchart\n\n```mermaid\ngraph LR\n\nsubgraph MainFunction\n  A[Start]\n  B[User sends /image command]\n  C[Bot asks for prompt]\n  D[User provides prompt]\n  E[Bot ask for size]\n  F[User provide size]\n  G[Bot asks for style]\n  H[User provides style]\n  I[Bot processes input]\n  J[Bot generates image]\n  K[Bot sends image to user]\n  L[End]\n\n  A --\u003e|Initiate| B\n  B --\u003e|Command received| C\n  C --\u003e|Ask for prompt| D\n  D --\u003e|Prompt received| E\n  E --\u003e|Ask for size| F\n  F --\u003e|Size received| G\n  G --\u003e|Ask for style| H\n  H --\u003e|Style received| I\n  I --\u003e|Process input| J\n  J --\u003e|Generate image| HelperFunctions\n  HelperFunctions --\u003e|Send image| K\n  K --\u003e |image send| L\n  L --\u003e|End| B\nend\n\nsubgraph HelperFunctions\n  M[Helper function: generate_image]\nend\n\nstyle A fill:#C21292,stroke:#000,stroke-width:2px;\nstyle B fill:#EF4040,stroke:#000,stroke-width:2px;\nstyle C fill:#711DB0,stroke:#000,stroke-width:2px;\nstyle D fill:#FF90BC,stroke:#000,stroke-width:2px;\nstyle E fill:#711DB0,stroke:#000,stroke-width:2px;\nstyle F fill:#FF90BC,stroke:#000,stroke-width:2px;\nstyle G fill:#711DB0,stroke:#000,stroke-width:2px;\nstyle H fill:#FF90BC,stroke:#000,stroke-width:2px;\nstyle I fill:#092635,stroke:#000,stroke-width:2px;\nstyle J fill:#092635,stroke:#000,stroke-width:2px;\nstyle K fill:#092635,stroke:#000,stroke-width:2px;\nstyle M fill:#C21292,stroke:#000,stroke-width:0px;\nstyle HelperFunctions fill:#711DB0,stroke:#000,stroke-width:3px;\nstyle MainFunction fill:#FFA732,stroke:#000,stroke-width:3px;\n```\n\n## 6. Notes\n\n- Ensure that the `./out` directory exists before running the bot. If not, it will be created during the image generation process.\n- The bot requires a stable internet connection to interact with the Telegram API and Stability AI API.\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1999azzar%2Ftelegram-image-generation-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F1999azzar%2Ftelegram-image-generation-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1999azzar%2Ftelegram-image-generation-bot/lists"}