This project monitors notifications on the sora.com website. When new image generations are detected, it downloads the image, splits it into a grid (typically 3x3 for 9 parts, but also supports 2x2 for 4 parts), and sends the resulting image segments as stickers to a specified Telegram chat. Additionally, it monitors video generations, sending the resulting videos, and provides real-time progress updates for ongoing tasks directly to the Telegram chat.
Before you begin, ensure you have the following installed:
-
Node.js and pnpm: The project uses
pnpm
for package management. You can find installation instructions on the official Node.js website and pnpm website. -
tsx: This TypeScript execution tool needs to be installed globally. You can install it using pnpm:
# Using pnpm (recommended for this project) pnpm install -g tsx # Or using npm npm install -g tsx
-
OpenCV: This project relies on
opencv4nodejs
. Depending on your system, you might need to build OpenCV from source or ensure prebuilt binaries are available. Please refer to the opencv4nodejs installation guide for detailed instructions specific to your operating system.
-
Clone the repository:
git clone https://github.com/sliterok/sticker-gpt cd sticker-gpt
-
Install dependencies:
# Using pnpm (recommended) pnpm install # Or using npm npm install
-
Configure Environment Variables: Create a
.env
file in the project's root directory and add the following variables, replacing the placeholder values with your actual credentials:BOT_TOKEN=<your_telegram_bot_token> CHAT_ID=<your_telegram_chat_id>
BOT_TOKEN
: Your Telegram bot's API token (obtainable from BotFather on Telegram).CHAT_ID
: The specific Telegram chat identifier where the stickers should be sent.
-
Configure Notification Headers: Create a
headers.json
file in the root directory. This file must contain the necessary HTTP request headers required to interact with the sora.com/backend/notif
endpoint.-
How to obtain headers: Use your browser's developer tools (usually by pressing F12). Go to the Network tab, perform the action on sora.com that triggers the notification check, find the request to
/backend/notif
, press Copy > Copy as fetch (Node.js), and copy the value ofheaders
property into theheaders.json
file. -
Example
headers.json
format:{ "Cookie": "session_id=...", "Authorization": "Bearer ...", "User-Agent": "Mozilla/5.0 ...", "Accept": "application/json" // Add any other required headers here }
(Replace the example values with the actual headers you copied.)
-
Once the setup is complete, you can start the application using:
# Using pnpm (recommended)
pnpm start
# Or using npm
npm start
These commands execute the notif.ts
script using tsx
, which will begin monitoring for notifications.
When generating images intended for use with this tool, you have two main options for the background:
-
Transparent Background (Recommended): For the most reliable results, include
transparent background
ortelegram sticker
directly in your prompt. This ensures the generated image has an alpha channel, which the sticker creation process handles best. -
Plain White Background (Experimental): Support for images with a plain white background has been added, but it can be finicky. For this to work correctly, the background must be plain white. Any variations, gradients, or off-white shades might cause issues during sticker processing.
Note: Adding transparent background
or telegram sticker
phrases to a preset is not sufficient; include it directly in the prompt text itself.
Using Presets: You can include the white background
requirement within a generation preset. This can help streamline your workflow.
Here's an example structure of a preset you might adapt for generating sticker packs:
Generate a telegram sticker pack of a subject
Rules:
Singular subject
Turn whatever user described into a single thing
Perfectly centered
Place that one subject right in the middle of each 512×512 canvas.
Exactly nine stickers
Always output 9 images arranged in a 3×3 grid
This section illustrates how the tool processes a generated image (fruit.webp
) and splits it into individual stickers.
1. Original Image:
The process starts with an image generated by sora.com, like the one below:
2. Resulting Stickers (3x3 Grid):
The script splits the original image into nine segments. Each segment is saved as a separate .webp
file and sent to Telegram as an individual sticker: