Last active
July 1, 2018 11:28
-
-
Save PashaWNN/d9ee065c90cc10df4e9075a69e946be6 to your computer and use it in GitHub Desktop.
Бывает, что нужно найти удалённую беседу, чтобы вернуться в неё, но перебирать все беседы по ID вручную — слишком долго. Скрипт после авторизации выдаёт список всех когда-либо существовавших у вас в диалогах бесед вместе со ссылками на них.
This file contains hidden or 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_api # Нужно установить эту библиотеку: pip install vk_api | |
from getpass import getpass as gp | |
def getChat(vk, id): | |
try: | |
r = vk.method('messages.getChat', {'chat_id': str(id)}) | |
except vk_api.exceptions.ApiError: | |
r = None | |
return r | |
if __name__ == '__main__': | |
login = input('Введите логин: ') | |
password = gp('Введите пароль: ') | |
vk = vk_api.VkApi(login, password) | |
vk.auth() | |
i = 1 | |
eoc = False | |
while not eoc: | |
r = getChat(vk, i) | |
if r is not None: | |
i += 1 | |
print('"%40s", Link: https://vk.com/im?sel=c%i' % (r['title'], r['id'])) | |
else: | |
eoc = True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment