-
Notifications
You must be signed in to change notification settings - Fork 280
Docs: say_stream #1463
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
Open
lukegalbraithrussell
wants to merge
14
commits into
main
Choose a base branch
from
docs-say_stream-docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Docs: say_stream #1463
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
cacf2ad
feat: add support for say_stream utility function
WilliamBergamin f30dd71
Improve unit tests around SayStream
WilliamBergamin 3e49461
Patch fixes and better test coverage
WilliamBergamin a4a63c8
claude found some stuff to fix
WilliamBergamin 55ea797
fix python 3.7 test issues
WilliamBergamin 6a7f0f7
Update tests/scenario_tests/test_events_say_stream.py
WilliamBergamin 42b6c4d
Improve conssistancy in naming
WilliamBergamin eda8e73
surface the buffer_size override
WilliamBergamin db99b51
make things alphabet
WilliamBergamin 9aaedf7
improving asserts in unit tests
WilliamBergamin 143e8e3
make things work for org apps
WilliamBergamin b142675
adds docs
lukegalbraithrussell affb6a1
go
lukegalbraithrussell 6048885
table thing
lukegalbraithrussell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # Don't add async module imports here | ||
| from .say_stream import SayStream | ||
|
|
||
| __all__ = [ | ||
| "SayStream", | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| import warnings | ||
| from typing import Optional | ||
|
|
||
| from slack_sdk.web.async_client import AsyncWebClient | ||
| from slack_sdk.web.async_chat_stream import AsyncChatStream | ||
|
|
||
| from slack_bolt.warning import ExperimentalWarning | ||
|
|
||
|
|
||
| class AsyncSayStream: | ||
| client: AsyncWebClient | ||
| channel: Optional[str] | ||
| recipient_team_id: Optional[str] | ||
| recipient_user_id: Optional[str] | ||
| thread_ts: Optional[str] | ||
|
|
||
| def __init__( | ||
| self, | ||
| *, | ||
| client: AsyncWebClient, | ||
| channel: Optional[str] = None, | ||
| recipient_team_id: Optional[str] = None, | ||
| recipient_user_id: Optional[str] = None, | ||
| thread_ts: Optional[str] = None, | ||
| ): | ||
| self.client = client | ||
| self.channel = channel | ||
| self.recipient_team_id = recipient_team_id | ||
| self.recipient_user_id = recipient_user_id | ||
| self.thread_ts = thread_ts | ||
|
|
||
| async def __call__( | ||
| self, | ||
| *, | ||
| buffer_size: Optional[int] = None, | ||
| channel: Optional[str] = None, | ||
| recipient_team_id: Optional[str] = None, | ||
| recipient_user_id: Optional[str] = None, | ||
| thread_ts: Optional[str] = None, | ||
| **kwargs, | ||
| ) -> AsyncChatStream: | ||
| warnings.warn( | ||
| "say_stream is experimental and may change in future versions.", | ||
| category=ExperimentalWarning, | ||
| stacklevel=2, | ||
| ) | ||
|
|
||
| channel = channel or self.channel | ||
| thread_ts = thread_ts or self.thread_ts | ||
| if channel is None: | ||
| raise ValueError("say_stream without channel here is unsupported") | ||
| if thread_ts is None: | ||
| raise ValueError("say_stream without thread_ts here is unsupported") | ||
|
|
||
| if buffer_size is not None: | ||
| return await self.client.chat_stream( | ||
| buffer_size=buffer_size, | ||
| channel=channel, | ||
| recipient_team_id=recipient_team_id or self.recipient_team_id, | ||
| recipient_user_id=recipient_user_id or self.recipient_user_id, | ||
| thread_ts=thread_ts, | ||
| **kwargs, | ||
| ) | ||
| return await self.client.chat_stream( | ||
| channel=channel, | ||
| recipient_team_id=recipient_team_id or self.recipient_team_id, | ||
| recipient_user_id=recipient_user_id or self.recipient_user_id, | ||
| thread_ts=thread_ts, | ||
| **kwargs, | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| import warnings | ||
| from typing import Optional | ||
|
|
||
| from slack_sdk import WebClient | ||
| from slack_sdk.web.chat_stream import ChatStream | ||
|
|
||
| from slack_bolt.warning import ExperimentalWarning | ||
|
|
||
|
|
||
| class SayStream: | ||
| client: WebClient | ||
| channel: Optional[str] | ||
| recipient_team_id: Optional[str] | ||
| recipient_user_id: Optional[str] | ||
| thread_ts: Optional[str] | ||
|
|
||
| def __init__( | ||
| self, | ||
| *, | ||
| client: WebClient, | ||
| channel: Optional[str] = None, | ||
| recipient_team_id: Optional[str] = None, | ||
| recipient_user_id: Optional[str] = None, | ||
| thread_ts: Optional[str] = None, | ||
| ): | ||
| self.client = client | ||
| self.channel = channel | ||
| self.recipient_team_id = recipient_team_id | ||
| self.recipient_user_id = recipient_user_id | ||
| self.thread_ts = thread_ts | ||
|
|
||
| def __call__( | ||
| self, | ||
| *, | ||
| buffer_size: Optional[int] = None, | ||
| channel: Optional[str] = None, | ||
| recipient_team_id: Optional[str] = None, | ||
| recipient_user_id: Optional[str] = None, | ||
| thread_ts: Optional[str] = None, | ||
| **kwargs, | ||
| ) -> ChatStream: | ||
| warnings.warn( | ||
| "say_stream is experimental and may change in future versions.", | ||
| category=ExperimentalWarning, | ||
| stacklevel=2, | ||
| ) | ||
|
|
||
| channel = channel or self.channel | ||
| thread_ts = thread_ts or self.thread_ts | ||
| if channel is None: | ||
| raise ValueError("say_stream without channel here is unsupported") | ||
| if thread_ts is None: | ||
| raise ValueError("say_stream without thread_ts here is unsupported") | ||
|
|
||
| if buffer_size is not None: | ||
| return self.client.chat_stream( | ||
| buffer_size=buffer_size, | ||
| channel=channel, | ||
| recipient_team_id=recipient_team_id or self.recipient_team_id, | ||
| recipient_user_id=recipient_user_id or self.recipient_user_id, | ||
| thread_ts=thread_ts, | ||
| **kwargs, | ||
| ) | ||
| return self.client.chat_stream( | ||
| channel=channel, | ||
| recipient_team_id=recipient_team_id or self.recipient_team_id, | ||
| recipient_user_id=recipient_user_id or self.recipient_user_id, | ||
| thread_ts=thread_ts, | ||
| **kwargs, | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
this was my bad; should've been a page from the beginning