-
-
Save therod/23ce3fa058c3b60c565e to your computer and use it in GitHub Desktop.
This file contains 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
require 'slack' | |
require 'curb' | |
Slack.configure do |config| | |
config.token = ENV['SLACK_TOKEN'] | |
end | |
auth = Slack.auth_test | |
client = Slack.realtime | |
client.on :hello do | |
# Slack successfull connected ... | |
puts 'Successfully connected.' | |
end | |
client.on :message do |data| | |
welcome_text = Curl.get(ENV['TEXT_URL']).body_str | |
case data['text'] | |
when 'makersbot welcome text' | |
private_chat = Slack.im_open user: data['user'], as_user: true | |
Slack.chat_postMessage channel: private_chat["channel"]["id"], text: welcome_text, as_user: true | |
end | |
end | |
client.on :team_join do |data| | |
welcome_text = Curl.get(ENV['TEXT_URL']).body_str | |
new_member = data["user"]["id"] | |
private_channel = Slack.im_open(user: new_member, as_user: true)["channel"] | |
Slack.chat_postMessage channel: private_channel["id"], text: welcome_text, as_user: true | |
end | |
client.start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment