···11# Stagehand - Telegram Image Queue Bot
2233-A Telegram bot that takes links from supported websites, extracts images, and queues them for posting to a Telegram channel at scheduled intervals.
33+A Telegram bot that takes links from supported websites, extracts images and videos, and queues them for posting to a Telegram channel at scheduled intervals.
4455## Features
6677-- Extract images from various supported websites
77+- Extract images and videos from various supported websites
88- Process forwarded messages containing links (including button links)
99-- Queue images for scheduled posting
99+- Queue media for scheduled posting
1010- Customizable posting schedule using cron syntax
1111- Access control to limit who can use the bot
1212-- Post images with source attribution and link back to original
1212+- Post media with source attribution and link back to original
1313- Modular design for easy addition of new website scrapers
1414- Interactive visual queue management with inline buttons
1515+- Intelligent queue monitoring with automatic alerts
1616+- Perceptual image hashing for duplicate detection
1717+- Automatic media cache management with recaching support
1818+- Scheduled announcements with individual cron schedules
1919+- Auto-updater for seamless updates from Git repository
2020+- Discord webhook integration (optional)
15211622## Supported Websites
1723···4652- Extracts direct download URLs, titles, and artist information
4753- Handles both image and video content
4854- Preserves proper attribution and metadata
5555+5656+### SoFurry
5757+- Uses direct access to the SoFurry API with OAuth authentication
5858+- Extracts submission IDs from URLs
5959+- Requires manual setup:
6060+ 1. Create an application on the [SoFurry Developer Portal](https://developer.sofurry.com)
6161+ 2. Generate an OAuth access token manually
6262+ 3. Add the access token to your `.env` file as `SOFURRY_ACCESS_TOKEN`
6363+- Fetches submission data, including display URLs and metadata
6464+- Supports both image and video content
6565+- Handles proper attribution with author and title information
6666+6767+### Weasyl (Currently Broken)
6868+- Implements Weasyl's API for submission data
6969+- Requires an API key from [Weasyl](https://www.weasyl.com/)
7070+- Add your API key to `.env` as `WEASYL_API_KEY`
7171+- Extracts submission information and media URLs
49725073## Media Caching and Transcoding
5174···189212- `OWNER_ID`: (Optional) User ID of the bot owner for admin-level commands
190213191214### Integration Options
192192-- `WEASYL_API_KEY`: (Optional) API key for Weasyl integration
215215+- `WEASYL_API_KEY`: (Optional) API key for Weasyl integration - Get yours from [Weasyl](https://www.weasyl.com/)
216216+- `SOFURRY_ACCESS_TOKEN`: (Optional) OAuth access token for SoFurry API - Create an app and generate a token at the [SoFurry Developer Portal](https://www.sofurry.com/oauth/applications)
193217- `DISCORD_WEBHOOK_URL`: (Optional) For Discord integration
194218- `DISCORD_ENABLED`: Set to 'true' to enable Discord posting
195219···266290- `/shuffle` - Toggle shuffle mode (randomizes queue after each post, persists between restarts)
267291- `/clear` - Clear the entire queue
268292- `/cleancache` - Clean expired items from media cache
269269-- `/announce` - Create a new announcement
270270-- `/announcements` - Manage existing announcements
293293+- `/recache` - Recache missing files and remove items that fail after 3 attempts
294294+- `/announce` - Create a new announcement (with custom text and schedule)
295295+- `/announcements` - Manage existing announcements (view, edit, delete)
296296+- `/update` - Check for updates and apply them (owner only)
271297272298### Adding Images to Queue
273299···337363338364This project includes comprehensive documentation in the `docs/` directory:
339365366366+- **[Bot Architecture](docs/bot-architecture.md)** - Detailed architecture documentation for the modular bot system
367367+- **[Bot Architecture Migration](docs/bot-architecture-migration.md)** - Migration guide from monolithic to modular architecture
340368- **[Queue Monitoring Implementation](docs/queue-monitoring-implementation.md)** - Complete implementation details for the queue monitoring and alert system
341369- **[Queue Monitoring Configuration](docs/queue-monitoring-configuration.md)** - Configuration guide for queue alerts and thresholds
370370+- **[Image Hashing](docs/image-hashing.md)** - Documentation on perceptual image hashing for duplicate detection
371371+372372+## Advanced Features
373373+374374+### Perceptual Image Hashing
375375+376376+Stagehand includes a sophisticated image hashing system to detect duplicate and similar images:
377377+378378+- **Automatic Processing**: Images are automatically hashed when cached
379379+- **SQLite Database**: Stores perceptual hashes with URLs and metadata
380380+- **Similarity Detection**: Find visually similar images using Hamming distance
381381+- **Duplicate Prevention**: Helps identify duplicate content from different sources
382382+- **Cleanup Management**: Automatically removes database entries for deleted files
383383+384384+The image hashing system uses the `imghash` library to generate perceptual hashes (pHash) that can detect similar images even after resizing, compression, or minor modifications.
385385+386386+For detailed information, see [Image Hashing Documentation](docs/image-hashing.md).
387387+388388+### Announcement System
389389+390390+Create and manage scheduled text announcements that are posted to your channel:
391391+392392+- **Multiple Announcements**: Support for multiple independent announcements
393393+- **Individual Schedules**: Each announcement can have its own cron schedule
394394+- **Interactive Management**: Create, edit, and delete announcements through the bot
395395+- **Persistent Storage**: Announcements are saved and survive bot restarts
396396+- **Test Functionality**: Test announcements before scheduling them
397397+398398+Use `/announce` to create new announcements and `/announcements` to manage existing ones.
399399+400400+### Auto-Updater
401401+402402+Stagehand includes an automatic update system that keeps your bot up to date:
403403+404404+- **Periodic Checks**: Automatically checks for updates every 12 hours
405405+- **Git Integration**: Pulls updates from your Git repository
406406+- **PM2 Restart**: Automatically restarts the bot using PM2 after updating
407407+- **Manual Updates**: Use `/update` command to check and apply updates immediately
408408+- **Owner-Only**: Update command is restricted to the bot owner
409409+- **Dev Mode Exclusion**: Auto-updater is disabled in development mode
410410+411411+The updater runs in the background and will notify you when updates are applied.
412412+413413+### Media Recaching
414414+415415+Automatically handle missing or corrupted cache files:
416416+417417+- **Automatic Detection**: Identifies missing cache files in the queue
418418+- **Redownload Support**: Automatically redownloads missing media files
419419+- **Failure Tracking**: Tracks failed attempts and removes items after 3 failures
420420+- **Manual Trigger**: Use `/recache` command to manually trigger recaching
421421+- **Scheduled Execution**: Can be scheduled to run automatically via cron
422422+- **Progress Reporting**: Reports how many items were processed and removed
423423+424424+This ensures your queue remains healthy and all media files are available when needed.
425425+426426+### Discord Integration
427427+428428+Optional Discord webhook support for cross-platform posting:
429429+430430+- **Webhook Support**: Post media to Discord channels via webhooks
431431+- **Parallel Posting**: Post to both Telegram and Discord simultaneously
432432+- **Independent Configuration**: Enable/disable Discord without affecting Telegram
433433+- **Media Compatibility**: Handles both images and videos
434434+435435+Configure using the `DISCORD_WEBHOOK_URL` and `DISCORD_ENABLED` environment variables.
436436+437437+## Documentation
438438+439439+This project includes comprehensive documentation in the `docs/` directory:
440440+342441- **[Bot Architecture](docs/bot-architecture.md)** - Detailed architecture documentation for the modular bot system
343442- **[Bot Architecture Migration](docs/bot-architecture-migration.md)** - Migration guide from monolithic to modular architecture
443443+- **[Queue Monitoring Implementation](docs/queue-monitoring-implementation.md)** - Complete implementation details for the queue monitoring and alert system
444444+- **[Queue Monitoring Configuration](docs/queue-monitoring-configuration.md)** - Configuration guide for queue alerts and thresholds
445445+- **[Image Hashing](docs/image-hashing.md)** - Documentation on perceptual image hashing for duplicate detection
344446345447## License
346448···355457- [x] Weasyl Scraper
356458- [x] Interactive Graphical Queue Manager
357459- [x] Add shuffle mode for queue
358358-- [ ] Add perceptual hashing
359359-- [ ] Redo Queue Manager
460460+- [x] Add perceptual hashing
360461- [x] Redo Bluesky Module
361462- [x] Redo Telegram Module
463463+- [x] Queue monitoring and alerts
464464+- [x] Announcement system
465465+- [x] Auto-updater
466466+- [x] Media recaching system
467467+- [ ] Redo Queue Manager
362468- [ ] Redo Discord Module