vk-to-telegram
Advanced tools
Comparing version 0.4.4 to 0.4.5
@@ -34,2 +34,3 @@ const forwarder = require('./lib/forwarder') | ||
this.sendNativePoll = typeof options.sendNativePoll === 'boolean' ? options.sendNativePoll : true | ||
this.criedHalfBea = typeof options.criedHalfBea === 'boolean' ? options.criedHalfBea : false | ||
@@ -36,0 +37,0 @@ this.send = this.send.bind(this) |
@@ -19,2 +19,3 @@ const { Telegram } = require('telegraf') | ||
const { sendDocument, sendPhoto, sendVideo } = Sender(config) | ||
const { criedHalfBea } = config | ||
return async post => { | ||
@@ -95,3 +96,3 @@ const chatId = config.chatId | ||
messageExtra.disable_web_page_preview = false | ||
return telegram.sendMessage(chatId, `<a href="${utils.photo.getHQ(attachments[0].album.thumb)}"> </a><a>${mediaText}</a>`, messageExtra) | ||
return telegram.sendMessage(chatId, `<a href="${utils.photo.getHQ(attachments[0].album.thumb, criedHalfBea)}"> </a><a>${mediaText}</a>`, messageExtra) | ||
} | ||
@@ -103,3 +104,3 @@ } else if (mediaText.length < 1000 && utils.isAlbum(attachments)) { | ||
type: 'photo', | ||
media: utils.photo.getHQ(attachment.photo), | ||
media: utils.photo.getHQ(attachment.photo, criedHalfBea), | ||
caption: mediaText, | ||
@@ -163,3 +164,3 @@ parse_mode: 'HTML' | ||
type: 'photo', | ||
media: utils.photo.getHQ(attachments[i].photo), | ||
media: utils.photo.getHQ(attachments[i].photo, criedHalfBea), | ||
caption: attachments[i].photo.text.length < 1000 ? decode(attachments[i].photo.text) : '', | ||
@@ -166,0 +167,0 @@ parse_mode: 'HTML' |
@@ -7,3 +7,3 @@ const Telegram = require('telegraf/telegram') | ||
const { decode } = new AllHtmlEntities() | ||
module.exports = ({ token, vkToken, chatId }) => { | ||
module.exports = ({ token, vkToken, chatId, criedHalfBea }) => { | ||
const telegram = new Telegram(token) | ||
@@ -21,3 +21,3 @@ const vkapi = vkApi(vkToken) | ||
if (doc.preview.photo) { | ||
extra.thumb = utils.photo.getHQ(doc.preview.photo) | ||
extra.thumb = utils.photo.getHQ(doc.preview.photo, criedHalfBea) | ||
} | ||
@@ -74,12 +74,12 @@ if (!text) { | ||
if (!text) { | ||
return telegram.sendPhoto(chatId, utils.photo.getHQ(photo), extra) | ||
return telegram.sendPhoto(chatId, utils.photo.getHQ(photo, criedHalfBea), extra) | ||
} else if (!text && photo.text.length < 1000) { | ||
extra.caption = photo.text | ||
return telegram.sendPhoto(chatId, utils.photo.getHQ(photo), extra) | ||
return telegram.sendPhoto(chatId, utils.photo.getHQ(photo, criedHalfBea), extra) | ||
} else if (text && text.length < 1000) { | ||
extra.caption = text | ||
return telegram.sendPhoto(chatId, utils.photo.getHQ(photo), extra) | ||
return telegram.sendPhoto(chatId, utils.photo.getHQ(photo, criedHalfBea), extra) | ||
} else { | ||
extra.disable_web_page_preview = false | ||
return telegram.sendMessage(chatId, `<a href="${utils.photo.getHQ(photo)}">\u{E0020}</a>${text}`, extra) | ||
return telegram.sendMessage(chatId, `<a href="${utils.photo.getHQ(photo, criedHalfBea)}">\u{E0020}</a>${text}`, extra) | ||
} | ||
@@ -86,0 +86,0 @@ }, |
module.exports = { | ||
photo: { | ||
getHQ (photo) { | ||
getHQ (photo, criedHalfBea = false) { | ||
if (photo.sizes) { | ||
const sizes = photo.sizes.sort((a, b) => a.width - b.width) | ||
return sizes[sizes.length - 1].url | ||
if (criedHalfBea) { | ||
const zSize = photo.sizes.find(el => el.type === 'z') | ||
if (zSize) { | ||
return zSize.url | ||
} | ||
} | ||
return photo.sizes.pop().url | ||
} | ||
let photoUrl | ||
if (criedHalfBea && typeof photo.photo_2560 === 'string') { | ||
delete photo.photo_2560 | ||
} | ||
switch ('string') { | ||
@@ -10,0 +18,0 @@ case typeof photo.photo_2560: |
{ | ||
"name": "vk-to-telegram", | ||
"version": "0.4.4", | ||
"version": "0.4.5", | ||
"description": "Vk to telegram forwarder", | ||
@@ -28,3 +28,3 @@ "author": "ejnshtein", | ||
"html-entities": "^1.2.1", | ||
"telegraf": "^3.34.1", | ||
"telegraf": "^3.36.0", | ||
"telegram-typings": "^4.0.0-beta" | ||
@@ -31,0 +31,0 @@ }, |
@@ -60,4 +60,6 @@ # vk to telegram forwarder | ||
| [<img src="https://i.imgur.com/UYV2cfV.png" height="120">](https://vk.com/advance_empire) | [<img src="https://i.imgur.com/2RR0fXh.png" height="120">](https://vk.com/panzer_sofa) | [<img src="https://i.imgur.com/51DrStx.jpg" height="120">](https://vk.com/oleglivanovgaming) | [<img src="https://i.imgur.com/FnBpfyl.jpg" height="120">](https://vk.com/ongoing_research) | | ||
|[<img src="https://i.imgur.com/7wydIxN.png" height="120">](https://vk.com/anireact)|[<img src="https://i.imgur.com/Y0kda79.png" height="120">](https://vk.com/otakusquad)|[<img src="https://i.imgur.com/yu6BNFj.png" height="120">](https://vk.com/dsgtng)|| | ||
|-|-|-|-| | ||
| [AlexandriA (AAR)](https://t.me/advance_emp) | [PanzerSofa](https://t.me/PanzerSofa) | [Олег Ливанов](https://t.me/oleglivanovgaming) | [ongoing research](https://t.me/ongoings) | | ||
| [<img src="https://i.imgur.com/7wydIxN.png" height="120">](https://vk.com/anireact) | [<img src="https://i.imgur.com/Y0kda79.png" height="120">](https://vk.com/otakusquad) | [<img src="https://i.imgur.com/yu6BNFj.png" height="120">](https://vk.com/dsgtng) || | ||
| [аниреакт](https://t.me/telereact) | [Otaku Squad](https://t.me/otakusquadt) | [disgusting otaku](https://t.me/dsgstngotakunews) || | ||
@@ -116,2 +118,3 @@ ## What content does it forward | ||
|`sendNativePoll`|`Boolean`|**Optional**|Use native [Telegram poll](https://core.telegram.org/bots/api#april-14-2019) instead of link to poll in VK, set `false` to use poll in VK| | ||
|`criedHalfBea`|`Boolean`|**Optional**|Use Z sized pictures as max. (Reduces pictures aliasing)| | ||
@@ -118,0 +121,0 @@ * DON'T forget to pick in your vk group api dashboard event type 'WALL POST - NEW'. |
@@ -12,2 +12,3 @@ const VkToTelegram = require('./') | ||
repostAds: false, | ||
criedHalfBea: true, | ||
// sendNativePoll: false | ||
@@ -14,0 +15,0 @@ }) |
47780
1100
127
Updatedtelegraf@^3.36.0