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

  • Get random photos from your library on a schedule using Cron.
  • Request random photos by sending a message with a number or using the /photo [count] command. Maximum 10 photos per request.
  • Supports various image formats: jpg, png, gif, webp, heic.
  • Automatic compression of photos larger than 6 MB before sending.
  • Show info about photo - path, time, camera model, GPS location.

Installation and Usage

Docker

To run from Docker, you need to do the following:

  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.
    version: '2'
    services:
    photo-moments-app:
    image: trueromancha/photo-moments:latest
    volumes:
    - /pathToYouPhotoLibrary/:/photoLibrary/
    environment:
    - FM_ALLOWED_USERS_ID=userId;userId2
    - FM_CHAT_ID=chatId
    - FM_TG_BOT_TOKEN=botToken
  5. Configure the volumes in docker-compose.yml to map your photo folders.
  6. Run command docker-compose up -d.

You can map multiple folders with photos, for example:

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_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 * * *

Commands

Command Description
[number] Send random photo from library. number - count of photos
/photo [count] Send random photo from library. count - count of photos
/paths Show paths of last sent photos
/info [number] Show info about photo - path, time, camera, GPS location. number - sequence number of last sent photos

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.