Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vk-to-telegram

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vk-to-telegram

Vk to telegram forwarder

  • 0.2.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
decreased by-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

vk to telegram forwarder

Powered by Telegraf
NPM Version node npm downloads telegram test channel telegram chat

Installation

npm i vk-to-telegram --save

Example

    const app = require('express')()
    const bodyParser = require('body-parser')
    const vkToTelegram = require('vk-to-telegram')
    const vkToTg = new vkToTelegram({
            botToken: 'your bot token',
            chatName: 'telegram chat/channel name',
            ownerId: 'your telegram id', // number
            vkToken: 'your very long token from vk api',
            vkConfirmation: 'group confirmation'
        })
    app.use(bodyParser.json())
    app.post('/', (req, res) => {
        vkToTg.send(req, res)
            .then(() => console.log('Done!'))
            .catch((err) => {
                console.log('Something went wrong')
                console.log(err)
            })
    })

    app.listen(80,()=>{
        console.log('listening on port 80')
    })

What is this

It is a tool for express which using VK callback api forwards posts from group in channel or chat in Telegram!

async/await

Here's example with koa2

    app.use(bodyParser())
    app.use(async ctx => {
        const result = await vkToTg.send(ctx)
        console.log(result)
    })

They use vk-to-telegram in production

What content does it forward

Content typeWorks fully?
Photo(s)Yes
Video(s)Yes
Document(s)Yes
LinkYes
Application ContentYes
PollNot yet, but forwarder will send link to poll.
Audio(s)NO. Why? Read here.
Album(s)Yes
GraffitiNot tested.
Wiki PageNot tested.
Market itemNot tested.
StickerNot tested.

Free usage

If you want to test this code, or to use on a regular basis(beta, works via heroku), please contact me for setup. It's simple ;)

Variables

VariableTypeRequiredDescription
tokenStringYesBot token from Botfather
chatNameStringYesTelegram channel or group link, like '@tavernofheroes'
ownerIdNumberYesYour telegram id for sending error if they are. U can get know it from @getidsbot
vkConfirmationStringYesConfirmation string from ur group callback api server:
vkTokenStringYesFollow the instructions below:
1. Create Standalone application here: https://vk.com/apps?act=manage
2. Open settings in created application and copy application id
3. Open this link with replace your application id:
https://oauth.vk.com/authorize?client_id=YOUR APPLICATION ID&display=page&redirect_uri=http://vk.com/&scope=offline,video,docs&response_type=token&v=5.81
4. Click allow all that need's and it's all! Your token is in query url, do not copy all link, only token without other params.
chatIdNumberOptionalIf you know your chat/channel id, put it here, it will replace chatName parameter
fromIdNumberOptionalVK group id with '-'in start or nothing, if you don't need check.
customVkButtonStringOptionalTitle for button which will be added to each post to open it in VK
customPollTitleStringOptionalCustom template string in the title of button with URL to poll("Open poll" -> "Open poll - ${poll.question}")
customLongPostTextStringOptionalCustom template string that replace full post text, because it's too long for Telegram(max 4096 characters) ("Too long post... [Read full]" -> "Too long post... <a href="https://vk.com/poll${poll.owner_id}_${poll.id}">Read full" and parse as HTML)
signedStringOptionalCustom template string that add post signer in the end of Telegram message ("Post By" -> "\n\nPost by <a href="https://vk.com/id${post.signer_id}">${signer.first_name} ${signer.last_name}" and parse as HTML)
herokuBooleanOptionalAdd filter that stops forwarder if detect that post repeats(Because of app sleeping)
herokuTimeoutNumberOptionalHeroku post delay between same posts
secretStringOptionalSecret field from vk admin panel to verify that post has come from VK
filterByWordStringOptionalFilter posts by key word(s) (use ',' as separator) (use '-' in begin of word to invert)
filterByHashtahStringOptionalFilter posts by hashtag (use ',' as separator) (use '-' in begin of word to invert)
adsBooleanOptionalForward posts marked as ads? (By default true)
repostAdsBooleanOptionalForward reposts marked as ads? (By default true)
appendTextStringOptionalAppend text to forwarded post (can be used for hashtags for channel navigation)
prependTextStringOptionalSame as appendText but it's will prepend it in the start of post text
repostBooleanOptionalAllow to forward post with repost (By default true)
  • DON'T forget to pick in your vk group api dashboard event type 'WALL POST - NEW'.
  • Recommend to use vk api v5.81

Contact

Here's a telegram group ¯\(ツ)
Also u can write to me directly in Telegram, VK or by mail

Keywords

FAQs

Package last updated on 18 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc