Example #1
0
 def send_message(self, request: GladosRequest, **kwargs):
     message = Message(
         text=request.json.message,
         blocks=[
             SectionBlock(text=MarkdownTextObject(
                 text=request.json.message))
         ],
     )
     return self.bot.send_message(channel=request.json.channel,
                                  message=message)
Example #2
0
    def update_message(self, channel: str, ts: str, message: Message) -> SlackResponse:
        """Updates a message that was sent by the bot

        Parameters
        ----------
        channel :
        ts :
        message :

        Returns
        -------

        """
        return self.client.chat_update(channel=channel, ts=ts, **message.to_dict()).data
Example #3
0
 def action_go_to_alerts(self, request: GladosRequest, **kwargs):
     # self.bot.validate_slack_signature(request)
     self.bot.send_message(
         message=Message(
             text="Going to alerts",
             blocks=[
                 SectionBlock(
                     text="Confirm Action",
                     accessory=ButtonElement(
                         text="Acknowledge", action_id="ack", value="ack"
                     ),
                 )
             ],
         ),
         channel=request.json.user.id,
     )
Example #4
0
    def send_message(self, channel: str, message: Message) -> SlackResponse:
        """Send a message as the bot

        Parameters
        ----------
        channel
            channel to send the message to
        message
            message object to send

        Returns
        -------

        """
        return self.client.chat_postMessage(channel=channel,
                                            as_user=True,
                                            **message.to_dict()).data
Example #5
0
 def update_message(self, request: GladosRequest, **kwargs):
     message = Message(
         text=request.json.message,
         blocks=[
             ContextBlock(elements=[
                 MarkdownTextObject(
                     text=
                     f"Message Updated: {datetime.now().isoformat(sep=' ', timespec='minutes')}"
                 )
             ]),
             SectionBlock(text=MarkdownTextObject(
                 text=request.json.message)),
         ],
     )
     return self.bot.update_message(channel=request.json.channel,
                                    ts=request.json.ts,
                                    message=message)
Example #6
0
 def send_message(self, request: GladosRequest, **kwargs):
     message = request.json.message
     channel = request.json.channel
     return self.bot.send_message(channel, Message(text=message))
Example #7
0
 def action_go_to_alerts(self, request: GladosRequest, **kwargs):
     # self.bot.validate_slack_signature(request)
     self.bot.send_message(
         message=Message(text="Going to alerts"),
         channel=request.json.user.id,
     )
Example #8
0
 def ack_handler(self, request: GladosRequest, **kwargs):
     return Message(text="I hear you")