Skip to content

Commit

Permalink
mikutter 4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
toshia committed Feb 8, 2020
1 parent 3125a58 commit ea537f9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 31 deletions.
4 changes: 2 additions & 2 deletions .mikutter.yml
Original file line number Diff line number Diff line change
@@ -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: >-
Expand Down
41 changes: 12 additions & 29 deletions anti_matsushita.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit ea537f9

Please sign in to comment.