0.1.14 • Published 5 years ago

vk-subs-activity v0.1.14

Weekly downloads
19
License
MIT
Repository
github
Last release
5 years ago

VK group subscribers activity monitoring (Node.js)

This module helps you to count activity of your VK group subscribers (likes, comments etc). And easy to integrate with your bot or something else.

Getting Started

Install

npm i vk-subs-activity

Usage

Fast start below, continue reading for advanced usage.

const VkSubsActivity = require('vk-subs-activity');

const vkSubsActivity = new VkSubsActivity({
  token: process.env.TOKEN, // SERVICE or USER token, NOT group
  groupId: process.env.GROUP_ID, // e.g. 147845620
});

vkSubsActivity.updateList()
  .then(() => {
    console.log(vkSubsActivity.getList());
  });

Tests

npm test

Methods

constructor(settings)

Default config
new VkSubsActivity({
  token: undefined,
  groupId: undefined,
  lang: 'ru',
  adminsIds: [],
  likes: {
    valueOfUsual: 1,
    valueOfTop: 2,
    countOfFirstAreTop: 5,
    valueOfLikedAllPosts: 5,
    ignoreAdmins: true,
  },
  comments: {
    valueOfUsual: 3,
    valueOfTop: 4,
    countOfFirstAreTop: 5,
    ignoreShorterThan: 10,
    valueOfLikesFromOthers: 5,
    ignoreAdmins: true,
  },
});
Properties description
PropertyTypeDefaultDescription
tokenstringundefinedVK Service or User access_token
groupIdnumberundefinedGroup id for monitoring
langstringruVK api data language
adminsIdsnumber[][]Activity of this users don't affect in rating (they will not get any points for activity)
likes.valueOfUsualnumber1Number of points user receive for "usual" like (not in the first N likes)
likes.valueOfTopnumber2Number of points user receive for "top" like (in the first N likes)
likes.countOfFirstAreTopnumber5How many first likes will get extra points
likes.valueOfLikedAllPostsnumber5User will get extra points if he liked all posts at the update interval fromDate - toDate
likes.ignoreAdminsbooleantrueAdmins likes will not affect in rating
comments.valueOfUsualnumber3Number of points user receive for "usual" comment (not in the first N comments)
comments.valueOfTopnumber4Number of points user receive for "top" comment (in the first N comments)
comments.countOfFirstAreTopnumber5How many first comments will get extra points
comments.ignoreShorterThannumber10Users who leave short comment, will not get points for this
comments.valueOfLikesFromOthersnumber5Number of points user receive if someone likes his comment
comments.ignoreAdminsbooleantrueAdmins comments will not affect in rating

.startAutoUpdate(settings, cb)

Starts rating auto update in selected interval. Clears rating list before each iteration to prevent double data rewriting. Optionally, you can pass a function as second argument, and it will executes every time when subs-activity-list is updated

Default config
.startAutoUpdate({
  fromDate: Math.floor(Date.now() / 1000 - 604800),
  toDate: Math.floor(Date.now() / 1000),
  interval: 300000,
}, Promise.resolve);
Properties description
PropertyTypeDefaultDescription
fromDatenumberMath.floor(Date.now() / 1000 - 604800) (Unix time 7 days ago)Only group posts newer than this Unix time affects rating
toDatenumberMath.floor(Date.now() / 1000) (Unix time now)Only group posts older than this Unix time affects rating
intervalnumber300000 (ms)Interval of rating update

.stopAutoUpdate()

It stops rating auto update

.getList(settings)

Default config
.getList({
  count: 0,
  plain: false,
  sortBy: 'points',
  sortDirection: 'desc',
  search: undefined,
});
Properties description
PropertyTypeDefaultDescription
countnumber0 (all)Number of rating items will return
plainbooleanfalseRating list will return as string
sortBystringpointsRating list will sort by (id / firstName / lastName / usualLikes / topLikes / totalLikes / usualComments / topComments / totalComments / commentsLikesFromOthers / likedAllPosts / points / place)
sortDirectionstringdescRating list sort direction ascending or descending (asc / desc)
searchobjectundefined (all)Will return only rating items which match search query. E.g. search: { id: 123456 } or search: { firstName: 'Ivan' }

.updateList(settings)

Manual update of the rating list. Note that .updateList() will not clear rating list before update

Settings are equal to .startAutoUpdate(settings, cb), but without interval property

.clearList()

Clears rating list

License

MIT

0.1.14

5 years ago

0.1.13

5 years ago

0.1.12

5 years ago

0.1.11

5 years ago

0.1.10

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago