Class: SlackInteractiveClient::Client
- Inherits:
-
Object
- Object
- SlackInteractiveClient::Client
- Defined in:
- lib/slack_interactive_client/client.rb
Class Attribute Summary collapse
Class Method Summary collapse
- .configure {|configuration| ... } ⇒ Object
- .reset ⇒ Object
- .send_csv(csv_data, channel) ⇒ Object
- .send_message(message, channel) ⇒ Object
- .send_message_with_template(template_name, args = {}) ⇒ Object
Class Attribute Details
.configuration ⇒ Object
14 15 16 |
# File 'lib/slack_interactive_client/client.rb', line 14 def configuration @configuration ||= ::SlackInteractiveClient::Configuration.new end |
Class Method Details
.configure {|configuration| ... } ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/slack_interactive_client/client.rb', line 22 def configure yield configuration ::Slack.configure do |config| config.token = configuration.auth_token config.logger = configuration.logger_instance end "SlackInteractiveClient::Client Configured!" end |
.reset ⇒ Object
18 19 20 |
# File 'lib/slack_interactive_client/client.rb', line 18 def reset @configuration = nil end |
.send_csv(csv_data, channel) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/slack_interactive_client/client.rb', line 67 def send_csv(csv_data, channel) web_client.files_upload( channels: channel, content: csv_data[:content], title: csv_data[:title], filename: csv_data[:filename], initial_comment: csv_data[:comment], as_user: true, ) return "Message sent by: SlackInteractiveClient::Client" rescue ::Slack::Web::Api::Errors::SlackError => e puts "An error occurred when sending the message: #{e.message}" end |
.send_message(message, channel) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/slack_interactive_client/client.rb', line 55 def (, channel) scrubbed = ::SlackInteractiveClient::MessageStopGuard.scrubber.call() web_client.chat_postMessage( channel: channel, blocks: [{ type: 'rich_text', elements: [ type: 'rich_text_section', elements: [ { type: 'text', text: scrubbed } ] ] }], as_user: true, ) return "Message sent by: SlackInteractiveClient::Client" rescue ::Slack::Web::Api::Errors::SlackError => e puts "An error occurred when sending the message: #{e.message}" end |
.send_message_with_template(template_name, args = {}) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/slack_interactive_client/client.rb', line 31 def (template_name, args = {}) compilation = ::SlackInteractiveClient::Message.compile(template_name, args) web_client.chat_postMessage( channel: compilation.channel, blocks: compilation.blocks, as_user: true, ) if compilation.csv? && compilation.csv_data[:csv][:content] web_client.files_upload( channels: compilation.channel, content: compilation.csv_data[:csv][:content], title: compilation.csv_data[:csv][:title], filename: compilation.csv_data[:csv][:filename], initial_comment: compilation.csv_data[:csv][:comment], as_user: true, ) end return "Message sent by: SlackInteractiveClient::Client" rescue ::Slack::Web::Api::Errors::SlackError => e puts "An error occurred when sending the message: #{e.message}" end |