Skip to content

Instantly share code, notes, and snippets.

@Niraj-Fonseka
Created August 12, 2024 17:13
Show Gist options
  • Save Niraj-Fonseka/10e97ec4b88a19c43714b4f5a3edd002 to your computer and use it in GitHub Desktop.
Save Niraj-Fonseka/10e97ec4b88a19c43714b4f5a3edd002 to your computer and use it in GitHub Desktop.
Remove a slack bot from all the channels it's added to
from slack_bolt import App
import time
app = App(token="")
resp = app.client.users_conversations()
channel_ids_to_skip = []
for c in resp["channels"]:
channel_id = c["id"]
channel_name = c["name"]
print(f"channel_id {channel_id}, channel_name {channel_name}")
if channel_id in channel_ids_to_skip:
print(f"---> skipping {channel_name}")
continue
resp = app.client.conversations_leave(channel=c["id"])
print(resp)
time.sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment