def process(client: SocketModeClient, req: SocketModeRequest):
     if req.type == "events_api":
         response = SocketModeResponse(envelope_id=req.envelope_id)
         client.send_socket_mode_response(response)
         client.web_client.reactions_add(
             name="eyes",
             channel=req.payload["event"]["channel"],
             timestamp=req.payload["event"]["ts"],
         )
Ejemplo n.º 2
0
    def _process_event(self, client: SocketModeClient, req: SocketModeRequest):
        if req.type == "events_api":
            # Acknowledge the request anyway
            response = SocketModeResponse(envelope_id=req.envelope_id)
            client.send_socket_mode_response(response)

            # Add a reaction to the message if it's a new message
            message = req.payload["event"]
            if message["type"] == "message" and message.get("subtype") is None:
                self.message_queue.put(message)
Ejemplo n.º 3
0
    def process(self, client: SocketModeClient, req: SocketModeRequest):
        if req.type != "events_api":
            return

        # Acknowledge the request anyway
        response = SocketModeResponse(envelope_id=req.envelope_id)
        client.send_socket_mode_response(response)

        if (req.payload["event"]["type"] == "message"
                or req.payload["event"]["type"] == "app_mention"
            ) and req.payload["event"].get("subtype") is None:
            with self.app.app_context():
                bot.run_action(req.payload, req.payload["event"]["channel"])
Ejemplo n.º 4
0
def process(client: SocketModeClient, req: SocketModeRequest):
    if req.type == "events_api":
        # Acknowledge the request anyway
        response = SocketModeResponse(envelope_id=req.envelope_id)
        client.send_socket_mode_response(response)

        # Add a reaction to the message if it's a new message
        if req.payload["event"]["type"] == "message" \
            and req.payload["event"].get("subtype") is None:
            client.web_client.reactions_add(
                name="eyes",
                channel=req.payload["event"]["channel"],
                timestamp=req.payload["event"]["ts"],
            )
Ejemplo n.º 5
0
    def on_socket_mode_request(self, client: SocketModeClient,
                               req: SocketModeRequest):
        if req.type == "events_api":
            # Acknowledge the request anyway
            response = SocketModeResponse(envelope_id=req.envelope_id)
            client.send_socket_mode_response(response)

            if req.payload['event']['type'] == 'open':
                self.on_open(req.payload['event'])
            elif req.payload['event']['type'] == 'message':
                self.on_message(req.payload['event'])
            elif req.payload['event']['type'] == 'channel_joined':
                self.on_channel_joined(req.payload['event'])
            elif req.payload['event']['type'] == 'channel_left':
                self.on_channel_left(req.payload['event'])
            elif req.payload['event']['type'] == 'member_joined_channel':
                self.on_member_joined_channel(req.payload['event'])
            elif req.payload['event']['type'] == 'member_left_channel':
                self.on_member_left_channel(req.payload['event'])