vrslev / flow

Reposting from VK to Telegram

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

vrslev/flow

Simple app for reposting posts from VK to Telegram. Can be easily deployed as AWS lambda function.

Configuration

Since main deployment method is as lambda function, configuration is done with environment variables.

VK_TOKEN

VK app service token. To get it you need to create a VK app and copy app service token from there.

VK_OWNER_ID

Source ID of VK group.

TG_TOKEN

Telegram bot token. Create a bot

TG_CHAT_ID

Target Telegram chat or channel id.

DB_PATH

Path to SQLite database file. Default is /tmp/database.db

SENTRY_DSN (optional)

DSN for sentry error reports

Usage

Lambda

  1. Set up S3 bucket,
  2. Set these environment variables along with variables in Configuration section: S3_BUCKET, S3_KEY, S3_ENDPOINT, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY,
  3. Set entrypoint to flow.main.lambda_handler,
  4. Clone this repo and upload zip archive generated by bash scripts/prepare_artifact.sh,
  5. Configure timer trigger for the function.

Local setup

  1. Clone and install the app. Note that you need to have poetry installed.
git clone --depth 1 https://github.com/vrslev/flow.git
cd flow
poetry install
  1. Configure .env file with the variables,
  2. Run:
poetry run python3 flow/main.py

With Python as library

  1. Install with pip:
pip install git+https://github.com/vrslev/flow.git
  1. Use flow wherever you want. For example:
from flow.main import main
from flow.models import Settings

settings = Settings()
main(settings)

Each call publishes only one post, doesn't matter if there's more available. This is done so you can easily customize publishing schedule (and use it in lambda 😏).

About

Reposting from VK to Telegram

License:MIT License


Languages

Language:Python 98.9%Language:Shell 1.1%