File: quoted_message.rb

package info (click to toggle)
mikutter 5.1.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,780 kB
  • sloc: ruby: 22,912; sh: 186; makefile: 21
file content (30 lines) | stat: -rw-r--r-- 1,033 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# -*- coding: utf-8 -*-
# frozen_string_literal: true

Plugin.create :quoted_message do
  command(:copy_message_permalink,
          name: ->(opt) {
            if opt
              _('%{model_label}のURLをコピー') % {model_label: opt&.messages&.first&.class&.spec&.name }
            else
              _('この投稿のURLをコピー')
            end
          },
          condition: ->(opt) { opt.messages.all?(&:perma_link) },
          visible: true,
          role: :timeline) do |opt|
    Plugin.call(:clipboard_write, opt.messages.map(&:perma_link).join("\n"))
  end

  command(:quoted_message,
          name: _('URLを引用して投稿'),
          icon: Skin[:quote],
          condition: ->(opt) { opt.messages.all?(&:perma_link) },
          visible: true,
          role: :timeline) do |opt|
    messages = opt.messages
    opt.widget.create_postbox(to: messages,
                              footer: ' ' + messages.map(&:perma_link).join(' '),
                              to_display_only: true)
  end
end