1.0.4 • Published 4 years ago

node-ts-vk-api v1.0.4

Weekly downloads
1
License
MIT
Repository
-
Last release
4 years ago

Simple Vk api for typescript

Basic Exaple

import pkg from 'node-ts-vk-api';
const {Bot} = pkg;

const bot = new Bot({
    token: 'YOUR TOKEN HERE'
});

bot.api.method('messages.send', { message: 'Hello World!', peer_id: 1 /* your vk id */});

Uploading Photos for Message

import pkg from 'node-ts-vk-api';
const {Bot} = pkg;
import { createReadStream } from "fs";

const user_id = 1; // id where do you want to send message with photo

const bot = new Bot({
    token: 'YOUR TOKEN HERE'
});

async function main(){
    const { id } = await bot.api.upload(createReadStream('./image.png'), user_id); //creating fs reading stream and uploading image to vk server
    await bot.api.method('messages.send', { message: 'Hello World!', peer_id: user_id, atachement: `photo${user_id}_${id}`});
}
main();
1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago