Socket
Socket
Sign inDemoInstall

vk-to-telegram

Package Overview
Dependencies
77
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.3 to 0.2.4-b

8

index.js

@@ -34,2 +34,3 @@ const forwarder = require('./lib/forwarder')

* @param {String} [options.prependText] - Same as `appendText` but it's will prepend it in the start of post text
* @param {Boolean} [options.repost=true] - Forward posts with repost?
*/

@@ -58,2 +59,3 @@ constructor (options) {

this.prependText = options.prependText || ''
this.repost = typeof options.repost === 'boolean' ? options.repost : true

@@ -137,3 +139,9 @@ this.send = this.send.bind(this)

})
// console.log(response)
if (response.length) {
if (!this.repost) {
if (response[0].copy_history) {
throw `Post contains repost: ${ JSON.stringify(response[0])}`
}
}
const messages = []

@@ -140,0 +148,0 @@ const post = response[0]

25

lib/forwarder.js

@@ -20,3 +20,3 @@ const Telegram = require('telegraf/telegram')

const telegram = new Telegram(config.token)
const sender = Sender(config)
const { sendDocument, sendPhoto, sendVideo } = Sender(config)
return async post => {

@@ -39,3 +39,2 @@ const chatId = config.chatId

const attachmentLink = []
let poll
if (attachments && attachments.length) {

@@ -56,3 +55,3 @@ if (attachments.some(el => el.type === 'link')) {

if (attachments.some(el => el.type === 'poll')) {
poll = attachments.find(el => el.type === 'poll').poll
const { poll } = attachments.find(el => el.type === 'poll')
messageExtra.reply_markup.inline_keyboard.unshift([{

@@ -76,10 +75,7 @@ text: config.customPollTitle ? `${config.customPollTitle} - ${decode(poll.question)}` : decode(poll.question),

case 'video':
return sender.sendVideo(attachments[0].video, mediaText, messageExtra)
break
return sendVideo(attachments[0].video, mediaText, messageExtra)
case 'photo':
return sender.sendPhoto(attachments[0].photo, mediaText, messageExtra)
break
return sendPhoto(attachments[0].photo, mediaText, messageExtra)
case 'doc':
return sender.sendDocument(attachments[0].doc, mediaText, messageExtra)
break
return sendDocument(attachments[0].doc, mediaText, messageExtra)
case 'album':

@@ -95,11 +91,10 @@ if (!mediaText && attachments[0].album.description.length < 1000) {

return telegram.sendMessage(chatId, `<a href="${utils.photo.getHQ(attachments[0].album.thumb)}">&#160;</a><a>${mediaText}</a>`, messageExtra)
break
}
} else if (mediaText.length < 1000 && utils.isAlbum(attachments)) {
const attachmentsArray = []
for (const key in attachments) {
for (const attachment of attachments) {
attachmentsArray.push({
type: 'photo',
media: {
url: utils.photo.getHQ(attachments[key].photo)
url: utils.photo.getHQ(attachment.photo)
},

@@ -176,6 +171,6 @@ caption: mediaText ? mediaText : '',

case 'doc':
posts.push(sender.sendDocument(attachments[i].doc, null, mediaExtra))
posts.push(sendDocument(attachments[i].doc, null, mediaExtra))
break
case 'video':
posts.push(sender.sendVideo(attachments[i].video, null, mediaExtra))
posts.push(sendVideo(attachments[i].video, null, mediaExtra))
break

@@ -188,3 +183,3 @@ case 'album':

mediaExtra.disable_web_page_preview = false
posts.push(sender.sendPhoto(attachments[i].album.thumb, null, mediaExtra))
posts.push(sendPhoto(attachments[i].album.thumb, null, mediaExtra))
break

@@ -191,0 +186,0 @@ }

6

lib/sender.js

@@ -11,3 +11,3 @@ const Telegram = require('telegraf/telegram')

return {
async sendDocument(document, text = '', extra = defaultConfig()) {
async sendDocument (document, text = '', extra = defaultConfig()) {
const messages = []

@@ -70,3 +70,3 @@ const doc = (await vkapi.docs.getById([`${document.owner_id}_${document.id}`])).response[0]

},
async sendPhoto(photo, text = '', extra = defaultConfig()()) {
async sendPhoto (photo, text = '', extra = defaultConfig()()) {
if (!text) {

@@ -85,3 +85,3 @@ return telegram.sendPhoto(chatId, utils.photo.getHQ(photo), extra)

},
async sendVideo(video, text = null, extra = defaultConfig()) {
async sendVideo (video, text = null, extra = defaultConfig()) {
const apivideo = (await vkapi.video.get([`${video.owner_id}_${video.id}`])).response.items[0]

@@ -88,0 +88,0 @@ if (apivideo) {

@@ -15,3 +15,3 @@ const axios = require('axios').default

/**
* @param {Number[]} videos
* @param {Number[]} videos
*/

@@ -30,3 +30,3 @@ get (videos, params = { extended: 1 }) {

/**
* @param {Number[]} docs
* @param {Number[]} docs
*/

@@ -45,3 +45,3 @@ getById (docs, params = {}) {

/**
* @param {Number[]} users
* @param {Number[]} users
*/

@@ -48,0 +48,0 @@ get (users, params = {fields: 'first_name,last_name',}) {

{
"name": "vk-to-telegram",
"version": "0.2.3",
"version": "0.2.4b",
"description": "Vk to telegram forwarder",

@@ -26,3 +26,3 @@ "author": "ejnshtein",

"html-entities": "^1.2.1",
"telegraf": "^3.22.2"
"telegraf": "^3.25.0"
},

@@ -35,8 +35,9 @@ "repository": {

"body-parser": "^1.18.3",
"puppeteer": "^1.7.0",
"express": "^4.16.3",
"koa": "^2.5.3",
"express": "^4.16.4",
"koa": "^2.6.1",
"koa-bodyparser": "^4.2.1",
"koa-route": "^3.2.0"
}
"koa-route": "^3.2.0",
"puppeteer": "^1.10.0"
},
"license": "MIT"
}

@@ -7,4 +7,4 @@ # vk to telegram forwarder

[![npm downloads](https://img.shields.io/npm/dm/vk-to-telegram.svg?style=flat-square)](http://npm-stat.com/charts.html?package=vk-to-telegram)
[![telegram test channel](https://img.shields.io/badge/telegram-test%20channel-blue.svg)](https://t.me/vktotgforwarderchannel)
[![telegram chat](https://img.shields.io/badge/telegram-chat-blue.svg)](https://t.me/vktotgforwarder)
[![telegram test channel](https://img.shields.io/badge/telegram-test%20channel-blue.svg?style=flat-square)](https://t.me/vktotgforwarderchannel)
[![telegram chat](https://img.shields.io/badge/telegram-chat-blue.svg?style=flat-square)](https://t.me/vktotgforwarder)

@@ -97,3 +97,3 @@ ## Installation

||||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.73|
||||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. |

@@ -115,2 +115,3 @@ |`chatId`|`Number`|**Optional**|If you know your chat/channel id, put it here, it will replace `chatName` parameter|

|`prependText`|`String`|**Optional**|Same as `appendText` but it's will prepend it in the start of post text|
|`repost`|`Boolean`|**Optional**|Allow to forward post with repost (By default `true`)|

@@ -124,2 +125,2 @@ * DON'T forget to pick in your vk group api dashboard event type 'WALL POST - NEW'.

Also u can write to me directly in [Telegram](https://t.me/ejnshtein),
[VK](https://vk.com/lbmmbr001) or by [mail](mailto:ejnshtein@dsgstng.com)
[VK](https://vk.com/lbmmbr001) or by [mail](mailto:ejnshtein@dsgstng.com)

@@ -13,3 +13,4 @@ const vkToTelegram = require('./')

ads: false,
repostAds: false
repostAds: false,
repost: false
})

@@ -16,0 +17,0 @@ const Koa = require('koa')

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc