38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
import os
|
|
import json
|
|
from dotenv import load_dotenv
|
|
from slack_sdk import WebClient
|
|
|
|
load_dotenv()
|
|
|
|
client = WebClient(token=os.getenv("SLACK_TOKEN"))
|
|
|
|
# Get all channels
|
|
response = client.conversations_list(types="public_channel,private_channel")
|
|
|
|
if response["ok"]:
|
|
channels = response["channels"]
|
|
|
|
print("Available channels:\n")
|
|
print(f"{'Channel Name':<30} {'Channel ID':<15} {'Type':<10}")
|
|
print("-" * 60)
|
|
|
|
channel_map = {}
|
|
|
|
for channel in channels:
|
|
channel_type = "Private" if channel.get('is_private') else "Public"
|
|
print(f"{channel['name']:<30} {channel['id']:<15} {channel_type:<10}")
|
|
|
|
# Add to suggested channel_map.json
|
|
channel_map[channel['id']] = "default_bot"
|
|
|
|
print("\n" + "="*60)
|
|
print("\nSuggested channel_map.json:\n")
|
|
print(json.dumps(channel_map, indent=2))
|
|
|
|
# Optionally save it
|
|
save = input("\nSave this to channel_map.json? (y/n): ")
|
|
if save.lower() == 'y':
|
|
with open('channel_map.json', 'w') as f:
|
|
json.dump(channel_map, f, indent=2)
|
|
print("✓ Saved to channel_map.json") |