This commit is contained in:
eweeman
2026-01-14 16:57:36 -08:00
parent 2544e891f8
commit 4a6e2b898f
14 changed files with 343 additions and 136 deletions

38
scripts/list_channels.py Normal file
View File

@@ -0,0 +1,38 @@
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")

View File

@@ -0,0 +1,55 @@
import os
from dotenv import load_dotenv
from slack_sdk import WebClient
from pathlib import Path
load_dotenv()
def test_slack_connection():
"""Test basic Slack connection and bot setup"""
token = os.getenv("SLACK_TOKEN")
if not token:
print("❌ SLACK_TOKEN not found in .env file")
return False
print(f"✓ SLACK_TOKEN found: {token[:10]}...")
try:
client = WebClient(token=token)
# Test authentication
auth_response = client.auth_test()
if auth_response["ok"]:
print(f"✓ Bot authenticated successfully!")
print(f" Bot User ID: {auth_response['user_id']}")
print(f" Bot Username: {auth_response['user']}")
print(f" Team: {auth_response['team']}")
# Test listing channels
channels_response = client.conversations_list(types="public_channel,private_channel")
if channels_response["ok"]:
channels = channels_response["channels"]
print(f"\n✓ Found {len(channels)} channels:")
for channel in channels[:5]: # Show first 5
print(f" - {channel['name']} (ID: {channel['id']})")
if len(channels) > 5:
print(f" ... and {len(channels) - 5} more")
return True
else:
print(f"❌ Authentication failed: {auth_response}")
return False
except Exception as e:
print(f"❌ Error connecting to Slack: {e}")
return False
if __name__ == "__main__":
print("Testing Slack Connection...\n")
test_slack_connection()