Skip to content

Commit b2cc290

Browse files
zimegClaude
andcommitted
feat(methods): complete codeChannels examples and minimize scopes
Add examples for the remaining codeChannels methods (archive, rename, setProperties, setCommands, listViews, removeView, getCanvas, setCanvasContent) and trim the manifest to the single code_channels:manage bot scope the methods require. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
1 parent 549640b commit b2cc290

10 files changed

Lines changed: 165 additions & 1 deletion

‎methods/README.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,13 @@ $ slack run chat_post_message # Make the request
2222

2323
### codeChannels
2424

25+
- **[codeChannels.archive](https://docs.slack.dev/reference/methods/codeChannels.archive)**: Archives a code channel, optionally recording a summary message. [Implementation](./src/code_channels/code_channels_archive.py).
2526
- **[codeChannels.create](https://docs.slack.dev/reference/methods/codeChannels.create)**: Creates a code channel for a session. [Implementation](./src/code_channels/code_channels_create.py).
27+
- **[codeChannels.getCanvas](https://docs.slack.dev/reference/methods/codeChannels.getCanvas)**: Reads a code channel canvas's content and its comment threads. [Implementation](./src/code_channels/code_channels_get_canvas.py).
28+
- **[codeChannels.listViews](https://docs.slack.dev/reference/methods/codeChannels.listViews)**: Lists the view tabs attached to a code channel. [Implementation](./src/code_channels/code_channels_list_views.py).
29+
- **[codeChannels.removeView](https://docs.slack.dev/reference/methods/codeChannels.removeView)**: Removes a view tab from a code channel. [Implementation](./src/code_channels/code_channels_remove_view.py).
30+
- **[codeChannels.rename](https://docs.slack.dev/reference/methods/codeChannels.rename)**: Renames a code channel. [Implementation](./src/code_channels/code_channels_rename.py).
31+
- **[codeChannels.setCanvasContent](https://docs.slack.dev/reference/methods/codeChannels.setCanvasContent)**: Replaces a code channel canvas's content while preserving comment anchors. [Implementation](./src/code_channels/code_channels_set_canvas_content.py).
32+
- **[codeChannels.setCommands](https://docs.slack.dev/reference/methods/codeChannels.setCommands)**: Registers the agent's per-channel slash commands for a code channel. [Implementation](./src/code_channels/code_channels_set_commands.py).
33+
- **[codeChannels.setProperties](https://docs.slack.dev/reference/methods/codeChannels.setProperties)**: Sets a code channel's context bar items and external resource details. [Implementation](./src/code_channels/code_channels_set_properties.py).
2634
- **[codeChannels.setView](https://docs.slack.dev/reference/methods/codeChannels.setView)**: Publishes a view tab (such as a diff) to a code channel. [Implementation](./src/code_channels/code_channels_set_view.py).
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import os
2+
3+
from slack_sdk import WebClient
4+
5+
# Read a token from an environment variable
6+
token = os.environ.get("SLACK_TOKEN")
7+
8+
# Initialize
9+
client = WebClient(token=token)
10+
11+
# Call the codeChannels.archive method to close out a code channel, optionally
12+
# recording the message that summarizes the work
13+
response = client.codeChannels_archive(
14+
channel_id="C123ABC456",
15+
summary_message_ts="1717171717.123456",
16+
)
17+
18+
# Inspect the response
19+
print(response)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import os
2+
3+
from slack_sdk import WebClient
4+
5+
# Read a token from an environment variable
6+
token = os.environ.get("SLACK_TOKEN")
7+
8+
# Initialize
9+
client = WebClient(token=token)
10+
11+
# Call the codeChannels.getCanvas method to read a code channel canvas's content
12+
# along with its comment threads
13+
response = client.codeChannels_getCanvas(
14+
channel_id="C123ABC456",
15+
)
16+
17+
# Inspect the response
18+
print(response)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import os
2+
3+
from slack_sdk import WebClient
4+
5+
# Read a token from an environment variable
6+
token = os.environ.get("SLACK_TOKEN")
7+
8+
# Initialize
9+
client = WebClient(token=token)
10+
11+
# Call the codeChannels.listViews method to read the view tabs currently
12+
# attached to a code channel
13+
response = client.codeChannels_listViews(
14+
channel_id="C123ABC456",
15+
)
16+
17+
# Inspect the response
18+
print(response)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import os
2+
3+
from slack_sdk import WebClient
4+
5+
# Read a token from an environment variable
6+
token = os.environ.get("SLACK_TOKEN")
7+
8+
# Initialize
9+
client = WebClient(token=token)
10+
11+
# Call the codeChannels.removeView method to detach a view tab from a code
12+
# channel by its view ID
13+
response = client.codeChannels_removeView(
14+
channel_id="C123ABC456",
15+
view_id="V123ABC456",
16+
)
17+
18+
# Inspect the response
19+
print(response)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import os
2+
3+
from slack_sdk import WebClient
4+
5+
# Read a token from an environment variable
6+
token = os.environ.get("SLACK_TOKEN")
7+
8+
# Initialize
9+
client = WebClient(token=token)
10+
11+
# Call the codeChannels.rename method to give a code channel a new name
12+
response = client.codeChannels_rename(
13+
channel_id="C123ABC456",
14+
name="Fix flaky login test v2",
15+
)
16+
17+
# Inspect the response
18+
print(response)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import os
2+
3+
from slack_sdk import WebClient
4+
5+
# Read a token from an environment variable
6+
token = os.environ.get("SLACK_TOKEN")
7+
8+
# Initialize
9+
client = WebClient(token=token)
10+
11+
# Call the codeChannels.setCanvasContent method to replace a code channel
12+
# canvas's content while preserving its comment anchors
13+
response = client.codeChannels_setCanvasContent(
14+
channel_id="C123ABC456",
15+
content="# Plan\n\n1. Reproduce the flaky test\n2. Fix the race\n3. Verify",
16+
)
17+
18+
# Inspect the response
19+
print(response)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import os
2+
3+
from slack_sdk import WebClient
4+
5+
# Read a token from an environment variable
6+
token = os.environ.get("SLACK_TOKEN")
7+
8+
# Initialize
9+
client = WebClient(token=token)
10+
11+
# Call the codeChannels.setCommands method to register the per-channel slash
12+
# commands the agent offers inside a code channel
13+
response = client.codeChannels_setCommands(
14+
channel_id="C123ABC456",
15+
commands=[
16+
{"name": "test", "description": "Run the test suite"},
17+
{"name": "diff", "description": "Show the current diff"},
18+
],
19+
)
20+
21+
# Inspect the response
22+
print(response)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import os
2+
3+
from slack_sdk import WebClient
4+
5+
# Read a token from an environment variable
6+
token = os.environ.get("SLACK_TOKEN")
7+
8+
# Initialize
9+
client = WebClient(token=token)
10+
11+
# Call the codeChannels.setProperties method to pin context bar items (up to
12+
# five) and external resource details to a code channel
13+
response = client.codeChannels_setProperties(
14+
channel_id="C123ABC456",
15+
code_channel={
16+
"context_bar_items": [
17+
{"key": "repo", "label": "acme/billing", "icon": "folder", "url": "https://github.com/acme/billing"},
18+
]
19+
},
20+
)
21+
22+
# Inspect the response
23+
print(response)

‎methods/src/code_channels/manifest.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
"oauth_config": {
1616
"scopes": {
17-
"bot": ["app_mentions:read", "channels:history", "chat:write", "code_channels:manage"]
17+
"bot": ["code_channels:manage"]
1818
}
1919
},
2020
"settings": {

0 commit comments

Comments
 (0)