How to use vk-io - 10 common examples

To help you get started, we’ve selected a few vk-io examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github happylolonly / events-free-spa / server / parse / vk.js View on Github external
import VK from 'vk-io';
import moment from 'moment';
import chrono from 'chrono-node';

import credentials from '../configs';

import { saveEventItemToDB, convertMonths, formatDate, sliceText, checkText } from './helpers';


const { app, key, token } = credentials.vk;
const vk = new VK({
  app: app,
  key: key,
  token: token,
});

const init = (group) => {
  vk.api.wall.get({
    domain: group,
    // query: `${moment().locale('ru').format('MMMM')}`,
    // query: `*`,
    count: 100,
    filter: 'all'
  })
  .then(wall => {
    // console.log('Wall:', wall);
github ruslang02 / atomos / apps / official / vk / vk.js View on Github external
function initVK() { /* Initializes in the end not to hang the UI when loading */
	const VKIO = require("vk-io");
	VK = VKIO.VK;
	authErrors = VKIO.authErrors;
	vk = new VK({
		appId: 6414462,
		language: "en",
		debug: true
	});
	const implicitFlow = vk.auth.implicitFlowUser();

	implicitFlow.run()
		.then((response) => {
			console.log('Token:', response.token);
			console.log('Expires:', response.expires);

			console.log('Email:', response.email);
			console.log('User ID:', response.user);
		});
	auth = vk.auth;
github fakemancat / vkbot-core / start.js View on Github external
// Модули
const { VK } = require('vk-io');
const vk = new VK();
const fs = require('fs');
const colors = require('colors');
const config = require("./config.js");
// database
const low = require('lowdb');
const FileSync = require('lowdb/adapters/FileSync');
const adapter = new FileSync('database/db.json');
const db = low(adapter);

db.defaults({ users: [] }).write();
//

db.getUser = async(ID) => {
  let user = db.get('users').find({ id: ID }).value();
  if (!user) {
    db.get('users').push({
github negezor / vk-io / docs / examples / questionnaire / bot.js View on Github external
const { VK, Keyboard } = require('vk-io');

const { Wizard } = require('./middlewares/wizard');
const { getSessionMiddleware } = require('./middlewares/session');

const scenes = require('./scenes');

const vk = new VK({
	token: process.env.TOKEN
});

const wizard = new Wizard();

// Register scenes
for (const scene of scenes) {
	wizard.addScene(scene);
}

// Skip outbox messages
vk.updates.on('message', async (context, next) => {
	if (context.isOutbox) {
		return;
	}
github negezor / vk-io / docs / examples / uploads.js View on Github external
const { VK } = require('vk-io');
const fetch = require('node-fetch');

const fs = require('fs');

const vk = new VK({
	token: process.env.TOKEN
});

/**
 * Sets custom uploadUrl or timeout
 */
vk.upload.photoAlbum({
	source: {
		uploadUrl: '<custom upload url>',
		timeout: 60e3,
		values: [
			// Examples of parameters below
		]
	}
});
github negezor / vk-io / docs / examples / simple-keyboard-bot.js View on Github external
const { VK, Keyboard } = require('vk-io');

const vk = new VK({
	token: process.env.TOKEN
});

vk.updates.on('message', (context, next) => {
	const { messagePayload } = context;

	context.state.command = messagePayload && messagePayload.command
		? messagePayload.command
		: null;

	return next();
});

// Simple wrapper for commands
const hearCommand = (name, conditions, handle) => {
	if (typeof handle !== 'function') {
github happylolonly / events-free-spa / server / parse / freeFitnessMinsk.js View on Github external
import tress  from 'tress';




// vk.setOptions({
//     app: 111,
//     login: 'protagonist@valtec.com',
//     pass: 'luckyVaultBoy',
//     phone: '+749531116869'
// });



const vk = new VK({
  app: 6131483,
  key: 'f4vLOjoPyKSOw4qXgb6y',
  scope: 'all',
  token: 'b58844e3b58844e3b58844e34eb5d5cbf8bb588b58844e3ecf6456263d1070e24bb2a38',
});




const URL = 'https://imaguru.by/events/';

var results = [];

// `tress` последовательно вызывает наш обработчик для каждой ссылки в очереди
var q = tress(function(url, callback){
github negezor / vk-io / docs / examples / hello-world.js View on Github external
const { VK } = require('vk-io');

const vk = new VK({
	token: process.env.TOKEN
});

vk.updates.hear(/hello/i, context => (
	context.send('World!')
));

vk.updates.start().catch(console.error);
github negezor / vk-io / docs / examples / simple-session-context.js View on Github external
const { VK } = require('vk-io');
const { SessionManager } = require('@vk-io/session');

const vk = new VK({
	token: process.env.TOKEN
});

const sessionManager = new SessionManager();

vk.updates.on('message', sessionManager.middleware);

vk.updates.hear('/counter', async (context) => {
	const { session } = context;

	if (session.counter === undefined) {
		session.counter = 0;
	}

	session.counter += 1;
github negezor / vk-io / docs / examples / simple-updates-bot.js View on Github external
const { VK } = require('vk-io');

const vk = new VK({
	token: process.env.TOKEN
});

vk.updates.hear('/start', async (context) => {
	await context.send(`
		My commands list

		/cat - Cat photo
		/purr - Cat purring
		/time - The current date
		/reverse - Reverse text
	`);
});

vk.updates.hear('/cat', async (context) => {
	await Promise.all([