Skip to content

Romancha/photo-moments-telegram-bot

Repository files navigation

Photo Moments Telegram Bot

GitHub release (with filter) GitHub Release Date - Published_At License

English | Русский

Introduction

The Photo Moments Telegram Bot delivers serendipitous snapshots from your personal collection straight to Telegram, enabling you to fondly reminisce about cherished memories.

Features

  • Random Photos on Schedule: Fetch random photos from your library using Cron.
  • On-Demand Random Photos: Request random photos by sending a message with a number or using the /photo [count] command. Maximum 10 photos per request.
  • Memories from the Past: View photos taken on this day in previous years with /memories [years] or /today.
  • Automated Memories: Receive photos taken on this day in previous years automatically on schedule.
  • Automatic Reindexing: Weekly differential reindexing to keep the photo database up-to-date.
  • Broad Image Format Support: jpg, png, gif, webp, heic.
  • Automatic Compression of large photos (>6 MB) before sending.
  • Detailed Photo Info: EXIF-based details (path, date, camera model, GPS location) via /info.

Installation and Usage

Docker

  1. Install Docker and Docker Compose.
  2. Create your bot and get a token from @BotFather.
  3. Get chat_id from @userinfobot.
  4. Set mandatory env docker-compose.yml: FM_ALLOWED_USERS_ID, FM_CHAT_ID, FM_TG_BOT_TOKEN, FM_DB_PATH.
    services:
    photo-moments-app:
    image: trueromancha/photo-moments:latest
    volumes:
    - /pathToYouPhotoLibrary/:/photoLibrary/
    - /pathToYouDbStorage/:/dbStorage/
    environment:
    - FM_ALLOWED_USERS_ID=userId;userId2
    - FM_CHAT_ID=chatId
    - FM_TG_BOT_TOKEN=botToken
    - FM_DB_PATH=/dbStorage/photo-moments.db
  5. Configure the volumes in docker-compose.yml to map your photo folders.
  6. Run docker-compose up -d.

Example multi-folder volume mapping:

volumes:
  - /home/user/photos:/photoLibrary/
  - /home/user/photos2:/photoLibrary/
  - /home/user/photos3:/photoLibrary/

Synology NAS

For Synology NAS, you can use the Container manager or Docker package.

From source

You can also run the bot from source code, build Go binary and run it. The bot requires the image process library libvips.

Configuration

Param Description
FM_TG_BOT_TOKEN Telegram bot token, take from @BotFather
FM_CHAT_ID Chat ID where the bot will send messages. @userinfobot Can help to get chat id
FM_ALLOWED_USERS_ID Telegram user IDs that can use the bot. You can specify multiple id with separator ;
FM_PHOTO_PATH Path to the photo library folder
FM_DB_PATH Path to the db file. Default photo_moments.db.
FM_PHOTO_COUNT The number of photos that the bot will send according to the schedule. Default 5, maximum 10
FM_SEND_PHOTOS_BY_NUMBER Send photos by number. Default true
FM_SEND_PHOTO_CRON_SPEC Cron to send random photos. Default 0 10 * * *
FM_MEMORIES_CRON_SPEC Cron to send photos from this day in different years. Default 0 12 * * *
FM_MEMORIES_PHOTO_COUNT Total number of photos to send for memories across all years. Default 5
FM_REINDEX_CRON_SPEC Cron for automatic differential reindexing. Default 0 0 * * 0 (weekly on Sunday at midnight)

Commands

Command Description
/start Start interacting with the bot
/help Show help information
/random Get a random photo from the archive
/random N Get N random photos from the archive
/memories Get photos taken on this day one year ago
/memories N Get photos taken on this day N years ago
/today Get photos taken on this day across different years
/indexing Show the current status of photo metadata indexing
/reindex full Start full reindexing of photos (clear and recreate indices)
/reindex diff Start differential indexing (only new and modified files)
/info [number] Show info about photo - path, time, camera, GPS location. number - sequence number of last sent photos
/info If replying to a specific photo, shows info about that exact photo

Contributing

We welcome contributions to improve this project.

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

About

Send random photos to telegram from your library

Topics

Resources

License

Stars

Watchers

Forks

Packages