From 2aaa21828c3be393a6d5793253c69c69120d5fa9 Mon Sep 17 00:00:00 2001 From: Srijan-SS02 Date: Tue, 13 Sep 2022 16:30:11 +0000 Subject: [PATCH] :art: Python code fromated with psf/black --- pastebin-bot/bot.py | 3 +++ pastebin-bot/link_shortner.py | 4 +--- pastebin-bot/quotes.py | 9 ++++++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pastebin-bot/bot.py b/pastebin-bot/bot.py index af80bfb..7e22412 100644 --- a/pastebin-bot/bot.py +++ b/pastebin-bot/bot.py @@ -12,6 +12,7 @@ from yt_download_shorts import download_video, get_title import instaloader from link_shortner import short + bot = telebot.TeleBot(API_KEY) # TBD @@ -154,6 +155,7 @@ def handle_video_download_yt(message): except instaloader.ConnectionException: bot.reply_to(message, "IP is Blocked Please Try After Some Time") + # This Decorator Deals with /short @bot.message_handler(commands=["short"]) def handle_short(message): @@ -165,5 +167,6 @@ def handle_short(message): except: bot.reply_to(message, f"We can't abel to short{payload_link_data}") + if __name__ == "__main__": bot.infinity_polling() diff --git a/pastebin-bot/link_shortner.py b/pastebin-bot/link_shortner.py index 2fb4028..315c08d 100644 --- a/pastebin-bot/link_shortner.py +++ b/pastebin-bot/link_shortner.py @@ -10,7 +10,7 @@ def short(url: str): headers = { "content-type": "application/x-www-form-urlencoded", "X-RapidAPI-Key": "e02923797dmshddea57448263f98p13ab17jsn9e252949aa6f", - "X-RapidAPI-Host": "url-shortener-service.p.rapidapi.com" + "X-RapidAPI-Host": "url-shortener-service.p.rapidapi.com", } response = requests.request("POST", url, data=payload, headers=headers) x = dict(response.json()) @@ -18,5 +18,3 @@ def short(url: str): for i in x.values(): return_link = i return return_link - - diff --git a/pastebin-bot/quotes.py b/pastebin-bot/quotes.py index 1c35416..72655e7 100644 --- a/pastebin-bot/quotes.py +++ b/pastebin-bot/quotes.py @@ -12,14 +12,17 @@ def preload_quotes(): global quotes quotes.clear() - - randon_quote = requests.get(api, headers={'X-Api-Key': 'ZSVhux9848gfWCCCLMlESQ==UwDZ4yCxgj0irhQu'}).json() + + randon_quote = requests.get( + api, headers={"X-Api-Key": "ZSVhux9848gfWCCCLMlESQ==UwDZ4yCxgj0irhQu"} + ).json() content = randon_quote[0] author = content["author"] quote = content["quote"] + "\n\n" + "By " + author quotes.append(quote) -#print(quotes[0]) + +# print(quotes[0]) # preload_quotes() #