A Telegram bot that takes links from supported websites, extracts images, and queues them for posting to a Telegram channel at scheduled intervals.
- Extract images from various supported websites
- Queue images for scheduled posting
- Customizable posting schedule using cron syntax
- Access control to limit who can use the bot
- Post images with source attribution and link back to original
- Modular design for easy addition of new website scrapers
- Interactive visual queue management with inline buttons
- e621 - Uses OpenGraph scraping and Cheerio DOM parsing to extract images and videos
- FurAffinity - Leverages the FA Export API to fetch submission data and direct download links
- Bluesky - Uses ATProto API Library with BskyAgent for full support of posts, images, and videos
- SoFurry - Planning stage
- Weasyl - Planning stage
- Uses the official
@atproto/api
library with BskyAgent - Parses URLs in the format
bsky.app/profile/{handle}/post/{id}
- Extracts user DIDs and content identifiers
- Supports both image and video content extraction
- Handles thumbnails for video posts
- Works with public posts without requiring authentication
- Processes quoted content and multiple images in a single post
- Uses Cheerio to parse the HTML DOM of e621 pages
- Extracts media URLs from OpenGraph tags and direct DOM elements
- Handles both image and video content
- Processes and caches media files locally
- Supports fallback methods if primary extraction fails
- Ensures proper URL resolution for relative paths
- Extracts submission IDs from URLs in the format
furaffinity.net/view/{id}
- Uses the (FAExport) (API) to fetch submission data
- Extracts direct download URLs, titles, and artist information
- Handles both image and video content
- Preserves proper attribution and metadata
Stagehand uses a sophisticated media caching and transcoding system to efficiently handle images and videos from various sources:
- All downloaded media is cached locally to reduce bandwidth usage and improve performance
- Files are stored in organized directories:
cache/images/
- For static imagescache/videos/
- For original video filescache/transcoded/
- For processed/transcoded videos
- Filenames are generated using MD5 hashes of source URLs to ensure uniqueness
- Cache is automatically cleaned up, with files older than 15 days (configurable) being removed
- Content type detection based on HTTP headers and URL patterns
- Intelligent fallback mechanisms if metadata is unavailable
- Special handling for different media sources (e.g., Bluesky API)
- File extension determination from both URL and content type
- Maximum download size limit of 50MB to prevent abuse
- Videos are automatically transcoded to H.264 MP4 format for maximum compatibility with Telegram
- Uses FFmpeg (via fluent-ffmpeg) with optimized settings:
- H.264 video codec for wide compatibility
- AAC audio codec at 128kbps
- Medium preset balancing quality and processing speed
- CRF 23 for good quality-to-size ratio
- MP4 container with faststart flag for immediate playback
- YUV420p pixel format for maximum device compatibility
- Animated GIFs are handled appropriately based on content type
This system ensures that all media is properly optimized before being sent to Telegram, providing reliable playback across all devices while managing bandwidth and storage efficiently.
- Clone this repository
- Install dependencies:
npm install
- Copy
.env.example
to.env
and fill in your credentials:cp .env.example .env
- Edit the
.env
file with your Telegram bot token and channel ID - Ensure PM2 is installed globally:
npm install -g pm2
BOT_TOKEN
: Your Telegram bot token from BotFatherCHANNEL_ID
: Your Telegram channel ID or username (e.g., @mychannel)AUTHORIZED_USERS
: Comma-separated list of Telegram user IDs that are allowed to use the bot
This bot uses PM2 by default to ensure it runs persistently and automatically restarts after crashes or system reboots.
npm start
npm run stop
npm run restart
npm run logs
npm run status
pm2 startup
Then follow the instructions provided by the command.
After starting your bot, run:
pm2 save
This ensures your bot restarts automatically if the system reboots.
For development with auto-reload on file changes:
npm run dev
/start
- Start the bot/help
- Show help information/queue
- Show current queue status with interactive management/send
- Post the next image in the queue immediately/schedule [cron]
- Set posting schedule using cron syntax/setcount [number]
- Set number of images per post interval/clear
- Clear the entire queue/cleancache
- Clean expired items from media cache
Send a link from any supported website to the bot in a direct message. The bot will extract the image and add it to the queue.
The /queue
command displays an interactive visual interface for managing queued items:
- Page Navigation: Browse through the queue using Previous/Next buttons
- Item Preview: View a preview of any queued item before it's posted
- Item Removal: Remove specific items from the queue with a single click
- Reordering: Move any item to the top of the queue to be posted next
- Pagination: Easily navigate through pages of queued items
The interface shows important information about each queued item including:
- Item position in queue
- Content type (image or video)
- Title and source website
- Controls for managing each item
To add support for a new website:
- Create a new scraper in the
scrapers
directory extendingBaseScraper
- Implement the
canHandle
andextract
methods - Register the scraper in
utils/scraperManager.js
ISC
- ATProto Implementation
- Basic e621 Scraper
- FurAffinity Scraper
- SoFurry Scraper
- Weasyl Scraper
- Interactive Graphical Queue Manager
- Add perceptual hashing
- Redo Queue Manager
- Redo Bluesky Module
- Redo Telegram Module
- Redo Discord Module