Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const evk = require('easyvk')
- const path = require('path')
- const config = {
- BOT_ID: 176316300,
- START_MESSAGE: 'помощь'
- }
- evk({
- username: 'Аккаунт',
- password: 'Пароль',
- session_file: path.join(__dirname, '.vk')
- }).then(async vk => {
- let startDate = 0;
- let timings = [];
- async function reSend () {
- return new Promise((resolve, reject) => {
- vk.call('messages.send', {
- peer_id: -config.BOT_ID,
- message: config.START_MESSAGE
- }).then(async () => {
- startDate = new Date().getTime()
- if (timings.length < 10) {
- console.log(Math.floor(timings.length/10 * 100) + '%')
- setTimeout(() => {
- reSend().then(resolve, reject)
- }, 5000)
- } else {
- resolve(true)
- }
- })
- })
- }
- let {connection: user} = await vk.longpoll.connect();
- user.on("message", (msg) => {
- if (msg[3] == -config.BOT_ID && !(msg[2] & 2)) {
- timings.push(new Date().getTime() - startDate)
- }
- });
- await reSend();
- console.log(timings.length)
- let sum = 0;
- timings.forEach(t => {sum += t})
- sum /= timings.length;
- console.log(sum)
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement