Skip to content

Instantly share code, notes, and snippets.

@mariusz-blaszczak
Created August 28, 2018 10:18
Show Gist options
  • Save mariusz-blaszczak/a2d2290007d2109ee6e75443ada64ea4 to your computer and use it in GitHub Desktop.
Save mariusz-blaszczak/a2d2290007d2109ee6e75443ada64ea4 to your computer and use it in GitHub Desktop.
module Slack
class MessageReceivedEventHandler
attr_reader :message
def initialize(message)
@message = message
end
def handle
if message_implicate_that_doors_were_just_opened?
Doors.open!
Firebase::PushToAndroid.new.call
end
end
private
def message_implicate_that_doors_were_just_opened?
allowed_words = %w(o open openeiro)
allowed_words.any? { |word| word == message.downcase }
end
end
end
module Slack
class PushNotification
SLACK_INCOMING_WEBHOOK_URL = ENV.fetch('SLACK_INCOMING_WEBHOOK_URL')
def self.notify
HTTParty.post(SLACK_INCOMING_WEBHOOK_URL,
body: {
text: 'Drzwi do biura otwarte!',
}.to_json,
headers: { 'Content-Type' => 'application/json' }
)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment