-
Notifications
You must be signed in to change notification settings - Fork 2
feat: use bolt context when possible #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| import random | ||
| from logging import Logger | ||
|
|
||
| from slack_bolt.context.async_context import AsyncBoltContext | ||
| from slack_bolt.context.say.async_say import AsyncSay | ||
| from slack_sdk.web.async_client import AsyncWebClient | ||
|
|
||
|
|
@@ -21,7 +22,11 @@ | |
|
|
||
|
|
||
| async def handle_message( | ||
| client: AsyncWebClient, event: dict, logger: Logger, say: AsyncSay | ||
| client: AsyncWebClient, | ||
| context: AsyncBoltContext, | ||
| event: dict, | ||
| logger: Logger, | ||
| say: AsyncSay, | ||
| ): | ||
| """Handle direct messages sent to Casey.""" | ||
| # Skip bot messages and message subtypes (edits, deletes, etc.) | ||
|
|
@@ -33,11 +38,11 @@ async def handle_message( | |
| return | ||
|
|
||
| try: | ||
| channel_id = event["channel"] | ||
| team_id = event.get("team") | ||
| channel_id = context.channel_id | ||
| team_id = context.team_id | ||
| text = event.get("text", "") | ||
| thread_ts = event.get("thread_ts") or event["ts"] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔭 thought: I'm curious if you have thoughts ahead to this change too?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yess definitely aim to change this once |
||
| user_id = event.get("user") | ||
| user_id = context.user_id | ||
|
|
||
| # Get session ID for conversation context | ||
| existing_session_id = session_store.get_session(channel_id, thread_ts) | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,16 +1,18 @@ | ||||||||||||||||||||||
| from logging import Logger | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| from slack_bolt import Ack | ||||||||||||||||||||||
| from slack_bolt import Ack, BoltContext | ||||||||||||||||||||||
| from slack_sdk import WebClient | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| def handle_feedback(ack: Ack, body: dict, client: WebClient, logger: Logger): | ||||||||||||||||||||||
| def handle_feedback( | ||||||||||||||||||||||
| ack: Ack, body: dict, client: WebClient, context: BoltContext, logger: Logger | ||||||||||||||||||||||
| ): | ||||||||||||||||||||||
|
Comment on lines
+7
to
+9
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
🪵 suggestion: While we're making a change here? |
||||||||||||||||||||||
| """Handle thumbs up/down feedback on Casey's responses.""" | ||||||||||||||||||||||
| ack() | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| try: | ||||||||||||||||||||||
| channel_id = body["channel"]["id"] | ||||||||||||||||||||||
| user_id = body["user"]["id"] | ||||||||||||||||||||||
| channel_id = context.channel_id | ||||||||||||||||||||||
| user_id = context.user_id | ||||||||||||||||||||||
| message_ts = body["message"]["ts"] | ||||||||||||||||||||||
| feedback_value = body["actions"][0]["value"] | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧮 suggestion: To make reading down fastest!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this suggestion 💯 But I think we might need to do this in another PR since this is fighting against the formatter slightly, we might want to make this a claude guideline 🤔