class Mihari::Notifiers::Slack
Constants
- DEFAULT_USERNAME
- SLACK_CHANNEL_KEY
- SLACK_WEBHOOK_URL_KEY
Public Instance Methods
notify(text:, attachments: [], mrkdwn: true)
click to toggle source
Send notification to Slack
@param [String] text @param [Array<Hash>] attachments @param [Boolean] mrkdwn
@return [nil]
# File lib/mihari/notifiers/slack.rb, line 57 def notify(text:, attachments: [], mrkdwn: true) notifier = ::Slack::Notifier.new(slack_webhook_url, channel: slack_channel, username: DEFAULT_USERNAME) notifier.post(text: text, attachments: attachments, mrkdwn: mrkdwn) end
slack_channel()
click to toggle source
Slack
channel to post
@return [String]
# File lib/mihari/notifiers/slack.rb, line 17 def slack_channel Mihari.config.slack_channel || "#general" end
slack_webhook_url()
click to toggle source
Slack
webhook URL
@return [String]
# File lib/mihari/notifiers/slack.rb, line 26 def slack_webhook_url Mihari.config.slack_webhook_url end
slack_webhook_url?()
click to toggle source
Check Slack
webhook URL is set
@return [Boolean]
# File lib/mihari/notifiers/slack.rb, line 35 def slack_webhook_url? !Mihari.config.slack_webhook_url.nil? end
valid?()
click to toggle source
Check Slack
webhook URL is set. Alias of slack_webhook_url?
.
@return [Boolean]
# File lib/mihari/notifiers/slack.rb, line 44 def valid? slack_webhook_url? end