Formatting
This commit is contained in:
parent
22f9a027ec
commit
586ef2cfc1
1 changed files with 35 additions and 16 deletions
33
main.py
33
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,14 +77,21 @@ 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)")
|
||||
|
|
Loading…
Reference in a new issue