vk-to-telegram
Advanced tools
Comparing version 0.1.0 to 0.1.1
22
index.js
@@ -75,17 +75,25 @@ const forward = require('./lib/forwarder') | ||
} | ||
if (this.debug) { util.log(herokuPosts) } | ||
if (this.heroku) { | ||
const newPost = { id: body.object.id, date: Date.now() } | ||
if (herokuPosts[body.group_id] && herokuPosts[body.group_id].length > 0) { | ||
herokuPosts[body.group_id] = herokuPosts[body.group_id].filter(el => Date.now() - el.date < this.herokuTimeout) | ||
const post = herokuPosts[body.group_id].find(el => el.id === body.object.id) | ||
if (herokuPosts[body.group_id] && Object.keys(herokuPosts[body.group_id]).length > 0) { | ||
for (const id in herokuPosts[body.group_id]) { | ||
const post = herokuPosts[body.group_id][id] | ||
if (Date.now() - post.date > this.herokuTimeout) { | ||
delete herokuPosts[body.group_id][id] | ||
} | ||
} | ||
const post = herokuPosts[body.group_id][newPost.id] | ||
if (post) { | ||
return reject(`Double post detected ${JSON.stringify(body.object)}`) | ||
} else { | ||
herokuPosts[body.group_id].push(newPost) | ||
herokuPosts[body.group_id][newPost.id] = { date: newPost.date } | ||
} | ||
} else { | ||
herokuPosts[body.group_id] = [newPost] | ||
herokuPosts[body.group_id] = { | ||
[newPost.id]: { date: newPost.date } | ||
} | ||
} | ||
} | ||
console.log(herokuPosts) | ||
if (this.debug) { util.log(herokuPosts) } | ||
telegram = new Telegram(this.token) | ||
@@ -114,3 +122,3 @@ vkapi = vkApi(this.vkToken) | ||
} else { | ||
return null | ||
return forwarder(body.object) | ||
} | ||
@@ -117,0 +125,0 @@ } else { |
{ | ||
"name": "vk-to-telegram", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Vk to telegram forwarder", | ||
@@ -5,0 +5,0 @@ "author": "ejnshtein", |
@@ -17,2 +17,3 @@ const vkToTelegram = require('./index'), | ||
}) | ||
vkToTg.debug = true | ||
// vkToTg.debug = true | ||
@@ -26,3 +27,3 @@ app.use(bodyParser.json()) | ||
.catch(err => { | ||
console.log(err) | ||
console.log('err:',err) | ||
}) | ||
@@ -29,0 +30,0 @@ }) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
56607
15
1101
1