From 586ef2cfc1a8fb80140e6d5355c7943b4b69f822 Mon Sep 17 00:00:00 2001 From: Firepup Sixfifty Date: Tue, 4 Jun 2024 17:18:48 -0500 Subject: [PATCH] Formatting --- main.py | 51 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/main.py b/main.py index e6cce39..b4084b5 100644 --- a/main.py +++ b/main.py @@ -6,13 +6,17 @@ import firepup650 as fp input = fp.replitInput -fp.replitCursor = fp.bcolors.REPLIT + ">>>" + fp.bcolors.RESET # Totally not hijacking one of my functions to use ;P +fp.replitCursor = ( + fp.bcolors.REPLIT + ">>>" + fp.bcolors.RESET +) # Totally not hijacking one of my functions to use ;P load_dotenv() for requiredVar in ["SLACK_BOT_TOKEN", "SLACK_APP_TOKEN"]: if not os.environ.get(requiredVar): - raise ValueError(f'Missing required environment variable "{requiredVar}". Please create a .env file in the same directory as this script and define it.') + raise ValueError( + f'Missing required environment variable "{requiredVar}". Please create a .env file in the same directory as this script and define it.' + ) print("Establishing a connection to slack...") app = App(token=os.environ.get("SLACK_BOT_TOKEN")) @@ -36,7 +40,11 @@ print("All pages loaded, generating user mappings now.") del pages user_mappings = {} for user in users_list: - user_mappings[f"<@{user['id']}>"] = f"<@{user['profile']['display_name']}>" if user["profile"]["display_name"] else f"<@{user['id']}>" + user_mappings[f"<@{user['id']}>"] = ( + f"<@{user['profile']['display_name']}>" + if user["profile"]["display_name"] + else f"<@{user['id']}>" + ) print("User mappings loaded. User count:", len(user_mappings)) @@ -50,10 +58,14 @@ if __name__ == "__main__": thread = input("Reply to a thread? (y|N)").lower().startswith("y") ts = None if thread: - hasID = input("Do you have the TS ID? (y|N))").lower().startswith("y") + hasID = ( + input("Do you have the TS ID? (y|N))").lower().startswith("y") + ) if not hasID: try: - print("Getting the last 50 messages for threading options...") + print( + "Getting the last 50 messages for threading options..." + ) res = client.conversations_history( channel=chan, inclusive=True, limit=50 ) @@ -65,25 +77,32 @@ if __name__ == "__main__": for user in user_mappings: label = label.replace(user, user_mappings[user]) texts[label] = i - found = messages[fp.menu(texts, "Please select the message to reply to as a thread")] + found = messages[ + fp.menu( + texts, + "Please select the message to reply to as a thread", + ) + ] ts = found["ts"] except Exception as E: print(f"Exception: {E}") break else: ts = input("TS ID") - print("^C to change/exit thread (^C twice if you want to change channel)") + print( + "^C to change/exit thread (^C twice if you want to change channel)" + ) try: - while 1: - msg = input("[THREAD] Message (Raw text, not blocks)") - try: - print( - client.chat_postMessage( - channel=chan, text=msg, thread_ts=ts + while 1: + msg = input("[THREAD] Message (Raw text, not blocks)") + try: + print( + client.chat_postMessage( + channel=chan, text=msg, thread_ts=ts + ) ) - ) - except Exception as E: - print(f"Exception: {E}") + except Exception as E: + print(f"Exception: {E}") except KeyboardInterrupt: print() if ts: