Skip to content

Latest commit

 

History

History
157 lines (115 loc) · 4.64 KB

README.md

File metadata and controls

157 lines (115 loc) · 4.64 KB

tg-yd-bot

tg-yd-bot - simple Telegram bot, which just resend your files from the Telegram chat with bot to selected Yandex.Disk folder. You can use it both from host or from the Docker. Feel free to send any requests about it.

When sending or forwarding photos & documents in chat with bot, it will save all to Yandex Disk in a folder (by default "bot_uploads" but you can set your own YANDEX_FOLDER for it). The bot accepts files from specific users by checking their Telegram ids. For users whose ids are not specified, the bot will not show any activity. This project made from cloud-saving-bot from Artem Nasakin

Python

Contents

Environment variables

Name Description
BOT_TOKEN Telegram bot API token. You can get it from @BotFather
YANDEX_TOKEN Yandex Disk API token. Get it from this link
ALLOWED_IDS This is the telegram id of users from whom the bot will successfully accept photos. Example in .env.example file
YANDEX_FOLDER Folder, which should be placed uploaded files.

Environments support

The list of environments in which the system has been tested is described below.

  • MacOS 13.6.3 (arm64v8)
  • Ubuntu 24.04 LTS (amd64)

Paths and volumes

  • Project path: /home/admin/tg-yd-bot/current

How to use

Copy env from example.

cp .env.example .env

Configure environment variables in .env file.

Direct on host

Automatic build on host

./build.sh

Automatic run at host

./run.sh

Manual build on host

  1. Install python and virtualenv.
brew install python3
pip install virtualenv
  1. Create virtualenv "venv"
virtualenv venv
virtualenv -p python3.13 venv
  1. Switch to virtualenv "venv"
source venv/bin/activate
  1. Install packages
poetry install

Manual run on host

Running server

poetry run server

After finished you can exit from virtualenv.

Deactivate virtualenv "venv"

deactivate

On Docker

Build on Docker

dcoker compose build

Run on Docker

docker compose up

Using systemd

Systemd Unit-file located at tg-yd-bot.service. Copy it to the /etc/systemd/system and run:

sudo systemctl daemon-reload
sudo systemctl enable tg-yd-bot
sudo systemctl start tg-yd-bot

Using for VSCode

For the best experience, you can use VSCode with Python extension. In this way please install extensionms:

pip install aiogram
pip install python-dotenv
pip install yadisk

Configure virtualenv in PyCharm

PyCharm and venv

License

Distributed under MIT license. See LICENSE for more information.

Credits

References and materials