-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
following_new_users.py
69 lines (63 loc) · 2.26 KB
/
following_new_users.py
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
#!/usr/bin/env python
# coding:utf-8
# | |
# --+----------------------------------------------------------+--
# | Code by : yasserbdj96 |
# | Email : [email protected] |
# | Github : https://github.com/yasserbdj96 |
# | BTC : bc1q2dks8w8uurca5xmfwv4jwl7upehyjjakr3xga9 |
# --+----------------------------------------------------------+--
# | all posts #yasserbdj96 ,all views my own. |
# --+----------------------------------------------------------+--
# | |
#START{
# IMPORT
import requests
import argparse
from base64 import b64encode
import time
import shutil
from hexor import *
import os
from datetime import datetime
# INPUT ARG
ap = argparse.ArgumentParser()
ap.add_argument('-t', '--token', required=True)
ap.add_argument('-m', '--username', required=True)
args = ap.parse_args()
p1=hexor(False,"hex")
# RESPONE AUTH
HEADERS = {"Authorization": "Basic " + b64encode(str(args.username + ":" + args.token).encode('utf-8')).decode('utf-8')}
res = requests.get("https://api.github.com/user", headers=HEADERS)
if(res.status_code != 200):
p1.c("Failure to Authenticate! Please check PersonalAccessToken and Username!","#ff0000")
exit(1)
else:
p1.c("Authentication Succeeded!","#22a701")
# SESSION HEADER
sesh = requests.session()
sesh.headers.update(HEADERS)
def following_new(new_users):
new_list=new_users
print("Starting to Follow Users...")
for i in range(len(new_users)):
time.sleep(2)
res = sesh.put('https://api.github.com/user/following/' + new_users[i])
if res.status_code != 204:
print("Rate-limited, please wait until it finish!")
time.sleep(60)
else:
print("Start Following : "+ new_users[i])
new_list.remove(new_users[i])
f = open("new_users_list.txt", "w+")
for i in range(len(new_list)):
f.write(new_list[i]+"\n")
f.close()
new_users = []
try:
with open("new_users_list.txt") as file_in:
for line in file_in:
new_users.append(line.replace('\n',''))
following_new(new_users)
except:
pass