-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Luciano Adonis
committed
Mar 27, 2019
1 parent
0b6b621
commit 5a508ce
Showing
5 changed files
with
70 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,13 @@ | ||
# Slack-Ruby-Examples | ||
Other methods of the Slack API using the slack-ruby-client. | ||
# Slack Ruby Examples | ||
Examples of methods that you will find useful sooner or later of the [Slack API](https://api.slack.com/methods) using the [slack-ruby-client](https://github.com/slack-ruby/slack-ruby-client). | ||
|
||
## Methods: | ||
|
||
- [emoji.list](https://api.slack.com/methods/emoji.list): i would say the only possible use for this is spam, but can probe useful is you want something like the URL. | ||
- [reactions.add](https://api.slack.com/methods/reactions.add): reacting like there's no tomorrow, but you need the timestamp of the message. | ||
- [search.files](https://api.slack.com/methods/search.files): for using this method you need to use an user token. | ||
- [users.list](https://api.slack.com/methods/users.list): you can get all the user info that is accessible. | ||
|
||
## More info: | ||
|
||
- [Enseñandole a un bot a ser como tú](https://medium.com/devschile/un-bot-como-tu-3868bb90a627): i explain how to get your user token and how methods work but in spanish. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
require 'slack-ruby-client' | ||
|
||
Slack.configure do |config| | ||
config.token = ENV['SLACK_API_TOKEN'] | ||
config.raise 'Missing ENV[SLACK_API_TOKEN]!' unless config.token | ||
end | ||
|
||
rclient = Slack::RealTime::Client.new | ||
wclient = Slack::Web::Client.new | ||
|
||
message = '' | ||
wclient.emoji_list.emoji.each do |c| | ||
# "icon": "https:\/\/my.slack.com\/emoji\/icon\/icon_name.png" | ||
message += ":#{c[0]}:" | ||
end | ||
|
||
|
||
|
||
rclient.web_client.chat_postMessage channel: '#yourchannel', | ||
text: message |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
require 'slack-ruby-client' | ||
|
||
Slack.configure do |config| | ||
config.token = ENV['SLACK_API_TOKEN'] | ||
config.raise 'Missing ENV[SLACK_API_TOKEN]!' unless config.token | ||
end | ||
|
||
client = Slack::Web::Client.new | ||
|
||
client.reactions_add(channel: '#yourchannel', name: 'joy', timestamp: '1123581321.345589') |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
require 'slack-ruby-client' | ||
|
||
Slack.configure do |config| | ||
config.token = ENV['SLACK_API_TOKEN'] | ||
config.raise 'Missing ENV[SLACK_API_TOKEN]!' unless config.token | ||
end | ||
|
||
client = Slack::Web::Client.new | ||
|
||
p client.search_files(query: 'energon') |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require 'slack-ruby-client' | ||
|
||
Slack.configure do |config| | ||
config.token = ENV['SLACK_API_TOKEN'] | ||
config.raise 'Missing ENV[SLACK_API_TOKEN]!' unless config.token | ||
end | ||
|
||
client = Slack::Web::Client.new | ||
|
||
client.users_list.members.each do |c| | ||
p "Name: #{c.name}, Email: #{c.profile.email}" | ||
# You can also check if the users are available with something like this: | ||
# | ||
# if c.deleted == false | ||
# "Name: #{c.name}, Email: #{c.profile.email}" | ||
# end | ||
end |