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 - npm Package Compare versions

Comparing version 0.0.13 to 0.0.14

176

app.js

@@ -70,5 +70,5 @@ const Telegraf = require('telegraf'),

}
console.log(mediaText)
//console.log(mediaText)
mediaText = mediaText.replace(/\[([\S]*)\|([\S\s]*?)\]/ig, `<a href="https://vk.com/$1">$2</a>`)
console.log(mediaText)
//console.log(mediaText)
if (media.attachments) { // Post generator start

@@ -106,3 +106,3 @@ media = media.attachments

.then(video =>
bot.telegram.sendMessage(params.chatid, `<a href="${video.player}">&#160;</a><a>${mediaText}</a>\n\n<a href="${video.player}">${video.title}</a>`, {
bot.telegram.sendMessage(params.chatid, `<a href="${video.player}">&#160;</a>${mediaText}\n\n<a href="${video.player}">${video.title}</a>`, {
parse_mode: 'HTML',

@@ -112,3 +112,10 @@ disable_web_page_preview: false,

})
.then(resolved())
.then(msg => {
console.log(msg)
if (!msg.response) {
resolved()
} else {
rejected(msg.response)
}
})
)

@@ -129,3 +136,9 @@ .catch(rejected)

disable_web_page_preview: true
}).then(resolved())
}).then(msg => {
if (!msg.response) {
resolved()
} else {
rejected(msg.response)
}
})
} else if (!mediaText && media[0].photo.text.length < 190) {

@@ -138,9 +151,21 @@ mediaText = media[0].photo.text

disable_web_page_preview: true
}).then(resolved())
}).then(msg => {
if (!msg.response) {
resolved()
} else {
rejected(msg.response)
}
})
} else if (mediaText.length > 190) {
bot.telegram.sendMessage(params.chatid, `<a href="${helps.getImgHiRes(media[0].photo)}">&#160;</a><a>${mediaText}</a>`, {
bot.telegram.sendMessage(params.chatid, `<a href="${helps.getImgHiRes(media[0].photo)}">&#160;</a>${mediaText}`, {
parse_mode: 'HTML',
reply_markup: yes ? keyboardStr : '',
disable_web_page_preview: false
}).then(resolved())
}).then(msg => {
if (!msg.response) {
resolved()
} else {
rejected(msg.response)
}
})
}

@@ -171,6 +196,17 @@ break

disable_web_page_preview: true
}).then(resolved())
}).then(msg => {
if (!msg.response) {
resolved()
} else {
rejected(msg.response)
}
})
} else {
bot.telegram.sendMessage(params.chatid, mediaText)
.then(() =>
.then((msg) => {
if (!msg.response) {
resolved()
} else {
rejected(msg.response)
}
bot.telegram.sendDocument(params.chatid, {

@@ -184,11 +220,23 @@ url: vkDocument.url,

disable_web_page_preview: true
}).then(resolved())
)
}).then(msg1 => {
if (!msg1.response) {
resolved()
} else {
rejected(msg1.response)
}
})
})
}
} else {
bot.telegram.sendMessage(params.chatid, `<a>${mediaText}</a>\n\n<a href="${vkDocument.url}>${vkDocument.title}</a>`, {
bot.telegram.sendMessage(params.chatid, `${mediaText}\n\n<a href="${vkDocument.url}>${vkDocument.title}</a>`, {
reply_markup: yes ? keyboardStr : '',
parse_mode: 'HTML',
disable_web_page_preview: false
}).then(resolved())
}).then(msg => {
if (!msg.response) {
resolved()
} else {
rejected(msg.response)
}
})
}

@@ -215,3 +263,9 @@ })

disable_web_page_preview: false,
}).then(resolved())
}).then(msg => {
if (!msg.response) {
resolved()
} else {
rejected(msg.response)
}
})
break

@@ -221,7 +275,13 @@ }

//console.log(media[0].link)
bot.telegram.sendMessage(params.chatid, `<a href="${media[0].link.url}">&#160;</a><a>${mediaText}</a>\n\n<a href="${media[0].link.url}">Link</a>`, {
bot.telegram.sendMessage(params.chatid, `<a href="${media[0].link.url}">&#160;</a>${mediaText}\n\n<a href="${media[0].link.url}">Link</a>`, {
disable_web_page_preview: false,
parse_mode: 'HTML'
})
.then(resolved())
.then(msg => {
if (!msg.response) {
resolved()
} else {
rejected(msg.response)
}
})
} else if (mediaText.length < 190 && helps.isAlbum(media)) {

@@ -241,3 +301,9 @@ let arr = []

bot.telegram.sendMediaGroup(params.chatid, arr)
.then(resolved())
.then(msg => {
if (!msg.response) {
resolved()
} else {
rejected(msg.response)
}
})
} else {

@@ -251,5 +317,9 @@ media = media.filter(res => res.type != 'link')

parse_mode: 'HTML'
}).then(() => {
yes = false
mediaPoster()
}).then((msg) => {
if (!msg.response) {
yes = false
mediaPoster()
} else {
rejected(msg.response)
}
})

@@ -276,3 +346,9 @@ } else {

bot.telegram.sendMediaGroup(params.chatid, arr)
.then(mediaPoster())
.then(msg => {
if (!msg.response) {
mediaPoster()
} else {
rejected(msg.response)
}
})
break

@@ -289,6 +365,10 @@ case 'video':

reply_markup: yes ? keyboardStr : ''
}).then(() => {
yes = false
i++
mediaPoster()
}).then((msg) => {
if (!msg.response) {
yes = false
i++
mediaPoster()
} else {
rejected(msg.response)
}
})

@@ -319,6 +399,10 @@ )

disable_web_page_preview: true
}).then(() => {
yes = false
i++
mediaPoster()
}).then((msg) => {
if (!msg.response) {
yes = false
i++
mediaPoster()
} else {
rejected(msg.response)
}
})

@@ -330,6 +414,10 @@ } else {

disable_web_page_preview: false
}).then(() => {
yes = false
i++
mediaPoster()
}).then((msg) => {
if (!msg.response) {
yes = false
i++
mediaPoster()
} else {
rejected(msg.response)
}
})

@@ -351,5 +439,9 @@ }

reply_markup: keyboard
}).then(() => {
i++
mediaPoster()
}).then((msg) => {
if (!msg.response) {
i++
mediaPoster()
} else {
rejected(msg.response)
}
})

@@ -365,6 +457,12 @@ break

if (mediaText) {
bot.telegram.sendMessage(params.chatid, `<a>${mediaText}</a>`, {
bot.telegram.sendMessage(params.chatid, `${mediaText}`, {
parse_mode: 'HTML',
disable_web_page_preview: false
}).then(resolved())
}).then((msg) => {
if (!msg.response) {
resolved()
} else {
rejected(msg.response)
}
})
} else {

@@ -371,0 +469,0 @@ resolved()

{
"name": "vk-to-telegram",
"version": "0.0.13",
"version": "0.0.14",
"description": "Vk to telegram forwarder",

@@ -14,4 +14,3 @@ "author": "ejnshtein",

"callback api",
"express",
"string"
"express"
],

@@ -18,0 +17,0 @@ "private": false,

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

## Where I can see how it looks?
For example, this sending posts from [Tavern of Heroes | Overwatch](https://vk.com/tavernofoverwatch) to Telegram channel [Tavern of Overwatch | News](https://t.me/tavernofoverwatchnews),
[Oleg Livanov - One man army](https://vk.com/oleglivanovgaming) trought [Heroku](https://heroku.com/) to Telegram channel [Oleg Livanov - One man army](https://t.me/oleglivanovgaming)
[Tavern of Heroes | Overwatch](https://vk.com/tavernofoverwatch) -> [Tavern of Overwatch | News](https://t.me/tavernofoverwatchnews),
[Oleg Livanov - One man army](https://vk.com/oleglivanovgaming) trought [Heroku](https://heroku.com) -> [Oleg Livanov - One man army](https://t.me/oleglivanovgaming)
## Installation

@@ -18,12 +18,13 @@ npm install vk-to-telegram@latest --save

vkToTg = new vkToTelegram({
botToken: token,
chatName: chatName,
ownerId: ownerId,
vkConfirmation: vkConfirmation,
vkToken: vkToken
botToken: 'your bot token',
chatName: 'telegram chat/channel name', // example: '@taverofoverwatchnews' || 'tavernofoverwatchnews'
vkConfirmation: 'group confirmation',
ownerId: 'your telegram id',
fromId: 'your group id', // optional, example: -103208430
vkToken: 'your very long token from vk api'
})
app.use(bodyParser.json()) // Must needed
app.post('/', vkToTg.send) // Now any data that comes here will be sent to Telegram
app.post('/', vkToTg.send) // Post to your Telegram channel/chat
app.listen(80,()=>{ // For heroku users - process.env.PORT https://scotch.io/tutorials/how-to-deploy-a-node-js-app-to-heroku
app.listen(80,()=>{
console.log('listening on port 80')

@@ -47,2 +48,4 @@ })

DON'T forget to pick event type 'WALL POST - NEW,REPOST' in your vk group api dashboard.
### Why?

@@ -49,0 +52,0 @@

@@ -36,6 +36,9 @@ const request = require('request')

try {
body = JSON.parse(response.body).response.items[0]
body = JSON.parse(response.body)
} catch (e) {
rej('error parse data from VK API')
rej(response.body)
}
//console.log(body)
body = body.response.items[0]
//console.log(body)
if (body && body.player) {

@@ -46,6 +49,6 @@ if (/https:\/\/vk\.com/i.test(body.player)) {

if (/https:\/\/player\.vimeo\.com\/video/i.test(body.player)) {
body.player = body.player.replace(/player\./, '').replace(/video\//, '')
body.player = body.player.replace(/player\./i, '').replace(/video\//i, '')
}
if (/https:\/\/www\.youtube\.com\/embed/i.test(body.player)) {
body.player = body.player.replace(/embed\//, 'watch?v=')
body.player = body.player.replace(/embed\//i, 'watch?v=')
}

@@ -70,3 +73,2 @@ return res({

(req, response) => {
console.log(response.body)
body = JSON.parse(response.body)

@@ -73,0 +75,0 @@ res(body.response[0])

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