Created
August 28, 2018 10:18
-
-
Save mariusz-blaszczak/a2d2290007d2109ee6e75443ada64ea4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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