
    i                         d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlmZ d dlmZ d dlmZ  G d de          ZdS )    )Optional	WebClientAck)BaseContext)Complete)Fail)GetThreadContext)Respond)SaveThreadContext)Say)	SetStatus)SetSuggestedPrompts)SetTitle)create_copyc                      e Zd ZdZddZedd            Zedefd            Zede	fd            Z
edefd            Zedee         fd	            Zedefd
            Zedefd            Zedee         fd            Zedee         fd            Zedee         fd            Zedee         fd            Zedee         fd            ZdS )BoltContextz4Context object associated with a request from Slack.returnc           	      $   i }|                                  D ]k\  }}|| j        v r|||<   || j        v r	 t          |          }|||<   4# t          $ r+}| j                            d| d| d           Y d }~dd }~ww xY wt          |          S )NzSkipped setting 'z' to a copied request for lazy listeners due to a deep-copy creation error. Consider passing the value not as part of context object (error: ))items copyable_standard_property_names$non_copyable_standard_property_namesr   	TypeErrorloggerwarningr   )selfnew_dict	prop_name
prop_valuecopied_valuetes         U/root/projects/butler/venv/lib/python3.11/site-packages/slack_bolt/context/context.pyto_copyablezBoltContext.to_copyable   s    %)ZZ\\ 	 	!IzDAAA&0##dGGG#.z#:#:L*6HY''    K'')I ) )#%) ) )        8$$$s   A
B !A;;B ThreadListenerRunnerc                     | d         S )zSThe properly configured listener_runner that is available for middleware/listeners.listener_runner r   s    r$   r(   zBoltContext.listener_runner,   s     %&&    c                 @    d| vrt          d          | d<   | d         S )ap  The `WebClient` instance available for this request.

            @app.event("app_mention")
            def handle_events(context):
                context.client.chat_postMessage(
                    channel=context.channel_id,
                    text="Thanks!",
                )

            # You can access "client" this way too.
            @app.event("app_mention")
            def handle_events(client, context):
                client.chat_postMessage(
                    channel=context.channel_id,
                    text="Thanks!",
                )

        Returns:
            `WebClient` instance
        clientN)tokenr   r*   s    r$   r-   zBoltContext.client1   s-    , 4&T222DNH~r+   c                 <    d| vrt                      | d<   | d         S )ah  `ack()` function for this request.

            @app.action("button")
            def handle_button_clicks(context):
                context.ack()

            # You can access "ack" this way too.
            @app.action("button")
            def handle_button_clicks(ack):
                ack()

        Returns:
            Callable `ack()` function
        ackr   r*   s    r$   r0   zBoltContext.ackK   s&      %%DKE{r+   c                 b    d| vr$t          | j        | j        | j                  | d<   | d         S )a  `say()` function for this request.

            @app.action("button")
            def handle_button_clicks(context):
                context.ack()
                context.say("Hi!")

            # You can access "ack" this way too.
            @app.action("button")
            def handle_button_clicks(ack, say):
                ack()
                say("Hi!")

        Returns:
            Callable `say()` function
        say)r-   channel	thread_ts)r   r-   
channel_idr4   r*   s    r$   r2   zBoltContext.say_   s9    $ T[$/UYUcdddDKE{r+   c                 v    d| vr.t          | j        | j        j        | j        j                  | d<   | d         S )a  `respond()` function for this request.

            @app.action("button")
            def handle_button_clicks(context):
                context.ack()
                context.respond("Hi!")

            # You can access "ack" this way too.
            @app.action("button")
            def handle_button_clicks(ack, respond):
                ack()
                respond("Hi!")

        Returns:
            Callable `respond()` function
        respond)response_urlproxyssl)r   r8   r-   r9   r:   r*   s    r$   r7   zBoltContext.respondu   sH    $ D  %!.k'KO  DO
 Ir+   c                 V    d| vrt          | j        | j                  | d<   | d         S )a/  `complete()` function for this request. Once a custom function's state is set to complete,
        any outputs the function returns will be passed along to the next step of its housing workflow,
        or complete the workflow if the function is the last step in a workflow. Additionally,
        any interactivity handlers associated to a function invocation will no longer be invocable.

            @app.function("reverse")
            def handle_button_clicks(ack, complete):
                ack()
                complete(outputs={"stringReverse":"olleh"})

            @app.function("reverse")
            def handle_button_clicks(context):
                context.ack()
                context.complete(outputs={"stringReverse":"olleh"})

        Returns:
            Callable `complete()` function
        completer-   function_execution_id)r	   r-   r>   r*   s    r$   r<   zBoltContext.complete   s7    ( T!!'t{RVRlmmmDJr+   c                 V    d| vrt          | j        | j                  | d<   | d         S )a  `fail()` function for this request. Once a custom function's state is set to error,
        its housing workflow will be interrupted and any provided error message will be passed
        on to the end user through SlackBot. Additionally, any interactivity handlers associated
        to a function invocation will no longer be invocable.

            @app.function("reverse")
            def handle_button_clicks(ack, fail):
                ack()
                fail(error="something went wrong")

            @app.function("reverse")
            def handle_button_clicks(context):
                context.ack()
                context.fail(error="something went wrong")

        Returns:
            Callable `fail()` function
        failr=   )r
   r-   r>   r*   s    r$   r@   zBoltContext.fail   s4    ( t{$JdeeeDLF|r+   c                 ,    |                      d          S )N	set_titlegetr*   s    r$   rB   zBoltContext.set_title   s    xx$$$r+   c                 ,    |                      d          S )N
set_statusrC   r*   s    r$   rF   zBoltContext.set_status   s    xx%%%r+   c                 ,    |                      d          S )Nset_suggested_promptsrC   r*   s    r$   rH   z!BoltContext.set_suggested_prompts   s    xx/000r+   c                 ,    |                      d          S )Nget_thread_contextrC   r*   s    r$   rJ   zBoltContext.get_thread_context   s    xx,---r+   c                 ,    |                      d          S )Nsave_thread_contextrC   r*   s    r$   rL   zBoltContext.save_thread_context   s    xx-...r+   N)r   r   )r   r&   )__name__
__module____qualname____doc__r%   propertyr(   r   r-   r   r0   r   r2   r   r   r7   r	   r<   r
   r@   r   rB   r   rF   r   rH   r   rJ   r   rL   r)   r+   r$   r   r      s       >>% % % %, ' ' ' X' 	    X2 S    X& S    X* '*    X2  (       X . d    X. %8H- % % % X% &HY/ & & & X& 1x0C'D 1 1 1 X1 .H-=$> . . . X. /X.?%@ / / / X/ / /r+   r   N)typingr   	slack_sdkr   slack_bolt.context.ackr   slack_bolt.context.base_contextr   slack_bolt.context.completer	   slack_bolt.context.failr
   8slack_bolt.context.get_thread_context.get_thread_contextr   slack_bolt.context.respondr   &slack_bolt.context.save_thread_contextr   slack_bolt.context.sayr   slack_bolt.context.set_statusr   (slack_bolt.context.set_suggested_promptsr   slack_bolt.context.set_titler   slack_bolt.util.utilsr   r   r)   r+   r$   <module>r`      s?               & & & & & & 7 7 7 7 7 7 0 0 0 0 0 0 ( ( ( ( ( ( U U U U U U . . . . . . D D D D D D & & & & & & 3 3 3 3 3 3 H H H H H H 1 1 1 1 1 1 - - - - - -~/ ~/ ~/ ~/ ~/+ ~/ ~/ ~/ ~/ ~/r+   