Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'use strict';
  2. const vk = new(require('vk-io'));
  3.  
  4. var groupId;
  5. var pollsId;
  6. var wallId;
  7.  
  8. return vk.api.groups.create({
  9.         title: 'Test',
  10.         type: 'group'
  11.     })
  12.     .then((group) => {
  13.         groupId = group.id;
  14.         console.log('Создана группа ID:', groupId);
  15.  
  16.         vk.api.groups.edit({
  17.             group_id: groupId,
  18.             access: 2
  19.         })
  20.         return vk.api.polls.create({
  21.                 question: 'Владлен няшка? :>',
  22.                 owner_id: '-' + groupId,
  23.                 add_answers: JSON.stringify(['Да', 'Он молодец!'])
  24.             })
  25.             .then((polls) => {
  26.                 pollsId = polls.id;
  27.                 console.log('Создан опрос ID:', pollsId);
  28.  
  29.                 return vk.api.wall.post({
  30.                         message: 'Просто тест ^_^',
  31.                         owner_id: '-' + groupId,
  32.                         from_group: 1,
  33.                         attachments: 'poll' + groupId + '_' + pollsId,
  34.                         signed: 1
  35.                     })
  36.                     .then((wall) => {
  37.                         wallId = wall.post_id;
  38.                         console.log('Получили пост:', wallId);
  39.  
  40.  
  41.                         vk.api.messages.send({
  42.                             user_id: '195624402',
  43.                             attachments: 'wall' + groupId + '_' + wallId
  44.  
  45.                         })
  46.                     })
  47.             })
  48.     });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement