Compare commits

..

No commits in common. "c7542b89f588e331c8be216882c1bd1de94d18b6" and "65717b9ad976ed0cc56411f8cee59b07f023bbaf" have entirely different histories.

13
main.py
View file

@ -52,21 +52,20 @@ except ImportError:
users_list.extend(data["members"]) users_list.extend(data["members"])
pages += 1 pages += 1
print( print(
f"[INFO] Pages of users loaded: {pages} (Estimated user count: {pages}000)" f"[INFO] Pages of users loaded: {pages} (Estimated user count: {len(pages) * 1000}"
) )
del pages del pages
print("[INFO] Building user mappings now, this shouldn't take long...") print("[INFO] Building user mappings now, this shouldn't take long...")
#print(users_list[38])
for ( for (
user user
) in ( ) in (
users_list users_list
): # Map user ID mentions to user name mentions, it's nicer when printing messages for thread selection. ): # Map user ID mentions to user name mentions, it's nicer when printing messages for thread selection.
userMappings[f"<@{user['id']}>"] = ( userMappings[f"<@{user['id']}>"] = (
f"<@{user['profile']['display_name_normalized']}|{user['id']}>" f"<@{user['profile']['display_name_normalized']}>"
if user["profile"]["display_name_normalized"] if user["profile"]["display_name_normalized"]
else ( # User is missing a display name for some reason, fallback to real names else ( # User is missing a display name for some reason, fallback to real names
f"<@{user['profile']['real_name_normalized']}|{user['id']}>" f"<@{user['profile']['real_name_normalized']}>"
if user["profile"]["real_name_normalized"] if user["profile"]["real_name_normalized"]
else f"<@{user['id']}>" # User is missing a real name too... Fallback to ID else f"<@{user['id']}>" # User is missing a real name too... Fallback to ID
) )
@ -91,7 +90,7 @@ if __name__ == "__main__":
ts = None ts = None
if thread: if thread:
hasID = ( hasID = (
input("Do you have the TS ID? (y|N)").lower().startswith("y") input("Do you have the TS ID? (y|N))").lower().startswith("y")
) )
if not hasID: if not hasID:
try: try:
@ -151,8 +150,8 @@ if __name__ == "__main__":
"\\n", "\n" "\\n", "\n"
) )
try: try:
ts = client.chat_postMessage(channel=chan, text=msg)['ts'] client.chat_postMessage(channel=chan, text=msg)
print(f"[INFO] Message sent (to the channel)! (TS ID: {ts})") print("[INFO] Message sent (to the channel)!")
except Exception as E: except Exception as E:
print("[WARN] Exception:") print("[WARN] Exception:")
for line in format_exc().split("\n")[:-1]: for line in format_exc().split("\n")[:-1]: