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 });
Uploading Photos for Message
import pkg from 'node-ts-vk-api';
const {Bot} = pkg;
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();