- About this project
- Project architecture
- Requirements
- Environment variables
- Prepare and configure environment
- How to run project locally
This project is a Telegram bot that allows you to upload posts from your Instagram profile to WebDav compatible storage.
Main functions
- a backup copy of a specific post by link
- a backup copy of list of posts by links
Preview of the bot in action
- Vault Server
- WebDav Cloud
- remote directory url
- username and password
- Telegram Bot
- Instagram Account
- Postgresql Database
Variable | Description | Default value |
---|---|---|
LOGGER_LEVEL |
The logging level of the logging module | INFO |
TELEGRAM_BOT_NAME |
The name of the bot, used to determine the unique mount point in the vault | pyinstabot-downloader |
MESSAGES_CONFIG |
The path to the message template file | src/configs/messages.json |
VAULT_* |
All supported vault environment variables can be found here | - |
- Create an account in any cloud that supports WebDav
- Get the WebDav directory url from your cloud provider
- Get the WebDav username and password from your cloud provider
All bot configuration is stored in the Vault Secrets
(except for the part of the configuration that configures the connection to Vault
)
-
pyinstabot-downloader-database
- vault database engine mount point, returns the temporary username and password for the database. More information about the database engine can be found here and here -
configuration/database
: database connection parameters{ "dbname": "pyinstabot-downloader", "host": "postgresql.example.com", "port": "5432", "connections": "10" }
-
configuration/telegram
: telegram bot configuration{ "token": "123456:qwerty" }
-
configuration/downloader-api
: downloader module configuration (for downloading content from instagram){ "enabled": "True", "2fa-enabled": "False", "2fa-seed": "my_2fa_secret", "country-code": "1", "country": "US", "delay-requests": "1", "locale": "en_US", "username": "my_username", "password": "my_password", "session-file": "session.json", "timezone-offset": "10800", "request-timeout": "10", "device-settings": {"app_version": "269.0.0.18.75", "version_code": "314665256", "manufacturer": "OnePlus", "model": "6T Dev", "device": "devitron", "cpu": "qcom", "dpi": "480dpi", "resolution": "1080x1920", "android_release": "8.0.0", "android_version": "26"} }
Description of parameters
delay-requests
: the delay between requests to the instagram api in secondslocale
: the locale of the instagram accountsession-file
: the path to the file where the session data will be storedtimezone-offset
: the offset of the timezone in seconds2fa-enabled
: two-factor authentication status2fa-seed
: two-factor authentication secretcountry-code
: the country code of the instagram accountcountry
: the country of the instagram accountenabled
: the status of the downloader moduleusername
: the username of the instagram accountpassword
: the password of the instagram accountrequest-timeout
: the timeout for requests to the instagram apidevice-settings
: the device settings of the instagram accountapp_version
: the version of the instagram appversion_code
: the version code of the instagram appmanufacturer
: the manufacturer of the devicemodel
: the model of the devicedevice
: the device namecpu
: the cpu of the devicedpi
: the dpi of the deviceresolution
: the resolution of the deviceandroid_release
: the android release version of the deviceandroid_version
: the android api version of the device
-
configuration/uploader-api
: uploader module configuration (for upload content to the target storage){ "enabled": "True", "destination-directory": "cloud-directory/", "password": "qwerty123", "source-directory": "data/", "username": "username1", "url": "https://webdav.example.com/directory" }
Description of parameters
destination-directory
: the directory in the target storage where the content will be uploadedsource-directory
: the directory where the content will be stored before uploading (temporary directory)url
: the url of the target webdav directoryenabled
: the status of the uploader moduleusername
: the username of the webdav accountpassword
: the password of the webdav account
-
configuration/users/<telegram_user_id>
: users permissions and attributes{ "requests": {"requests_per_day": 10, "requests_per_hour": 1, "random_shift_minutes": 60}, "roles": ["posts", "reschedule_queue"], "status": "allowed" }
Description of parameters
requests
: the number of requests that the user can make per day and per hour, as well as the random shift in minutes (scheduling of message processing from the queue works on the basis of this parameter)roles
: list of roles that allow to use the corresponding functionality (available roles).status
: allowed or denied user access to the bot
Scripts for configuring the vault-server are located in the vault-init.sh
- instructions for starting and configuring a new vault-server
# Clone the repository
git clone https://github.com/obervinov/pyinstabot-downloader.git
cd pyinstabot-downloader
# Run vault-server
docker-compose -f docker-compose.yml up vault-server -d
# Initialize and unseal new vault-server
export VAULT_ADDR=http://0.0.0.0:8200
vault operator init
vault operator unseal
# Run the script for configuring the vault-server for this bot project
export VAULT_TOKEN=hvs.123456qwerty
./scripts/vault-init.sh
- instructions for configuring an existing vault server
# Clone the repository
git clone https://github.com/obervinov/pyinstabot-downloader.git
cd pyinstabot-downloader
# Run the script for configuring the vault-server for this bot project
export VAULT_ADDR=https://vault.example.com:8200
export VAULT_TOKEN=hvs.123456qwerty
./scripts/vault-init.sh
Persistent data storage is implemented using Postgresql
The database structure is created automatically when the bot starts:
- bot checks the database structure and creates missing tables if necessary
- after checking the database structure, the bot executes the migrations in the order of their numbering
To quickly prepare an instance, you can execute the psql-init.sh script
git clone https://github.com/obervinov/pyinstabot-downloader.git
cd pyinstabot-downloader
export PGHOST=<host>
export PGPORT=<port>
export PGUSER=<user>
export PGPASSWORD=<password>
export PGDATABASE=postgres
./scripts/psql-init.sh
What data is stored in tables:
- user request queue
- user metadata
- user request logs
- processed messages
- migrations
- bot messages
export VAULT_APPROLE_ID={change_me}
export VAULT_APPROLE_SECRET_ID={change_me}
export VAULT_ADDR={change_me}
docker compose -f docker-compose.yml up -d
Name | Version |
---|---|
GitHub Actions Templates | v2.0.2 |