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.1.2 to 0.1.3-b

2

index.js

@@ -107,3 +107,3 @@ const forward = require('./lib/forwarder')

})
.then(() => vkapi.wall.getById(`${body.object.owner_id}_${body.object.id}`,{
.then(() => vkapi.wall.getById(`${body.object.owner_id}_${body.object.id}`, {
copy_history_depth: 1

@@ -110,0 +110,0 @@ }))

@@ -36,15 +36,17 @@ const Telegram = require('telegraf/telegram')

let { attachments } = media
let attachmentLink
const attachmentLink = []
let poll
if (attachments) {
if (attachments.some(el => el.type === 'link')) {
attachmentLink = attachments.find(el => el.type === 'link').link
if (/^[\d?\s]*$/ig.test(attachmentLink.title)) {
attachmentLink.title = 'Read'
}
attachments.filter(el => el.type === 'link').forEach(({ link }) => {
if (/^[\d?\s]*$/ig.test(link.title)) {
link.title = 'Read more'
}
attachmentLink.push(link)
messageExtra.reply_markup.inline_keyboard.unshift([{
text: entities.decode(link.title).capitalize(),
url: link.url
}])
})
attachments = attachments.filter(el => el.type !== 'link')
messageExtra.reply_markup.inline_keyboard.unshift([{
text: entities.decode(attachmentLink.title).capitalize(),
url: attachmentLink.url
}])
}

@@ -71,8 +73,5 @@ if (attachments.some(el => el.type === 'poll')) {

if (attachments.length === 0 && attachmentLink) {
if (attachments.length === 0 && attachmentLink.length) {
messageExtra.disable_web_page_preview = false
telegram.sendMessage(config.get('chatId'), `<a href="${attachmentLink.url}">&#160;</a>
${mediaText ? mediaText : `<a href="${attachmentLink.url}">${entities.decode(attachmentLink.title).capitalize()}</a>`}
${mediaText ? `\n<a href="${attachmentLink.url}">${attachmentLink.button ? entities.decode(attachmentLink.title).capitalize() : 'Open link source'}</a>` : ''}
`, messageExtra)
telegram.sendMessage(config.get('chatId'), `<a href="${attachmentLink[0].url}">&#160;</a>${mediaText ? `${mediaText}\n\n` : ''}${attachmentLink.map(link => `<a href="${link.url}">${entities.decode(link.title).capitalize()}</a>`).join('\n')}`, messageExtra)
.then(resolve)

@@ -103,3 +102,3 @@ .catch(reject)

text: entities.decode(attachments[0].album.title),
url: `https://vk.com/album'${attachments[0].album.owner_id}_${attachments[0].album.id}`
url: `https://vk.com/album${attachments[0].album.owner_id}_${attachments[0].album.id}`
}])

@@ -159,17 +158,2 @@ messageExtra.disable_web_page_preview = false

})
// telegram.sendMediaGroup(config.get('chatId'), attachmentsArray)
// .then(resolve)
// .catch(reject)
// mediaExtra.reply_markup.inline_keyboard.unshift([{
// text: entities.decode(attachments[i].album.title),
// url: `https://vk.com/album${attachments[i].album.owner_id}_${attachments[i].album.id}`
// }])
// mediaExtra.disable_web_page_preview = false
// sender.sendPhoto(attachments[i].album.thumb, null, mediaExtra)
// .then(msg => {
// i++
// mediaPoster(msg)
// })
// .catch(reject)
} else {

@@ -294,5 +278,6 @@ attachments = attachments.filter(el => el.type !== 'link')

} else {
if (attachmentLink) {
if (attachmentLink.length) {
messageExtra.disable_web_page_preview = false
telegram.sendMessage(config.get('chatId'), `<a href="${attachmentLink.url}">&#160;</a><a href="${attachmentLink.url}">${attachmentLink.button ? `Read "${attachmentLink.title.capitalize()}"` : 'Open source'}</a>`, messageExtra)
telegram.sendMessage(config.get('chatId'), `<a href="${attachmentLink[0].url}">&#160;</a>${attachmentLink.map(link => `<a href="${link.url}">${entities.decode(link.title).capitalize()}</a>`).join('\n')}`, messageExtra)
.then(msg => mediaPoster(msg))

@@ -299,0 +284,0 @@ .catch(reject)

@@ -192,19 +192,24 @@ const Telegram = require('telegraf/telegram')

.then(response => {
const video = response.response.items[0]
const apivideo = response.response.items[0]
let vk = false
switch (video.platform) {
case 'YouTube': // https://www.youtube.com/embed/qLQr0VrMVQk?__ref=vk.api -> https://www.youtube.com/watch?v=tyHAI-70DSg
video.player = `https://youtube.com/watch?v=${video.player.match(/https:\/\/www\.youtube\.com\/embed\/(\S+)\?/i)[1]}`
break
case 'Vimeo': // https://player.vimeo.com/video/231140379?__ref=vk.api -> https://vimeo.com/231140379
video.player = `https://vimeo.com/${video.player.match(/https:\/\/player\.vimeo\.com\/video\/(\S+)\?/i)[1]}`
break
case undefined: // vk
vk = true
video.player = `https://vk.com/video${video.owner_id}_${video.id}`
break
default:
vk = true
video.player = `https://vk.com/video${video.owner_id}_${video.id}`
break
if (apivideo) {
switch (apivideo.platform) {
case 'YouTube': // https://www.youtube.com/embed/qLQr0VrMVQk?__ref=vk.api -> https://www.youtube.com/watch?v=tyHAI-70DSg
apivideo.player = `https://youtube.com/watch?v=${apivideo.player.match(/https:\/\/www\.youtube\.com\/embed\/(\S+)\?/i)[1]}`
break
case 'Vimeo': // https://player.vimeo.com/video/231140379?__ref=vk.api -> https://vimeo.com/231140379
apivideo.player = `https://vimeo.com/${apivideo.player.match(/https:\/\/player\.vimeo\.com\/video\/(\S+)\?/i)[1]}`
break
case undefined: // vk
vk = true
apivideo.player = `https://vk.com/video${apivideo.owner_id}_${apivideo.id}`
break
default:
vk = true
apivideo.player = `https://vk.com/video${apivideo.owner_id}_${apivideo.id}`
break
}
} else {
video.player = `https://vk.com/video${video.owner_id}_${video.id}`
vk = true
}

@@ -219,4 +224,3 @@ extra.disable_web_page_preview = false

return telegram.sendMessage(chatId,
`<a href="${vk ? utils.video.getPreview(video) : video.player}">&#160;</a>
${text ? `${text}\n\n` : ''}<a href="${video.player}">${video.title}</a>`,
`<a href="${vk ? utils.video.getPreview(video) : video.player}">&#160;</a>${text ? `${text}\n\n` : ''}<a href="${video.player}">${video.title}</a>`,
extra)

@@ -223,0 +227,0 @@ })

{
"name": "vk-to-telegram",
"version": "0.1.2",
"version": "0.1.3b",
"description": "Vk to telegram forwarder",

@@ -5,0 +5,0 @@ "author": "ejnshtein",

const vkToTelegram = require('./index'),
app = require('express')(),
bodyParser = require('body-parser'),
axios = require('axios'),
config = require('./config.json'),

@@ -5,0 +6,0 @@ vkToTg = new vkToTelegram({

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