-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ceecc60
commit bb78884
Showing
33 changed files
with
258 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
src/main/java/ru/spliterash/vkVideoUnlocker/common/exceptions/AlwaysNotifyException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package ru.spliterash.vkVideoUnlocker.common.exceptions | ||
|
||
interface AlwaysNotifyException |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/main/java/ru/spliterash/vkVideoUnlocker/message/api/Messages.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/ru/spliterash/vkVideoUnlocker/message/utils/MessageContentScanner.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package ru.spliterash.vkVideoUnlocker.message.utils | ||
|
||
import jakarta.inject.Singleton | ||
import ru.spliterash.vkVideoUnlocker.longpoll.message.ReplyMessage | ||
import ru.spliterash.vkVideoUnlocker.longpoll.message.RootMessage | ||
import ru.spliterash.vkVideoUnlocker.longpoll.message.attachments.AttachmentContainer | ||
import ru.spliterash.vkVideoUnlocker.longpoll.message.hasPing | ||
import ru.spliterash.vkVideoUnlocker.longpoll.message.isPersonalChat | ||
import ru.spliterash.vkVideoUnlocker.vk.MessageScanner | ||
import ru.spliterash.vkVideoUnlocker.vk.actor.GroupUser | ||
import ru.spliterash.vkVideoUnlocker.vk.api.VkApi | ||
import java.util.* | ||
import java.util.function.Predicate | ||
|
||
@Singleton | ||
class MessageContentScanner( | ||
@GroupUser private val groupUser: VkApi, | ||
private val messageScanner: MessageScanner, | ||
) { | ||
fun findContent(root: RootMessage): MessageScanner.ScanResult? { | ||
val containerPredicate: Predicate<AttachmentContainer> = | ||
if (root.isPersonalChat() || root.hasPing(groupUser)) | ||
Predicate { true } | ||
else | ||
Predicate { it !is ReplyMessage } | ||
|
||
val init = LinkedList<AttachmentContainer>() | ||
init += root | ||
return messageScanner.scanForAttachment( | ||
init, | ||
listOf( | ||
MessageScanner.Checker { it.video }, | ||
MessageScanner.Checker { it.story }, | ||
), | ||
containerPredicate | ||
) | ||
} | ||
} |
33 changes: 6 additions & 27 deletions
33
src/main/java/ru/spliterash/vkVideoUnlocker/message/utils/MessageUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/main/java/ru/spliterash/vkVideoUnlocker/video/exceptions/ContentNotFoundException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package ru.spliterash.vkVideoUnlocker.video.exceptions | ||
|
||
import ru.spliterash.vkVideoUnlocker.common.exceptions.AlwaysNotifyException | ||
import ru.spliterash.vkVideoUnlocker.common.exceptions.VkUnlockerException | ||
|
||
class ContentNotFoundException : VkUnlockerException(),AlwaysNotifyException { | ||
override fun messageForUser(): String { | ||
return "Я не знаю каким образом, но при получении сообщения от пользователя, содержимое отличается" | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/ru/spliterash/vkVideoUnlocker/video/exceptions/NoSenseReuploadUserVideos.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package ru.spliterash.vkVideoUnlocker.video.exceptions | ||
|
||
import ru.spliterash.vkVideoUnlocker.common.exceptions.VkUnlockerException | ||
|
||
class NoSenseReuploadUserVideos : VkUnlockerException() { | ||
override fun messageForUser(): String { | ||
return "Мне нет смысла перезаливать пользовательские видео" | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/ru/spliterash/vkVideoUnlocker/video/exceptions/NoSourceException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package ru.spliterash.vkVideoUnlocker.video.exceptions | ||
|
||
import ru.spliterash.vkVideoUnlocker.common.exceptions.AlwaysNotifyException | ||
import ru.spliterash.vkVideoUnlocker.common.exceptions.VkUnlockerException | ||
|
||
class NoSourceException : VkUnlockerException(), AlwaysNotifyException { | ||
override fun messageForUser() = | ||
"Перешли видео в личные сообщения сообщества. Из за ограничений API я не могу сделать это в беседе" | ||
} |
Oops, something went wrong.