dimonier / tg2obsidian

This bot pulls new messages from a Telegram chat or group and puts them into Obsidian vault on a local machine
MIT License
103 stars 26 forks source link
markdown obsidian ocr productivity telegram text-to-speech

tg2obsidian

This program (hereinafter referred to as the Bot) utilizes the free functionality of the Telegram bot to save messages from a Telegram group into an Obsidian vault on your local computer.

The Markdown formatting used will also work for most other programs that work with local Markdown files. The Bot is designed to run locally on the computer where the Obsidian files are located.

This readme is also available in Russian.

Use Case

Features

Installation and Setup

The instructions below are intended for Windows users. For Linux and MacOS users, the installation and setup procedure is similar, but the commands for running programs may differ.

Main Steps

  1. Install Python 3.10+.
  2. Install the required dependencies:
pip install -r requirements.txt
  1. Create your bot using https://t.me/BotFather
  2. Insert the token received from @botfather into the corresponding variable in the config.py file and modify the other parameters in config.py as required.
  3. (Optional) Add the bot created above to a private Telegram group and make it an administrator so that it can read messages.
  4. Run the bot (see the "Usage" section)
  5. Send the /start command to your bot on Telegram. In response, the bot will tell you your id. Insert it into the my_chat_id parameter in the config.py file.

If Text Recognition on Images is Required

  1. Install Tesseract and add the path to the executable file (tesseract.exe on Windows) to the system's PATH environment variable.
  2. Navigate to the folder containing this script and ensure that tesseract.exe can be run from it.

If Speech Recognition is Required

  1. Install the compiled FFMPEG and add the path to the executable file (ffmpeg.exe on Windows) to the system's PATH environment variable.
  2. Navigate to the folder containing this script and ensure that ffmpeg.exe can be run from it.

Usage

  1. Send/forward messages that should be added to your Obsidian vault directly to your bot or to your private Telegram group.

  2. Run the Bot:

    python tg2obsidian_bot.py

Important! The Bot can only receive messages from the last 24 hours due to lifetime of Telegram updates. If more than 24 hours have passed since a message was sent before the Bot is run, that message will not be received by the Bot.