X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Ftext%2FSoneMentionDetector.kt;fp=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Ftext%2FSoneMentionDetector.kt;h=32d311da0479b605de6dee1fa123c8e983f094d3;hp=7dd82854b7dcfa597ceaf61f68e03adfc62953a2;hb=acdc9746bb0c853bfd36f1c982c95017158166c2;hpb=ae15a32bcf71f56e4f5e7aff5e13a04ea1c88ad3 diff --git a/src/main/kotlin/net/pterodactylus/sone/text/SoneMentionDetector.kt b/src/main/kotlin/net/pterodactylus/sone/text/SoneMentionDetector.kt index 7dd8285..32d311d 100644 --- a/src/main/kotlin/net/pterodactylus/sone/text/SoneMentionDetector.kt +++ b/src/main/kotlin/net/pterodactylus/sone/text/SoneMentionDetector.kt @@ -41,4 +41,15 @@ class SoneMentionDetector @Inject constructor(private val eventBus: EventBus, pr } } + @Subscribe + fun onNewPostReply(event: NewPostReplyFoundEvent) { + event.postReply.let { postReply -> + postReply.sone.isLocal.onFalse { + if (soneTextParser.parse(postReply.text, null).filterIsInstance().any { it.sone.isLocal }) { + postReply.post.let(::LocalSoneMentionedInPostEvent).also(eventBus::post) + } + } + } + } + }