Sha256: de49882759fb45829c0ffd7286ab95dab3b3537fcc382858c73d60aabdbfe2cf

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

module SlackBotManager
  module Commands

    def on_hello(data)
      debug(data)
    end

    def on_message(data)
      debug(data)

			message = data['text'].downcase

      site_by_word = /is (\w{2,}) (?:down|up)/
      site_by_url = /is (\w{2,}\.\w{1,}) (?:down|up)/
      site_by_link = /is <https?:\/\/[a-zA-Z\.]+\|((?:www.)\w{2,}\.\w\w{1,})> (?:down|up)/

      if message =~ site_by_word
        typing(data['channel'])
        word = site_by_word.match(message)[1]
        url = Status.find_url(word)
        if (url)
          message(data['channel'], Status.isitdown(url), icon_emoji: ":ok:")
        end
      end

      if message =~ site_by_url
        typing(data['channel'])
        url = site_by_url.match(message)[1]
        message(data['channel'], Status.isitdown(url), icon_emoji: ":ok:")
      end

      if message =~ site_by_link
        typing(data['channel'])
        url = site_by_link.match(message)[1]
        message(data['channel'], Status.isitdown(url), icon_emoji: ":ok:")
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
slack-bot-manager-0.1.0pre5 examples/downforeveryone-bot/lib/slack.rb
slack-bot-manager-0.1.0pre4 examples/downforeveryone-bot/lib/slack.rb
slack-bot-manager-0.1.0pre3 examples/downforeveryone-bot/lib/slack.rb