Simple Vk api for typescript
Basic Exaple
import Bot from 'node-ts-vk-api';
const bot = new Bot({
token: 'YOUR TOKEN HERE'
});
bot.api.method('messages.send', { message: 'Hello World!', peer_id: 1 });
Uploading Photos for Message
import Bot from 'node-ts-vk-api';
import { createReadStream } from "fs";
const user_id = 1;
const bot = new Bot({
token: 'YOUR TOKEN HERE'
});
async function main(){
const { id } = await bot.api.upload(createReadStream('./image.png'), user_id);
await bot.api.method('messages.send', { message: 'Hello World!', peer_id: user_id, atachement: `photo${user_id}_${id}`});
}
main();