diff --git a/.mikutter.yml b/.mikutter.yml index 1b20990..f1a6b17 100644 --- a/.mikutter.yml +++ b/.mikutter.yml @@ -1,9 +1,9 @@ --- slug: :anti_matsushita depends: - mikutter: 3.10.0-develop + mikutter: '4.1.0' plugin: [] -version: '1.0' +version: '2.0' author: toshi_a name: Anti Matsushita description: >- diff --git a/anti_matsushita.rb b/anti_matsushita.rb index 5df1a17..98256bf 100644 --- a/anti_matsushita.rb +++ b/anti_matsushita.rb @@ -2,36 +2,19 @@ Plugin.create(:anti_matsushita) do aho = %w[アホ ボケ カス バカ] - convicted = Set.new - judge_queue = Queue.new start = Time.new - # 大量に勧められて百烈拳にならないように、一度反応したら1分キューを止める - Thread.new do - loop do - - Enumerator.new{|y| - y << judge_queue.pop - }.lazy.select { |toot| - toot.description.include?('まちカドまぞくを見ろ') && toot.created >= start - }.reject{|toot| - convicted.include?(toot.uri.to_s) - }.map { |toot| - [toot, - Enumerator.new{|y| Plugin.filtering(:worlds, y) }.select { |w| - mastodon?(w) - }.find { |w| toot.receive_user_idnames.include?(w.account.idname) }] - }.select { |_, w| - w - }.each do |toot, world| - convicted << toot.uri.to_s.freeze - compose(toot, world, body: "@#{toot.user.idname} いやじゃ#{aho.sample}") - sleep 60 - end - end - end.abort_on_exception - - on_mastodon_appear_toots do |toots| - toots.each(&judge_queue.method(:push)) + subscribe(:extract_receive_message, :mastodon_appear_toots).select { |toot| + toot.description.include?('まちカドまぞくを見ろ') && toot.created >= start + }.uniq.map { |toot| + [toot, + collect(:worlds) + .select(&method(:mastodon?)) + .find { |w| toot.receive_user_idnames.include?(w.account.idname) } + ] + }.select { |_, w| + w + }.debounce(60).each do |toot, world| + compose(toot, world, body: "@#{toot.user.idname} いやじゃ#{aho.sample}") end end