From 37e1f256244f239a86e415fed127a59103f6d530 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Mon, 26 Sep 2022 06:01:25 +0200 Subject: [PATCH] make using proxies only happen in 3 circumstances again --- files/helpers/actions.py | 2 +- files/helpers/cron.py | 2 +- files/helpers/discord.py | 14 +++++++------- files/helpers/media.py | 6 +++--- files/helpers/offsitementions.py | 2 +- files/routes/discord.py | 12 ++++++------ files/routes/giphy.py | 2 +- files/routes/login.py | 2 +- files/routes/posts.py | 4 ++-- files/routes/settings.py | 4 ++-- files/routes/static.py | 4 ++-- 11 files changed, 27 insertions(+), 27 deletions(-) diff --git a/files/helpers/actions.py b/files/helpers/actions.py index 3799a76bb..a59946aaa 100644 --- a/files/helpers/actions.py +++ b/files/helpers/actions.py @@ -30,7 +30,7 @@ def badge_grant(user, badge_id, description=None, url=None, notify=True): def archiveorg(url): - try: requests.get(f'https://web.archive.org/save/{url}', headers={'User-Agent': 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'}, timeout=100, proxies=proxies) + try: requests.get(f'https://web.archive.org/save/{url}', headers={'User-Agent': 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'}, timeout=100) except: pass def archive_url(url): diff --git a/files/helpers/cron.py b/files/helpers/cron.py index b3636c563..65a905ec7 100644 --- a/files/helpers/cron.py +++ b/files/helpers/cron.py @@ -112,7 +112,7 @@ def give_monthly_marseybux_task(): data = {'access_token': GUMROAD_TOKEN} - emails = [x['email'] for x in requests.get(f'https://api.gumroad.com/v2/products/{GUMROAD_ID}/subscribers', data=data, timeout=5, proxies=proxies).json()["subscribers"]] + emails = [x['email'] for x in requests.get(f'https://api.gumroad.com/v2/products/{GUMROAD_ID}/subscribers', data=data, timeout=5).json()["subscribers"]] for u in g.db.query(User).filter(User.patron > 0, User.patron_utc == 0).all(): g.db.add(u) diff --git a/files/helpers/discord.py b/files/helpers/discord.py index 4c637f2be..9068f4884 100644 --- a/files/helpers/discord.py +++ b/files/helpers/discord.py @@ -25,30 +25,30 @@ def discord_wrap(f): def add_role(user, role_name): role_id = ROLES[role_name] url = f"https://discordapp.com/api/guilds/{DISCORD_SERVER_ID}/members/{user.discord_id}/roles/{role_id}" - requests.put(url, headers=headers, timeout=5, proxies=proxies) + requests.put(url, headers=headers, timeout=5) @discord_wrap def remove_role(user, role_name): role_id = ROLES[role_name] url = f"https://discordapp.com/api/guilds/{DISCORD_SERVER_ID}/members/{user.discord_id}/roles/{role_id}" - requests.delete(url, headers=headers, timeout=5, proxies=proxies) + requests.delete(url, headers=headers, timeout=5) @discord_wrap def remove_user(user): url=f"https://discordapp.com/api/guilds/{DISCORD_SERVER_ID}/members/{user.discord_id}" - requests.delete(url, headers=headers, timeout=5, proxies=proxies) + requests.delete(url, headers=headers, timeout=5) @discord_wrap def set_nick(user, nick): url=f"https://discordapp.com/api/guilds/{DISCORD_SERVER_ID}/members/{user.discord_id}" data={"nick": nick} - requests.patch(url, headers=headers, json=data, timeout=5, proxies=proxies) + requests.patch(url, headers=headers, json=data, timeout=5) def send_changelog_message(message): data={"content": message} - requests.post("https://discordapp.com/api/channels/924485611715452940/messages", headers=headers, data=data, timeout=5, proxies=proxies) - requests.post("https://discordapp.com/api/channels/1013992002624426015/messages", headers=headers, data=data, timeout=5, proxies=proxies) + requests.post("https://discordapp.com/api/channels/924485611715452940/messages", headers=headers, data=data, timeout=5) + requests.post("https://discordapp.com/api/channels/1013992002624426015/messages", headers=headers, data=data, timeout=5) def send_wpd_message(message): data={"content": message} - requests.post("https://discordapp.com/api/channels/1013990963846332456/messages", headers=headers, data=data, timeout=5, proxies=proxies) \ No newline at end of file + requests.post("https://discordapp.com/api/channels/1013990963846332456/messages", headers=headers, data=data, timeout=5) \ No newline at end of file diff --git a/files/helpers/media.py b/files/helpers/media.py index 6f7ec0eb3..690e038f9 100644 --- a/files/helpers/media.py +++ b/files/helpers/media.py @@ -30,7 +30,7 @@ def process_files(): def process_other(file): - req = requests.post("https://pomf2.lain.la/upload.php", files={'files[]': file}, timeout=20, proxies=proxies).json() + req = requests.post("https://pomf2.lain.la/upload.php", files={'files[]': file}, timeout=20).json() return req['files'][0]['url'] @@ -47,7 +47,7 @@ def process_audio(file): if os.stat(name).st_size > 8 * 1024 * 1024: with open(name, 'rb') as f: os.remove(name) - req = requests.post("https://pomf2.lain.la/upload.php", files={'files[]': f}, timeout=20, proxies=proxies).json() + req = requests.post("https://pomf2.lain.la/upload.php", files={'files[]': f}, timeout=20).json() return req['files'][0]['url'] return f'{SITE_FULL}{name}' @@ -67,7 +67,7 @@ def process_video(file): if os.stat(new).st_size > 8 * 1024 * 1024: with open(new, 'rb') as f: os.remove(new) - req = requests.post("https://pomf2.lain.la/upload.php", files={'files[]': f}, timeout=20, proxies=proxies).json() + req = requests.post("https://pomf2.lain.la/upload.php", files={'files[]': f}, timeout=20).json() return req['files'][0]['url'] return f'{SITE_FULL}{new}' diff --git a/files/helpers/offsitementions.py b/files/helpers/offsitementions.py index 45c706142..2aaebd88e 100644 --- a/files/helpers/offsitementions.py +++ b/files/helpers/offsitementions.py @@ -33,7 +33,7 @@ def get_mentions(queries): mentions = [] for kind, query in itertools.product(kinds, queries): try: - data = requests.get(f'https://api.pushshift.io/reddit/{kind}/search?html_decode=true&q={query}&size=1', timeout=5, proxies=proxies).json()['data'] + data = requests.get(f'https://api.pushshift.io/reddit/{kind}/search?html_decode=true&q={query}&size=1', timeout=5).json()['data'] except: break for i in data: diff --git a/files/routes/discord.py b/files/routes/discord.py index 659b608ff..23373758d 100644 --- a/files/routes/discord.py +++ b/files/routes/discord.py @@ -55,7 +55,7 @@ def discord_redirect(v): } url="https://discord.com/api/oauth2/token" - x=requests.post(url, headers=headers, data=data, timeout=5, proxies=proxies) + x=requests.post(url, headers=headers, data=data, timeout=5) x=x.json() @@ -67,7 +67,7 @@ def discord_redirect(v): headers={ 'Authorization': f"Bearer {token}" } - x=requests.get(url, headers=headers, timeout=5, proxies=proxies) + x=requests.get(url, headers=headers, timeout=5) x=x.json() @@ -80,7 +80,7 @@ def discord_redirect(v): if v.discord_id and v.discord_id != x['id']: url=f"https://discord.com/api/guilds/{DISCORD_SERVER_ID}/members/{v.discord_id}" - requests.delete(url, headers=headers, timeout=5, proxies=proxies) + requests.delete(url, headers=headers, timeout=5) if g.db.query(User).filter(User.id!=v.id, User.discord_id==x["id"]).one_or_none(): return render_template("message.html", title="Discord account already linked.", error="This Discord account is already in use by another user.", v=v) @@ -97,7 +97,7 @@ def discord_redirect(v): "nick":name, } - x=requests.put(url, headers=headers, json=data, timeout=5, proxies=proxies) + x=requests.put(url, headers=headers, json=data, timeout=5) if x.status_code in {201, 204}: time.sleep(0.1) @@ -112,7 +112,7 @@ def discord_redirect(v): add_role(v, "admin") time.sleep(0.1) - requests.put("https://discord.com/api/guilds/913091440035389520/members/788152118669606932", headers=headers, json={"access_token":token,"roles":[915260962540511292]}, timeout=5, proxies=proxies) + requests.put("https://discord.com/api/guilds/913091440035389520/members/788152118669606932", headers=headers, json={"access_token":token,"roles":[915260962540511292]}, timeout=5) else: return x.json() @@ -124,7 +124,7 @@ def discord_redirect(v): "nick": name } - requests.patch(url, headers=headers, json=data, timeout=5, proxies=proxies) + requests.patch(url, headers=headers, json=data, timeout=5) return redirect(f"https://discord.com/channels/{DISCORD_SERVER_ID}/{DISCORD_WELCOME_CHANNEL}") \ No newline at end of file diff --git a/files/routes/giphy.py b/files/routes/giphy.py index ee45a9c2b..11142c6a1 100644 --- a/files/routes/giphy.py +++ b/files/routes/giphy.py @@ -19,4 +19,4 @@ def giphy(v=None, path=None): url = f"https://api.giphy.com/v1/gifs/search?q={searchTerm}&api_key={GIPHY_KEY}&limit=48" else: url = f"https://api.giphy.com/v1/gifs?api_key={GIPHY_KEY}&limit=48" - return jsonify(requests.get(url, timeout=5, proxies=proxies).json()) + return jsonify(requests.get(url, timeout=5).json()) diff --git a/files/routes/login.py b/files/routes/login.py index c2803ae4f..22bd8712e 100644 --- a/files/routes/login.py +++ b/files/routes/login.py @@ -318,7 +318,7 @@ def sign_up_post(v): "sitekey": HCAPTCHA_SITEKEY} url = "https://hcaptcha.com/siteverify" - x = requests.post(url, data=data, timeout=5, proxies=proxies) + x = requests.post(url, data=data, timeout=5) if not x.json()["success"]: return signup_error("Unable to verify captcha [2].") diff --git a/files/routes/posts.py b/files/routes/posts.py index 12fc9d98c..a770ea38e 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -769,7 +769,7 @@ def submit_post(v, sub=None): return error(reason) elif "twitter.com" == domain: try: - embed = requests.get("https://publish.twitter.com/oembed", params={"url":url, "omit_script":"t"}, timeout=5, proxies=proxies).json()["html"] + embed = requests.get("https://publish.twitter.com/oembed", params={"url":url, "omit_script":"t"}, timeout=5).json()["html"] embed = embed.replace('