Commit c969bf59 authored by Samy Haffoudhi's avatar Samy Haffoudhi

ajout du suuport pour channels prives

parent 39edf145
...@@ -6,13 +6,16 @@ from slack_sdk.errors import SlackApiError ...@@ -6,13 +6,16 @@ from slack_sdk.errors import SlackApiError
client = WebClient(token=os.environ.get("SLACK_BOT_TOKEN")) client = WebClient(token=os.environ.get("SLACK_BOT_TOKEN"))
try: try:
result = client.conversations_list() result = client.conversations_list(types="public_channel, private_channel")
for response in result: for response in result:
for channel in result["channels"]: for channel in result["channels"]:
if channel["name"][0] == '2': if (channel["name"][0] == '2') and (not channel["is_archived"]):
if not channel["is_archived"]: try:
client.conversations_join(channel=channel["id"]) client.conversations_join(channel=channel["id"])
except:
pass
client.chat_postMessage(channel=channel["id"], text="Salut ! Ceci est un test :grin:") client.chat_postMessage(channel=channel["id"], text="Salut ! Ceci est un test :grin:")
# print(channel["name"])
except SlackApiError as e: except SlackApiError as e:
print(f"Error: {e}") print(f"Error: {e}")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment