| 1 |
|
| 2 |
module ::Plugin::Command |
| 3 |
class << self |
| 4 |
extend Gem::Deprecate |
| 5 |
|
| 6 |
はDeprecateです。 |
| 7 |
|
| 8 |
def [](condition, *other) |
| 9 |
if other.empty? |
| 10 |
const_get(condition.to_sym) |
| 11 |
else |
| 12 |
const_get(condition.to_sym) & self[*other] end end |
| 13 |
deprecate :[], :none, 2020, 01 |
| 14 |
end |
| 15 |
|
| 16 |
precateです。 |
| 17 |
|
| 18 |
class Condition |
| 19 |
def initialize(&block) |
| 20 |
@cond = block |
| 21 |
type_strict @cond => :call |
| 22 |
end |
| 23 |
|
| 24 |
def &(follow) |
| 25 |
type_strict follow => :call |
| 26 |
Condition.new{ |opt| call(opt) && follow.call(opt) } end |
| 27 |
|
| 28 |
def |(follow) |
| 29 |
type_strict follow => :call |
| 30 |
Condition.new{ |opt| call(opt) || follow.call(opt) } end |
| 31 |
|
| 32 |
def call(opt) |
| 33 |
@cond.call(opt) end |
| 34 |
alias === call |
| 35 |
alias [] call |
| 36 |
end |
| 37 |
|
| 38 |
ルの条件 |
| 39 |
|
| 40 |
が選択されている |
| 41 |
HasMessage = Condition.new{ |opt| not opt.messages.empty? } |
| 42 |
deprecate_constant :HasMessage |
| 43 |
|
| 44 |
が選択されている |
| 45 |
ondition:には以下のコードを使ってください。 |
| 46 |
|
| 47 |
HasOneMessage = Condition.new{ |opt| opt.messages.size == 1 } |
| 48 |
deprecate_constant :HasOneMessage |
| 49 |
|
| 50 |
ツイートが全てリプライ可能な時。 |
| 51 |
選択されていなければ偽 |
| 52 |
ondition:には以下のコードを使ってください。 |
| 53 |
|
| 54 |
CanReplyAll = Condition.new{ |opt| |
| 55 |
if not opt.messages.empty? |
| 56 |
current_world, = Plugin.filtering(:world_current, nil) |
| 57 |
Plugin[:command].compose?(current_world, to: opt.messages) |
| 58 |
end |
| 59 |
} |
| 60 |
deprecate_constant :CanReplyAll |
| 61 |
|
| 62 |
一つでも現在のアカウントでリツイートできるものがあれば真を返す |
| 63 |
ondition:には以下のコードを使ってください。 |
| 64 |
|
| 65 |
CanReTweetAny = Condition.new { |opt| |
| 66 |
current_world, = Plugin.filtering(:world_current, nil) |
| 67 |
opt.messages.lazy.any?{|m| |
| 68 |
Plugin[:command].share?(current_world, m) && !Plugin[:command].shared?(current_world, m) |
| 69 |
} |
| 70 |
} |
| 71 |
deprecate_constant :CanReTweetAny |
| 72 |
|
| 73 |
て、現在のアカウントでリツイート可能な時、真を返す。 |
| 74 |
みのものはリツイート不可とみなす。 |
| 75 |
選択されていなければ偽 |
| 76 |
CanReTweetAll = Condition.new{ |opt| |
| 77 |
current_world, = Plugin.filtering(:world_current, nil) |
| 78 |
!opt.messages.empty? && opt.messages.lazy.all?{|m| |
| 79 |
Plugin[:command].share?(current_world, m) && !Plugin[:command].shared?(current_world, m) |
| 80 |
} |
| 81 |
} |
| 82 |
deprecate_constant :CanReTweetAll |
| 83 |
|
| 84 |
、現在のアカウントで全てリツイートしている場合。 |
| 85 |
選択されていなければ偽 |
| 86 |
ondition:には以下のコードを使ってください。 |
| 87 |
|
| 88 |
IsReTweetedAll = Condition.new{ |opt| |
| 89 |
current_world, = Plugin.filtering(:world_current, nil) |
| 90 |
!opt.messages.empty? && opt.messages.lazy.all?{|m| |
| 91 |
Plugin[:command].destroy_share?(current_world, m) |
| 92 |
} |
| 93 |
} |
| 94 |
deprecate_constant :IsReTweetedAll |
| 95 |
|
| 96 |
、一つでも現在のアカウントでふぁぼれるものがあれば真を返す |
| 97 |
ondition:には以下のコードを使ってください。 |
| 98 |
|
| 99 |
CanFavoriteAny = Condition.new { |opt| |
| 100 |
current_world, = Plugin.filtering(:world_current, nil) |
| 101 |
opt.messages.any?{|m| |
| 102 |
Plugin[:command].favorite?(current_world, m) && !Plugin[:command].favorited?(current_world, m) |
| 103 |
} |
| 104 |
} |
| 105 |
deprecate_constant :CanFavoriteAny |
| 106 |
|
| 107 |
、現在のアカウントでお気に入りに追加可能な時、真を返す。 |
| 108 |
済みのものはお気に入りに追加不可とみなす。 |
| 109 |
選択されていなければ偽 |
| 110 |
CanFavoriteAll = Condition.new{ |opt| |
| 111 |
current_world, = Plugin.filtering(:world_current, nil) |
| 112 |
!opt.messages.empty? and opt.messages.all?{|m| |
| 113 |
Plugin[:command].favorite?(current_world, m) |
| 114 |
} |
| 115 |
} |
| 116 |
deprecate_constant :CanFavoriteAll |
| 117 |
|
| 118 |
現在のアカウントで全てお気に入りに追加している場合。 |
| 119 |
選択されていなければ偽 |
| 120 |
ondition:には以下のコードを使ってください。 |
| 121 |
|
| 122 |
IsFavoritedAll = Condition.new{ |opt| |
| 123 |
current_world, = Plugin.filtering(:world_current, nil) |
| 124 |
!opt.messages.empty? and opt.messages.all?{|m| |
| 125 |
Plugin[:command].unfavorite?(current_world, m) |
| 126 |
} |
| 127 |
} |
| 128 |
deprecate_constant :IsFavoritedAll |
| 129 |
|
| 130 |
のが全て自分のツイートの時 |
| 131 |
ondition:には以下のコードを使ってください。 |
| 132 |
|
| 133 |
IsMyMessageAll = Condition.new{ |opt| |
| 134 |
current_world, = Plugin.filtering(:world_current, nil) |
| 135 |
not opt.messages.empty? and opt.messages.all?{|m| m.from_me?(current_world) } |
| 136 |
} |
| 137 |
deprecate_constant :IsMyMessageAll |
| 138 |
|
| 139 |
が一文字でも選択されている |
| 140 |
ondition:には以下のコードを使ってください。 |
| 141 |
|
| 142 |
TimelineTextSelected = Condition.new{ |opt| opt.widget.selected_text(opt.messages.first) } |
| 143 |
deprecate_constant :TimelineTextSelected |
| 144 |
|
| 145 |
HasParmaLinkAll = Condition.new{ |opt| |
| 146 |
not opt.messages.empty? and opt.messages.all? { |m| m.perma_link } } |
| 147 |
deprecate_constant :HasParmaLinkAll |
| 148 |
|
| 149 |
ール |
| 150 |
|
| 151 |
入力中:グレーアウトしてない時) |
| 152 |
ondition:には以下のコードを使ってください。 |
| 153 |
|
| 154 |
Editable = Condition.new{ |opt| opt.widget.editable? } |
| 155 |
deprecate_constant :Editable |
| 156 |
|
| 157 |
deprecate_constant :Condition |
| 158 |
end |
| 159 |
|
| 160 |
|
| 161 |
|