Skip to content

Commit

Permalink
Pornographics #25
Browse files Browse the repository at this point in the history
  • Loading branch information
peterarsentev committed Jun 10, 2024
1 parent d73d88d commit 51b2e29
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 123 deletions.
10 changes: 0 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,6 @@
</repositories>

<dependencies>
<dependency>
<groupId>net.sourceforge.tess4j</groupId>
<artifactId>tess4j</artifactId>
<version>4.5.4</version>
</dependency>
<dependency>
<groupId>org.tensorflow</groupId>
<artifactId>tensorflow</artifactId>
<version>1.15.0</version>
</dependency>
<dependency>
<groupId>com.vdurmont</groupId>
<artifactId>emoji-java</artifactId>
Expand Down
53 changes: 0 additions & 53 deletions src/main/kotlin/pro/dionea/service/DetectImageService.kt

This file was deleted.

38 changes: 0 additions & 38 deletions src/main/kotlin/pro/dionea/service/Receiver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ class Receiver(
val encoding: PasswordEncoder,
val contactService: ContactService,
val chatService: ChatService,
val detectImageService: DetectImageService,
val textExtractionService: TextExtractionService
) : TelegramLongPollingBot() {

private val log = LoggerFactory.getLogger(Receiver::class.java)
Expand Down Expand Up @@ -91,42 +89,6 @@ class Receiver(
}
}

private fun handleRacyImageRequest(message: Message) {
val userContact = contactService.findIfNotCreate(message.from)
for (photo in message.photo) {
val img = getBufferedImageFromTelegramPhoto(photo.fileId)
val category = detectImageService.detect(img)
val textImg = textExtractionService.extract(img)
val resultSpam = spamAnalysis.isSpam(textImg)
if (category == ImageCategory.PORN
|| category == ImageCategory.SEXY
|| resultSpam.spam) {
val spam = Spam().apply {
text = if (resultSpam.spam) { resultSpam.text } else { "Изображение содержит $category" }
time = Timestamp(System.currentTimeMillis())
contact = userContact
chat = findChat(message)
}
spamService.add(spam)
val send = SendMessage(
message.chatId.toString(),
"""
Сообщение включает оскорбительное изображение.
Оно будет удалено через 10 секунд.
""".trimIndent()
)
send.replyToMessageId = message.messageId
val infoMsg = execute(send)
GlobalScope.launch {
delay(10000)
execute(DeleteMessage(message.chatId.toString(), message.messageId))
execute(DeleteMessage(message.chatId.toString(), infoMsg.messageId))
}
break
}
}
}

private fun getBufferedImageFromTelegramPhoto(flId: String): BufferedImage {
val file = execute(
GetFile().apply {
Expand Down
22 changes: 0 additions & 22 deletions src/main/kotlin/pro/dionea/service/TextExtractionService.kt

This file was deleted.

0 comments on commit 51b2e29

Please sign in to comment.