Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gt-vk-api

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gt-vk-api

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

GTVKApi

This API for VK (Actually it mix of two APIs) that mostly adapted for bots, but can be used for anything

It written in TypeScript, but can be used in JS too. All examples in this readme written in TS.

.d.ts files for used APIs and this api can be found on github

For node imports will be converted like this:

import {name1, name2} from 'gt-vk-api'; 

->

var vk = require('gt-vk-api');
var name1 = vk.name1;
var name2 = vk.name2;

or just require and use vk.name1; vk.name2;


and

import Name = require('name');

->

var Name = require('name');

bot in all examples is bot from vk-bot-api so you can also use all it features

Authentication:

With login & pass:

    import {auth, Creditanials} from 'gt-vk-api';
    
    const credentials: Credentials = {
        client_id: 0,//Application ID
        login: 'login|email|phone',
        pass: 'password',
        phone: 'phone',
        scope: ['messages', 'photos', 'users', 'audio']
    };
    
    //Second argumet is prefix for bot command
    auth(credentials, '!').then(bot => {
        //You have access to api now
    }).catch(e => {
        //Authorization faild, e describes the error
    });
    

With token:

    import {authToken} from 'gt-vk-api';
    import Bot = require('vk-bot-api');
    
    //Second argumet is prefix for bot command
    var bot: Bot = authToken('...token...', '!');
    //You have access to api now

Api access:

    import {$} from 'gt-vk-api';//$ can be replaced with 'callApi'
    
    $('method.name', {
        param1: 1,
        parame2" 'foo'
    }, bot /*Optional, if ommited last authenticated bot will be used*/).then(res => {
        //res is 'response' param from json returned by vk
    }.catch(e => {
        //Error
    });

Sending message:

By peer_id (User id || chat id + 2000000000 || -group id)

    bot.sendMessage(peer_id, "message");

By message ('message.getById' or from frist arg in command (see below)):

    import {reply} from 'gt-vk-api';
    
    reply(msg, "message", bot /*Optional, if ommited last authenticated bot will be used*/);

Commands:

    import {createCommand, Message} form 'gt-vk-api'
    
    //Should be used after authentication
    createCommand('commandName' (msg: Message, args: string[]) => {
        //Perform command here
    }

Regex can also be used:

    import {createCommand, Message} form 'gt-vk-api'
    
     //Should be used after authentication
     createCommand('/commandNam.?/i' (msg: Message, args: string[]) => {
        //Perform command here
     }

FAQs

Package last updated on 22 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc