This repository has been archived by the owner on Sep 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathunfollower.rb
78 lines (62 loc) · 1.86 KB
/
unfollower.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/env ruby
# encoding: utf-8
require 'rubygems'
require 'bundler/setup'
require 'instagram'
require 'date'
require 'socket'
require_relative 'functions'
#setting
CLIENT_ID = ""
CLIENT_SECRET = ""
ACCESS_TOKEN = ""
LOGIN = ""
IP = ""
MAX_UNFOLLOWS_PER_HOUR = 50 #max 60
MAX_SLEEP_TIME = 3600
current_unfollow_count = 0
puts "Unfollower instagram v 0.1"
sleep 3
#create client for instagram api
begin
client = Instagram.client(:client_id => CLIENT_ID, :client_secret => CLIENT_SECRET, :client_ips => IP, :access_token => ACCESS_TOKEN)
puts "Авторизация инстаграм успешна"
sleep 1
rescue Exception => e
puts "Ошибка авторизации"
puts e.inspect
end
#get list follows current user
begin
puts "Получаем список подписок текущего пользователя(может занять продолжительное время)"
old_follows_username = user_follows(LOGIN)
sleep 1
rescue Exception => e
puts "Ошибки получения списка подписок"
puts e.inspect
end
i = 0
#unfollowing
while i < old_follows_username.size
begin
users = client.user_search(old_follows_username[i])
uid = users[0][:id]
response = client.unfollow_user(uid)
case response.outgoing_status
when "none"
puts "[#{Time.now}]: Успешно отписались от #{old_follows_username[i]}"
end
rescue Exception => e
puts "Ошибка во время анфоловинга"
puts e.inspect
end
i+= 1
current_unfollow_count += 1
timer = rand(10) + 10
sleep timer
if current_unfollow_count == MAX_UNFOLLOWS_PER_HOUR
puts " [#{Time.now}]: Достигнут лимит. Приостанавлеваем работу на #{MAX_SLEEP_TIME}"
sleep MAX_SLEEP_TIME
end
end
puts "[#{Time.now}]: Работа завершена"