Created
June 29, 2015 17:58
-
-
Save therod/c8ae0691ced05e8ca631 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 'json' | |
Slack.configure do |config| | |
config.token = "xxx" | |
end | |
auth = Slack.auth_test | |
client = Slack.realtime | |
client.on :hello do | |
# Slack successfull connected ... | |
puts 'Successfully connected.' | |
end | |
client.on :message do |data| | |
puts data | |
case data['text'] | |
when 'foundersbot hi' | |
private_chat = Slack.im_open user: data['user'], as_user: true | |
Slack.chat_postMessage channel: private_chat["channel"]["id"], text: "muschi", as_user: true | |
end | |
end | |
client.on :team_join do |data| | |
welcome_text = "Welcome to #founders!" | |
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