justice47 / vktgbot

Telegram Bot for repost from VK to TG channel

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

vktgbot

docker image

Telegram Bot on Python for reposting from VKontakte community pages (group, public page or event page) to Telegram Channels.

What is now implemented    |    How bot works    |    Installation & Usage

rus: Телеграм бот для парсинга (репоста) постов из пабликов ВК в Телеграм каналы

What is now implemented

Type of VK post Is implemented? What bot will send to Telegram
Text post Yes Text post
Text post with photo(s) Yes Text post with photo(s)
Text post with link(s) Yes Text post with link(s)
Text post with (yt/vk) video(s) Yes Text post with link(s) to video(s)
Text post with audios ~ Text post without audios > VK-API restrictions
Text post with document(s) Yes Text post with document(s)
Text post with VK repost Yes Original post and repost in 2 messages*
Text post with polls ~ Just text post for now

*One message with original post's text and attachments and one message with repost's text and attachments

In addition, bot can skip ads posts if in config.py

skipAdsPosts = True

How bot works

  • Bot sends and receives request from vk api [get.wall method]
  • Then bot compares the id from last_known_id.txt with the id of the last post
  • If skipAdsPosts = True in config.py bot will skip ads posts
  • If id of the last post is larger than id from last_known_id.txt the bot will write a new id to the file and call the function parsePosts()
  • parsePosts() parses attachments from posts (or reposts if exists) and calls sendPosts() to send them to Telegram
  • Then bot is waiting for the period settled by the user and starts again

Installation & Usage

Linux

# clone the repo
$ git clone https://github.com/alcortazzo/vktgbot.git

# change the working directory to vktgbot
$ cd vktgbot

# install python3 and python3-pip if they are not installed

# install the requirements
$ python3 -m pip install -r requirements.txt

Or launch it in docker

Windows

If you want to use git

# clone the repo
git clone https://github.com/alcortazzo/vktgbot.git

# change the working directory to vktgbot
cd vktgbot

# install python3 and python3-pip if they are not installed

# install the requirements
python -m pip install -r requirements.txt

If you don't want to use git

  1. Download vktgbot repo as ZIP
  2. Unzip vktgbot to your folder (for example C:\Users\%username%\bots\)
  3. Then open cmd or powershell
# change the working directory to vktgbot
cd c:\\users\\%username%\\bots\\vktgbot

# install the requirements
python -m pip install -r requirements.txt

Open config file and update the following variables:

tgChannel = '@aaaa'
tgBotToken = '1234567890:AAA-AaA1aaa1AAaaAa1a1AAAAA-a1aa1-Aa'
vkToken = '00a0a0ab00f0a0ab00f0a6ab0c00000b0f000f000f0a0ab0a00b000000dd00000000de0'
vkDomain = 'bbbb'
  • tgChannel is the link to channel in telegram t.me/>>aaaa<<. You must add bot to this channel as an administrator
  • tgBotToken is the bot token from BotFather
  • vkToken is your vk personal token. HowToGet
    • You can just use the vk service token (HowToGet), but if you want to repost posts from closed groups or want to repost posts with YouTube videos use personal token.
  • vkDomain is the link to vk public vk.com/>>bbbb<<
  • tgLogChannel link to another channel in telegram if you want to get bot's log message

If Telegram is not available in your country, you should update these variables.

proxyEnable = True
proxyLogin = "bot"  
proxyPass = "12345"  
proxyIp = "myproxy.com"  
proxyPort = "1234"

Open last_known_id.txt file and write in it id of the last (not pinned!) post (optional):

  • Example: if link to post is https://vk.com/wall-22822305_1070803 id of this post will be 1070803
  • PhotoExemple

Launch the bot

Linux

$ python3 bot.py

Windows

python bot.py

Docker (58MB)

docker build -t vktgbot .
docker run -dt --name vktgbot vktgbot

View logs: docker logs --follow vktgbot

License

GPLv3
Original Creator - alcortazzo

About

Telegram Bot for repost from VK to TG channel

License:GNU General Public License v3.0


Languages

Language:Python 98.8%Language:Dockerfile 1.2%