gallery is visualised

This commit is contained in:
Believethehype
2024-06-28 21:13:52 +02:00
parent a42762de53
commit f331398316
7 changed files with 73 additions and 55 deletions

View File

@@ -72,3 +72,21 @@ data class EmojiUrl(val code: String, val url: String) {
}
}
}
@Immutable
data class GalleryUrl(val id: String, val url: String) {
fun encode(): String {
return ":$id:$url"
}
companion object {
fun decode(encodedGallerySetup: String): EmojiUrl? {
val emojiParts = encodedGallerySetup.split(":", limit = 3)
return if (emojiParts.size > 2) {
EmojiUrl(emojiParts[1], emojiParts[2])
} else {
null
}
}
}
}

View File

@@ -119,6 +119,8 @@ open class Event(
override fun taggedEvents() = tags.filter { it.size > 1 && it[0] == "e" }.map { it[1] }
override fun taggedGalleryEntries() = tags.filter { it.size > 2 && it[0] == "g" }.map { GalleryUrl(it[1], it[2]) }
override fun taggedUrls() = tags.filter { it.size > 1 && it[0] == "r" }.map { it[1] }
override fun firstTagFor(vararg key: String) = tags.firstOrNull { it.size > 1 && it[0] in key }?.let { it[1] }

View File

@@ -145,6 +145,8 @@ interface EventInterface {
fun firstTaggedK(): Int?
fun taggedGalleryEntries(): List<GalleryUrl>
fun taggedEmojis(): List<EmojiUrl>
fun matchTag1With(text: String): Boolean