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.2 to 0.2.3

44

.eslintrc.js
module.exports = {
"env": {
"node": true,
"es6":true,
"browser": true
"browser": true,
"es6": true,
"node": true
},

@@ -13,5 +13,12 @@ "extends": "eslint:recommended",

"rules": {
"no-console": 0,
"no-case-declarations":0,
"no-extra-parens": 1,
"block-scoped-var": 1,
"curly": 1,
"eqeqeq": 1,
"no-global-assign": 1,
"no-implicit-globals": 1,
"no-labels": 1,
"no-multi-str": 0,
"comma-spacing": 1,

@@ -24,12 +31,18 @@ "comma-style": 1,

"lines-around-comment": 1,
"no-multiple-empty-lines": 1,
"space-infix-ops": 1,
"arrow-spacing": 1,
"arrow-parens":0,
"no-var": 1,
"prefer-const": 1,
"no-unsafe-negation": 1,
"array-callback-return": 1,
"dot-location": 0,
"dot-notation": 1,
"no-eval": 1,
"no-extend-native": 0,
"no-extra-label": 1,
"semi": 1,
"space-before-blocks": 1,
"space-before-function-paren": 0,
"space-before-function-paren": 1,
"space-in-parens": 1,

@@ -39,9 +52,2 @@ "space-unary-ops": 1,

"arrow-body-style": 1,
"rest-spread-spacing": 1,
"no-console": 0,
"no-case-declarations":0,
"no-extra-parens": 1,
"no-var": 1,
"no-unsafe-negation": 1,
"no-restricted-imports": 1,

@@ -51,13 +57,4 @@ "no-duplicate-imports": 1,

"no-useless-rename": 1,
"no-multiple-empty-lines": 1,
"no-global-assign": 1,
"no-implicit-globals": 1,
"no-labels": 1,
"no-multi-str": 1,
"no-trailing-spaces": 0,
"no-unreachable":0,
"no-eval": 1,
"no-extend-native": 0,
"no-extra-label": 1,
"rest-spread-spacing": 1,
"no-trailing-spaces": 1,
"indent": [

@@ -79,4 +76,3 @@ "off",

]
},
// "globals": { "fetch": false }
}
};

@@ -30,4 +30,8 @@ const forwarder = require('./lib/forwarder')

* @param {String} [options.filterByHashtag] - Filter posts by hashtag (use '-' in start to invert)
* @param {Boolean} [options.ads=true] - Forward posts marked as ads? (By default `true`)
* @param {Boolean} [options.repostAds=true] - Forward reposts marked as ads? (By default `true`)
* @param {String} [options.appendText] - Append text to forwarded post (can be used for hashtags for channel navigation)
* @param {String} [options.prependText] - Same as `appendText` but it's will prepend it in the start of post text
*/
constructor(options) {
constructor (options) {
this.token = options.botToken

@@ -47,5 +51,10 @@ this.chatName = options.chatName ? options.chatName.startsWith('@') ? options.chatName : `@${options.chatName}` : ''

this.signed = options.signed || '👨'
this.secret = options.secret
this.secret = options.secret || ''
this.filterByWord = options.filterByWord ? options.filterByWord.split(',') : []
this.filterByHashtag = options.filterByHashtag ? options.filterByHashtag.split(',') : []
this.ads = typeof options.ads === 'boolean' ? options.ads : true
this.repostAds = typeof options.repostAds === 'boolean' ? options.repostAds : true
this.appendText = options.appendText || ''
this.prependText = options.prependText || ''
this.send = this.send.bind(this)

@@ -74,3 +83,3 @@ }

}
debug('Post body: %b', body)
debug('Post body: %b', body)
if (body.type === 'confirmation') {

@@ -106,3 +115,2 @@ await callback(this.vkConfirmation)

if (post) {
throw `Double post detected ${JSON.stringify(body.object)}`

@@ -119,3 +127,2 @@ } else {

if (this.debug) {debug('heroku Obj: %p', herokuPosts) }
if (this.fromId ? body.object.from_id !== this.fromId : false) {

@@ -125,3 +132,3 @@ throw `Wrong post from_id: ${body.object.from_id} !== ${this.fromId}`

if (body.type !== 'wall_post_new') {
throw 'Not a event.type wall_post_new'
throw 'Not a event.type wall_post_new' + ` ${body.type}`
}

@@ -134,6 +141,10 @@ if (body.object.post_type !== 'post') {

})
if (response.length) {
const messages = []
const post = response[0]
if (!this.ads) {
if (typeof post.marked_as_ads === 'number' && post.marked_as_ads !== 0) {
throw 'This is an ad. Rejecting.'
}
}
if (post.text) {

@@ -154,5 +165,16 @@ if (post.text.length > 4090) {

}
if (this.prependText) {
post.text = `${this.prependText}${post.text ? '\n' + post.text : ''}`
}
if (this.appendText) {
post.text = `${post.text ? post.text + '\n' : ''}${this.appendText}`
}
messages.push({type:'post', post: await forward(post)})
if (post.copy_history) {
const repost = post.copy_history[post.copy_history.length - 1]
if (!this.repostAds) {
if (typeof repost.marked_as_ads === 'number' && repost.marked_as_ads !== 0) {
throw 'Ad in repost. Rejecting.'
}
}
if (repost.text) {

@@ -159,0 +181,0 @@ if (repost.text.length > 4090) {

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

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

"debug": "^4.1.0",
"html-entities": "^1.2.1"
"html-entities": "^1.2.1",
"telegraf": "^3.22.2"
},

@@ -38,5 +39,4 @@ "repository": {

"koa-bodyparser": "^4.2.1",
"koa-route": "^3.2.0",
"telegraf": "^3.22.2"
"koa-route": "^3.2.0"
}
}

@@ -63,3 +63,3 @@ # vk to telegram forwarder

## What content does it forward?
## What content does it forward

@@ -110,2 +110,6 @@ | Content type | Works fully? |

|`filterByHashtah`|`String`|**Optional**|Filter posts by hashtag (use ',' as separator) (use '-' in begin of word to invert)|
|`ads`|`Boolean`|**Optional**|Forward posts marked as ads? (By default `true`)|
|`repostAds`|`Boolean`|**Optional**|Forward reposts marked as ads? (By default `true`)|
|`appendText`|`String`|**Optional**|Append text to forwarded post (can be used for hashtags for channel navigation)|
|`prependText`|`String`|**Optional**|Same as `appendText` but it's will prepend it in the start of post text|

@@ -117,4 +121,4 @@ * DON'T forget to pick in your vk group api dashboard event type 'WALL POST - NEW'.

Here's a telegram [group](https://t.me/vktotgforwarder) ¯\\_(ツ)_/¯
Here's a telegram [group](https://t.me/vktotgforwarder) ¯\\_(ツ)_/¯
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)
const vkToTelegram = require('./')
const config = require('./config.json')
const vkToTg = new vkToTelegram({
botToken: config.botToken,
chatName: config.chatName,
vkConfirmation: config.vkConfirmation,
ownerId: config.ownerId,
vkToken: config.vkToken,
customVkButton: config.customVkButton,
customPollTitle: config.customPollTitle,
customLongPostText: config.customLongPostText,
...config,
filterByWord: 'someword',

@@ -16,3 +9,7 @@ filterByHashtag: '#jojo',

heroku: false,
debug: true
debug: true,
prependText: '#overwatch',
appendText: '#hollycow',
ads: false,
repostAds: false
})

@@ -19,0 +16,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