Selecting a daily random picture and send it by Telegram to your family

05.Feb.2015 — Julio


  • I have all my pictures in a Imac.
  • A script select randomly every day mydailyrandompicture.jpg .
  • And then sends mydailyrandompicture.jpg to my family by Telegram.
  • I see mydailyrandompicture.jpg in my private web server where I work every day. my to-do page
  • I sync mydailyrandompicture with BitTorrentSync with three more devices.

You need

  • python but if you use iMac or linux is installed by default so you do not need this step.
  • Install Telegram CLI following this instruccions Telegram CLI.
  • Optional BitTorrentSync if you want to sync your dailyrandompicture.


  • Download this code
  • Change three paths
    • CHANGE1 : where you put the choosen picture
    • CHANGE2 : where you have all your pictures to choose
    • CHANGE3 : where you save your log
  • Add in your crontab the python task (change the time you want)

    58 23 * * * python /your_path/

    (you need to add your absolute paths)
    (I need to copy the picture to my server, and copy the picture to another folder used by BitTorrentSync too, so I use another script that do that all toghether.)

  • Send _dailyrandompicture with Telegram CLI with this code. You can add to your crontab too

    /your_path_telegram/bin/telegram-cli -k -WR -e "send_photo user#DESTINATION /your_path_CHANGE1/your_picture.jpg"
    (you need to add your absolute paths)

Tags: python, telegram

Comments? Tweet