Module slack_bolt.adapter.socket_mode.async_base_handler
The base class of asyncio-based Socket Mode client implementation
Classes
class AsyncBaseSocketModeHandler
-
Expand source code
class AsyncBaseSocketModeHandler: app: Union[App, AsyncApp] client: AsyncBaseSocketModeClient async def handle(self, client: AsyncBaseSocketModeClient, req: SocketModeRequest) -> None: """Handles Socket Mode envelope requests through a WebSocket connection. Args: client: this Socket Mode client instance req: the request data """ raise NotImplementedError() async def connect_async(self): """Establishes a new connection with the Socket Mode server""" await self.client.connect() async def disconnect_async(self): """Disconnects the current WebSocket connection with the Socket Mode server""" await self.client.disconnect() async def close_async(self): """Disconnects from the Socket Mode server and cleans the resources this instance holds up""" await self.client.close() async def start_async(self): """Establishes a new connection and then starts infinite sleep to prevent the termination of this process. If you don't want to have the sleep, use `#connect()` method instead. """ await self.connect_async() if self.app.logger.level > logging.INFO: print(get_boot_message()) else: self.app.logger.info(get_boot_message()) await asyncio.sleep(float("inf"))
Subclasses
Class variables
var app : App | AsyncApp
-
The type of the None singleton.
var client : slack_sdk.socket_mode.async_client.AsyncBaseSocketModeClient
-
The type of the None singleton.
Methods
async def close_async(self)
-
Expand source code
async def close_async(self): """Disconnects from the Socket Mode server and cleans the resources this instance holds up""" await self.client.close()
Disconnects from the Socket Mode server and cleans the resources this instance holds up
async def connect_async(self)
-
Expand source code
async def connect_async(self): """Establishes a new connection with the Socket Mode server""" await self.client.connect()
Establishes a new connection with the Socket Mode server
async def disconnect_async(self)
-
Expand source code
async def disconnect_async(self): """Disconnects the current WebSocket connection with the Socket Mode server""" await self.client.disconnect()
Disconnects the current WebSocket connection with the Socket Mode server
async def handle(self,
client: slack_sdk.socket_mode.async_client.AsyncBaseSocketModeClient,
req: slack_sdk.socket_mode.request.SocketModeRequest) ‑> None-
Expand source code
async def handle(self, client: AsyncBaseSocketModeClient, req: SocketModeRequest) -> None: """Handles Socket Mode envelope requests through a WebSocket connection. Args: client: this Socket Mode client instance req: the request data """ raise NotImplementedError()
Handles Socket Mode envelope requests through a WebSocket connection.
Args
client
- this Socket Mode client instance
req
- the request data
async def start_async(self)
-
Expand source code
async def start_async(self): """Establishes a new connection and then starts infinite sleep to prevent the termination of this process. If you don't want to have the sleep, use `#connect()` method instead. """ await self.connect_async() if self.app.logger.level > logging.INFO: print(get_boot_message()) else: self.app.logger.info(get_boot_message()) await asyncio.sleep(float("inf"))
Establishes a new connection and then starts infinite sleep to prevent the termination of this process. If you don't want to have the sleep, use
#connect()
method instead.