Class: Lita::Handlers::Amesh::Uploaders::SlackUploader
- Inherits:
-
Object
- Object
- Lita::Handlers::Amesh::Uploaders::SlackUploader
- Defined in:
- lib/lita/handlers/amesh/uploaders/slack_uploader.rb
Instance Method Summary collapse
-
#initialize(token:) ⇒ SlackUploader
constructor
A new instance of SlackUploader.
- #upload_image(image_path) ⇒ Object
Constructor Details
#initialize(token:) ⇒ SlackUploader
Returns a new instance of SlackUploader.
11 12 13 14 15 16 |
# File 'lib/lita/handlers/amesh/uploaders/slack_uploader.rb', line 11 def initialize(token:) Slack.configure do |config| config.token = token end @client = Slack::Web::Client.new end |
Instance Method Details
#upload_image(image_path) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/lita/handlers/amesh/uploaders/slack_uploader.rb', line 18 def upload_image(image_path) filename = "#{Time.now.strftime("%Y%m%d%H%M")}.jpg" client.files_upload( channels: '#general', as_user: false, file: Faraday::UploadIO.new(image_path, 'image/jpeg'), title: 'アメッシュ', filename: filename ) end |