arcade-mcp/toolkits/slack/arcade_slack/tools/utils.py
Eric Gustin ab889f9f1d
Lint all toolkits (#183)
# PR Description
* Adds/updates the following files to all toolkits:
    - `.pre-commit-config.yaml`
    - `.ruff.toml`
    - `LICENSE`
    - `Makefile`
    - `pyproject.toml`
* Lint all toolkits such that they pass `make check` and `make test` (a
total doozy). This includes adding some unit tests and evals.
* Github workflow for testing toolkits before merge into main (courtesy
of @sdreyer)
* Added a QOL improvement for tool developers for when they need to get
the context's auth token.
* Minor updates to `arcade new` template.
2024-12-20 09:49:45 -08:00

20 lines
771 B
Python

from slack_sdk.web import SlackResponse
def format_channels(channels_response: SlackResponse) -> str:
csv_string = "All active Slack channels:\n\nname\n"
for channel in channels_response["channels"]:
if not channel.get("is_archived", False):
name = channel.get("name", "")
csv_string += f"{name}\n"
return csv_string.strip()
def format_users(userListResponse: SlackResponse) -> str:
csv_string = "All active Slack users:\n\nname,real_name\n"
for user in userListResponse["members"]:
if not user.get("deleted", False):
name = user.get("name", "")
real_name = user.get("profile", {}).get("real_name", "")
csv_string += f"{name},{real_name}\n"
return csv_string.strip()