blob: d797d0a5f79701714bbdfc84e3a6a0ab763b43b6 (
plain)
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
31
32
33
34
35
36
37
|
#!/usr/bin/env ruby
# RAILS_ENVを設定
ENV['RAILS_ENV'] = 'production'
# あなたのMastodonインストール先パス
require_relative '/your/mastodon/config/environment'
require 'uri'
# メッセージ内に@マークが5個以上あるかをチェックするメソッド
def spam_detected?(message)
message.scan(/@/).size >= 5
end
def block_spam_messages
spam_accounts = []
# 全ての投稿を取得
Status.all.each do |status|
# あなたのMastodonドメイン
your_domain = 'eyes4you.org'
if spam_detected?(status.content)
status.destroy
if status.account.url
domain = URI.parse(status.account.url).host
spam_accounts << "#{status.account.username} (#{domain})"
else
spam_accounts << "#{status.account.username} (#{your_domain})"
end
end
end
# スパムと判定されたアカウントをファイルに出力
File.open('spam.txt', 'a') { |file| file.puts(spam_accounts) } unless spam_accounts.empty?
end
block_spam_messages
|