Class: Slk::Commands::Thread
- Defined in:
- lib/slk/commands/thread.rb
Overview
Views a message thread from a Slack URL
Instance Attribute Summary
Attributes inherited from Base
#options, #positional_args, #runner
Instance Method Summary collapse
- #execute ⇒ Object
- #fetch_and_display_messages(resolved) ⇒ Object
- #resolve_and_display_thread ⇒ Object
Methods inherited from Messages
#missing_target_error, #output_messages
Methods included from Support::InlineImages
#convert_to_png, #in_tmux?, #inline_images_supported?, #iterm2_protocol_supported?, #kitty_graphics_supported?, #png_data?, #print_inline_image, #print_inline_image_with_text, #print_iterm_image, #print_kitty_image, #print_tmux_iterm_image, #print_tmux_kitty_image, #read_image_data_for_protocol, #tmux_client_is_kitty_compatible?
Methods inherited from Base
Constructor Details
This class inherits a constructor from Slk::Commands::Base
Instance Method Details
#execute ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/slk/commands/thread.rb', line 9 def execute result = return result if result resolve_and_display_thread rescue ApiError => e error("Failed to fetch messages: #{e.}") 1 rescue ArgumentError => e error(e.) 1 end |
#fetch_and_display_messages(resolved) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/slk/commands/thread.rb', line 33 def (resolved) ts = resolved.thread_ts || resolved.msg_ts return unless ts api = runner.conversations_api(resolved.workspace.name) raw = fetch_all_thread_replies(api, resolved.channel_id, ts) = raw.map { |m| Models::Message.from_api(m, channel_id: resolved.channel_id) } (, resolved.workspace, resolved.channel_id) 0 end |
#resolve_and_display_thread ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/slk/commands/thread.rb', line 22 def resolve_and_display_thread target = positional_args.first return usage_error unless target parsed = Support::SlackUrlParser.new.parse(target) return url_required_error unless parsed&. resolved = target_resolver.resolve(target, default_workspace: target_workspaces.first) (resolved) end |