Skip to content

Commit e12a9dd

Browse files
committed
update format
1 parent 5684bf2 commit e12a9dd

File tree

1 file changed

+30
-24
lines changed

1 file changed

+30
-24
lines changed

camel/bots/slack/slack_app.py

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from camel.utils import dependencies_required
2929

3030
if TYPE_CHECKING:
31+
from slack_bolt.app.async_app import AsyncApp
3132
from slack_bolt.context.async_context import AsyncBoltContext
3233
from slack_bolt.context.say.async_say import AsyncSay
3334
from slack_sdk.web.async_client import AsyncWebClient
@@ -40,7 +41,7 @@ class SlackApp:
4041
r"""Represents a Slack app that is powered by a Slack Bolt `AsyncApp`.
4142
This class is responsible for initializing and managing the Slack
4243
application by setting up event handlers, running the app server, runting
43-
socket mode client, and handling events such as messages and mentions
44+
socket mode client, and handling events such as messages and mentions
4445
from Slack.
4546
"""
4647

@@ -64,20 +65,23 @@ def __init__(
6465
Args:
6566
oauth_token (str): Slack API token for authentication.
6667
app_token (str, optional): Slack app token for authentication.
68+
(default: :obj:`None`)
6769
scopes (str, optional): Slack app scopes for permissions.
70+
(default: :obj:`None`)
6871
signing_secret (str, optional): Signing secret for verifying Slack
69-
requests.
70-
client_id (str, optional): Slack app client ID.
72+
requests. (default: :obj:`None`)
73+
client_id (str, optional): Slack app client ID. (default: :obj:`None`)
7174
client_secret (str, optional): Slack app client secret.
72-
redirect_uri_path (str, optional): The URI path for OAuth redirect.
73-
(default: :str:"/slack/oauth_redirect")
75+
(default: :obj:`None`)
76+
redirect_uri_path (str, optional): The URI path for OAuth redirect.
77+
(default: :str:`/slack/oauth_redirect`)
7478
installation_store (AsyncInstallationStore, optional): The installation
75-
store for handling OAuth installations.
79+
store for handling OAuth installations. (default: :obj:`None`)
7680
socket_mode (bool): A flag to enable socket mode for the Slack app
77-
(default: :bool:False).
81+
(default: :bool:`False`).
7882
oauth_mode (bool): A flag to enable OAuth mode for the Slack app
79-
(default: :bool:False).
80-
83+
(default: :bool:`False`).
84+
8185
Raises:
8286
ValueError: If the `SLACK_OAUTH_TOKEN` and other required
8387
parameters are not provided.
@@ -140,18 +144,19 @@ def _initialize_app(
140144
self,
141145
installation_store: Optional[AsyncInstallationStore] = None,
142146
redirect_uri_path: str = "/slack/oauth_redirect",
143-
) -> Any:
147+
) -> 'AsyncApp':
144148
r"""Initializes the Slack Bolt app with the given installation store
145149
and OAuth settings.
146150
147151
Args:
148152
installation_store (AsyncInstallationStore, optional): The
149153
installation store for handling OAuth installations.
154+
(default: :obj:`None`)
150155
redirect_uri_path (str): The URI path for handling OAuth redirects
151-
(default: :str:"/slack/oauth_redirect").
156+
(default: :str:`/slack/oauth_redirect`).
152157
153158
Returns:
154-
Any: The initialized Slack Bolt app.
159+
AsyncApp: The initialized Slack Bolt app.
155160
"""
156161
from slack_bolt.app.async_app import AsyncApp
157162
from slack_bolt.oauth.async_oauth_settings import AsyncOAuthSettings
@@ -176,7 +181,7 @@ def _initialize_app(
176181
token=self.oauth_token,
177182
)
178183

179-
def setup_handlers(self) -> None:
184+
def setup_handlers(self):
180185
r"""Sets up the event handlers for Slack events, such as `app_mention`
181186
and `message`.
182187
@@ -186,7 +191,7 @@ def setup_handlers(self) -> None:
186191
self._app.event("app_mention")(self.app_mention)
187192
self._app.event("message")(self.on_message)
188193

189-
async def start(self) -> None:
194+
async def start(self):
190195
r"""Starts the Slack Bolt app asynchronously."""
191196
from slack_bolt.adapter.socket_mode.async_handler import (
192197
AsyncSocketModeHandler,
@@ -211,16 +216,17 @@ def run(
211216
port: int = 3000,
212217
path: str = "/slack/events",
213218
host: Optional[str] = None,
214-
) -> None:
219+
):
215220
r"""Starts the Slack Bolt app server to listen for incoming Slack
216221
events.
217222
218223
Args:
219224
port (int): The port on which the server should run.
220-
(default: :int:3000).
225+
(default: :int:`3000`).
221226
path (str): The endpoint path for receiving Slack events.
222-
(default: :str:/slack/events).
227+
(default: :str:`/slack/events`).
223228
host (str, optional): The hostname to bind the server.
229+
(default: :obj:`None`)
224230
"""
225231
self._app.start(port=port, path=path, host=host)
226232

@@ -231,7 +237,7 @@ async def app_mention(
231237
event: Dict[str, Any],
232238
body: Dict[str, Any],
233239
say: "AsyncSay",
234-
) -> None:
240+
):
235241
r"""Event handler for `app_mention` events.
236242
237243
This method is triggered when someone mentions the app in Slack.
@@ -272,7 +278,7 @@ async def on_message(
272278
event: Dict[str, Any],
273279
body: Dict[str, Any],
274280
say: "AsyncSay",
275-
) -> None:
281+
):
276282
r"""Event handler for `message` events.
277283
278284
This method is triggered when the app receives a message in Slack.
@@ -325,7 +331,7 @@ def mention_me(
325331
mention = f"<@{bot_user_id}>"
326332
return mention in message
327333

328-
async def stop(self) -> None:
334+
async def stop(self):
329335
r"""Stops the Slack Bolt app asynchronously."""
330336
from slack_bolt.adapter.socket_mode.async_handler import (
331337
AsyncSocketModeHandler,
@@ -373,11 +379,11 @@ def set_custom_handler(
373379
handler function should accept two arguments: the event profile
374380
and the event body and return the response message or a tuple
375381
containing the response message and the thread_ts.
376-
message_type (Optional[str]): The specific message type to handle
377-
(e.g., 'mention', 'message', etc.).
378-
Defaults to 'default' if not specified.
382+
message_type (str, optional): The specific message type to handle
383+
(e.g., 'mention', 'message', etc.). (default: :str:`default`)
379384
380-
Returns: None
385+
Returns:
386+
None
381387
"""
382388
message_type = message_type or 'default'
383389
self._custom_handlers[message_type] = handler

0 commit comments

Comments
 (0)