Telegram bot for automatic forwarding posts from VK to Telegram.
Python script to automatically repost from VK community pages to Telegram channels or chats. Once the script is set up and running, it will check for new posts in VK every N seconds using VK API and, if there are any, parse and send them to Telegram.
You can manually run the script with Python or Docker and leave it running in the background. Or you can set the script to run automatically on the remote server with tools like crontab, systemd, etc. Or you can configure the script to run at one time if you set VAR_SINGLE_START = True
in .env
file.
# clone the repository
$ git clone https://github.com/alcortazzo/vktgbot.git
# if you want to clone specific version (for example v2.6)
$ git clone -b v2.6 https://github.com/alcortazzo/vktgbot.git
# change the working directory to vktgbot
$ cd vktgbot
Note that in version 3.0 the script has been rewritten from the pyTelegramBotAPI library to the aiogram library. So if you want to install an older version of the script working with the pyTelegramBotAPI library, install version 2.6 using the method above. You can find instructions on how to run an older version of the script here.
Open .env
configuration file with text editor and set the following variables:
VAR_TG_CHANNEL = @aaaa
VAR_TG_BOT_TOKEN = 1234567890:AAA-AaA1aaa1AAaaAa1a1AAAAA-a1aa1-Aa
VAR_VK_TOKEN = 00a0a0ab00f0a0ab00f0a6ab0c00000b0f000f000f0a0ab0a00b000000dd00000000de0
VAR_VK_DOMAIN = bbbb
VAR_TG_CHANNEL
is link or ID of Telegram channel. You must add bot to this channel as an administrator!VAR_TG_BOT_TOKEN
is token for your Telegram bot. You can get it here: BotFather.VAR_VK_TOKEN
is personal token for your VK profile. You can get it here: HowToGet.VAR_VK_DOMAIN
is part of the link (after vk.com/) to the VK channel. For example, if link isvk.com/durov
, you should setVAR_VK_DOMAIN = durov
.
Open the file "last_id.txt" and write in it the ID of the last message (not the pinned one!):
- For example, if the link to post is
https://vk.com/wall-22822305_1070803
, then the id of that post will be1070803
. - Example photo
# install requirements
$ python3 -m pip install -r requirements.txt
# run script
$ python3 vktgbot
# change the working directory to docker
$ cd docker
# build and run docker
$ docker-compose up --build
GPLv3
Original Creator - alcortazzo