-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathroutes.py
37 lines (28 loc) · 1.3 KB
/
routes.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
import aiohttp
from config.params import get_cookies, get_header, get_quest_url, get_url_proxies, get_auth_proxies, profile_link, \
GET_header
async def send_post_request(session, url, data, headers, cookies, proxy):
proxy_url = get_url_proxies(proxy)
username = get_auth_proxies(proxy)[0]
password = get_auth_proxies(proxy)[1]
proxy_auth = aiohttp.BasicAuth(username, password)
async with session.post(url, data=data, headers=headers, cookies=cookies, proxy=proxy_url,
proxy_auth=proxy_auth) as resp:
warn = ""
data = await resp.json()
if "error" in data:
if "follow" in data["error"]:
warn = data["error"]["follow"]
else:
warn = data["error"]
elif "message" in data:
warn = data['message'] + " or Already Claimed"
return resp.status, warn
async def send_get_request(session, url, headers, cookies):
async with session.get(url, headers=headers, cookies=cookies) as resp:
response = await resp.json()
return response
async def get_me(access_token):
async with aiohttp.ClientSession() as session:
result = await send_get_request(session, profile_link, GET_header, get_cookies(access_token))
return result["discordHandle"]