Advertisement
stuppid_bot

Лурк интерактивный

Aug 25th, 2014
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.71 KB | None | 0 0
  1. #-*-coding:u8-*-
  2. from account import *
  3. from vklib import *
  4.  
  5. vk = VKClient(delay_time=.5)
  6. vk.login(username, password)
  7. interactive_id=76134582
  8. lurkopub_id=26406986
  9. adminchat_id=1527 # cur.peer-2e9 /im?.*sel=<chat_id>
  10. last_suggest_post_id=int(vk.api('storage.get',key='last_lurkopab_suggest_post_id')) or 0
  11. while 1:
  12.     posts=vk.api('wall.get',owner_id=-lurkopub_id,filter='suggests',count=20)['items']
  13.     ids=[post['id'] for post in posts]
  14.     # print ids
  15.     ids.reverse()
  16.     # print last_suggest_post_id
  17.     for idr in ids:
  18.         if last_suggest_post_id>=idr:
  19.             continue
  20.         poll_id=vk.api('polls.create',question=u'Как?',add_answers=u'["ГОДНОТА","ХУЕТА"]',owner_id=-interactive_id)['id']
  21.         # если аттачей не было, то при редактировании их нельзя прикрепить, причем аттачи нельзя заменить!
  22.         attach='poll-%s_%s' % (interactive_id, poll_id)
  23.         post_id=vk.api('wall.post', owner_id=-interactive_id, attachments=attach)['post_id']
  24.         mess=u'Оцениваем: http://vk.com/wall-%s_%s?w=wall-%s_%s\n' % (interactive_id, post_id, lurkopub_id, idr)
  25.         mess+=u'Прямая ссылка: http://vk.com/wall-%s_%s (через нее можно опубликовать)' % (lurkopub_id, idr)
  26.         vk.api('wall.edit', post_id=post_id, owner_id=-interactive_id, message=mess, attachments=attach)
  27.         vk.api('messages.send', chat_id=adminchat_id, message=u'Голосуем.', attachment='wall-%s_%s'%(interactive_id,post_id))
  28.         vk.api('storage.set',key='last_lurkopab_suggest_post_id',value=idr)
  29.         last_suggest_post_id=idr    
  30.         vk.delay(300)    
  31.     vk.delay(60)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement