Blurry Moon on Nostr: Anyway here's the MRF for eliminating ReplyGuy spam so you don't have to resort to ...
Anyway here's the MRF for eliminating ReplyGuy spam so you don't have to resort to tricks:
```
# Copyright © 2024 Moon Man
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.MRF.ReplyGuySpam do
alias Pleroma.User
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
require Logger
@impl true
def history_awareness, do: :auto
@impl true
def filter(
%{
"type" => "Create",
"actor" => actor_id,
"object" => %{
"type" => "Note"
}
} = activity
) do
with %User{:name => name, :nickname => "npub" <> _} <-
User.get_cached_by_ap_id(actor_id),
true <- String.contains?(String.downcase(name), "replyguy") do
Logger.info("Dropping Nostr replyguy spam")
{:reject, activity}
else
_ ->
# pass through
{:ok, activity}
end
end
@impl true
def filter(activity = %{}), do: {:ok, activity}
@impl true
def describe, do: {:ok, %{}}
end
```
Published at
2024-09-06 15:54:28 UTCEvent JSON
{
"id": "97ec9d309de0fb50c696258a21972952736e32e58f8fcb8d609473c80a0062a8",
"pubkey": "bc99ecc661ecc2be90c8cbec0f3532b2742a455411782936822256a74b1bb7a2",
"created_at": 1725638068,
"kind": 1,
"tags": [
[
"proxy",
"https://shitposter.world/objects/2c922809-0829-4181-a969-1e82cf9cd5e8",
"activitypub"
],
[
"L",
"pink.momostr"
],
[
"l",
"pink.momostr.activitypub:https://shitposter.world/objects/2c922809-0829-4181-a969-1e82cf9cd5e8",
"pink.momostr"
],
[
"-"
]
],
"content": "Anyway here's the MRF for eliminating ReplyGuy spam so you don't have to resort to tricks:\r\n\r\n```\r\n# Copyright © 2024 Moon Man\r\n# SPDX-License-Identifier: AGPL-3.0-only\r\n\r\ndefmodule Pleroma.Web.ActivityPub.MRF.ReplyGuySpam do\r\n alias Pleroma.User\r\n\r\n @behaviour Pleroma.Web.ActivityPub.MRF.Policy\r\n\r\n require Logger\r\n\r\n @impl true\r\n def history_awareness, do: :auto\r\n\r\n @impl true\r\n def filter(\r\n %{\r\n \"type\" =\u003e \"Create\",\r\n \"actor\" =\u003e actor_id,\r\n \"object\" =\u003e %{\r\n \"type\" =\u003e \"Note\"\r\n }\r\n } = activity\r\n ) do\r\n with %User{:name =\u003e name, :nickname =\u003e \"npub\" \u003c\u003e _} \u003c-\r\n User.get_cached_by_ap_id(actor_id),\r\n true \u003c- String.contains?(String.downcase(name), \"replyguy\") do\r\n Logger.info(\"Dropping Nostr replyguy spam\")\r\n {:reject, activity}\r\n else\r\n _ -\u003e\r\n # pass through\r\n {:ok, activity}\r\n end\r\n end\r\n\r\n @impl true\r\n def filter(activity = %{}), do: {:ok, activity}\r\n\r\n @impl true\r\n def describe, do: {:ok, %{}}\r\nend\r\n```",
"sig": "0789800e3d98992d492f53d4d304cc02705c5aa4df7e1e81d1afd65baa756ebfad3426e925a658a1522a2d144dea7385933cb3b59a2fb90278da650b67ef9873"
}