Skip to content

Commit

Permalink
Merge pull request #934 from InsanusMokrassar/23.0.0
Browse files Browse the repository at this point in the history
23.0.0
  • Loading branch information
InsanusMokrassar authored Dec 25, 2024
2 parents b90f8ec + 9a0793d commit 2d08c44
Show file tree
Hide file tree
Showing 31 changed files with 329 additions and 324 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# TelegramBotAPI changelog

## 23.0.0

* `Version`:
* `Coroutines`: `1.9.0` -> `1.10.1`
* `MicroUtils`: `0.23.2` -> `0.24.0`
* `KSLog`: `1.3.6` -> `1.4.0`
* `Ktor`: `3.0.2` -> `3.0.3`
* `Core`:
* All old factory methods for `TextSource`s took suffix `TextSource`. For example: `regular` -> `regularTextSource`.
That has been for excluding names resolution ambiguity with extensions for `EntitiesBuilder`

## 22.0.0

**THIS UPDATE CONTAINS BREAKING CHANGES**
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ kotlin.incremental=true
kotlin.incremental.js=true

library_group=dev.inmo
library_version=22.0.0
library_version=23.0.0
10 changes: 5 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@

kotlin = "2.1.0"
kotlin-serialization = "1.7.3"
kotlin-coroutines = "1.9.0"
kotlin-coroutines = "1.10.1"

javax-activation = "1.1.1"

korlibs = "5.4.0"
uuid = "0.8.4"
ktor = "3.0.2"
ktor = "3.0.3"

ksp = "2.1.0-1.0.29"
kotlin-poet = "1.18.1"

microutils = "0.23.2"
kslog = "1.3.6"
microutils = "0.24.0"
kslog = "1.4.0"

versions = "0.51.0"

github-release-plugin = "2.5.2"
dokka = "1.9.20"
dokka = "2.0.0"

validator = "0.16.3"

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
170 changes: 85 additions & 85 deletions tgbotapi.core/api/tgbotapi.core.api

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,14 @@ import dev.inmo.tgbotapi.bot.exceptions.newRequestException
import dev.inmo.tgbotapi.requests.GetUpdatesRequest
import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.types.Response
import dev.inmo.tgbotapi.types.message.textsources.pre
import dev.inmo.tgbotapi.utils.DefaultKTgBotAPIKSLog
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
import io.ktor.client.HttpClient
import io.ktor.client.plugins.timeout
import io.ktor.client.request.*
import io.ktor.client.request.forms.*
import io.ktor.client.statement.bodyAsText
import io.ktor.http.ContentType
import io.ktor.http.content.*
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.Json
import kotlin.collections.set

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package dev.inmo.tgbotapi.types.message

import dev.inmo.micro_utils.common.Warning
import dev.inmo.micro_utils.serialization.mapper.MapperSerializer
import dev.inmo.tgbotapi.types.CustomEmojiId
import dev.inmo.tgbotapi.types.chat.User
import dev.inmo.tgbotapi.types.message.textsources.*
import kotlinx.serialization.KSerializer
import kotlinx.serialization.Serializable
import kotlinx.serialization.builtins.ListSerializer

@Serializable
@Warning("This thing is subject of changes. Library do not guarantee stability of this class")
Expand Down Expand Up @@ -102,15 +99,15 @@ internal fun List<Pair<Int, TextSource>>.fillWithRegulars(source: String): TextS
for (i in indices) {
val (offset, textSource) = get(i)
if (offset - index > 0) {
result.add(regular(source.substring(index, offset)))
result.add(regularTextSource(source.substring(index, offset)))
index = offset
}
result.add(textSource)
index += textSource.source.length
}

if (index != source.length) {
result.add(regular(source.substring(index, source.length)))
result.add(regularTextSource(source.substring(index, source.length)))
}

return result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.utils.internal.*
import kotlinx.serialization.Serializable

/**
* @see blockquote
* @see blockquoteTextSource
*/
@Serializable
data class BlockquoteTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
Expand All @@ -18,6 +18,6 @@ data class BlockquoteTextSource @RiskFeature(DirectInvocationOfTextSourceConstru
override val html: String by lazy { blockquoteHTML() }
}

inline fun blockquote(parts: TextSourcesList) = BlockquoteTextSource(parts.makeString(), parts)
inline fun blockquote(vararg parts: TextSource) = blockquote(parts.toList())
inline fun blockquote(text: String) = blockquote(regular(text))
inline fun blockquoteTextSource(parts: TextSourcesList) = BlockquoteTextSource(parts.makeString(), parts)
inline fun blockquoteTextSource(vararg parts: TextSource) = blockquoteTextSource(parts.toList())
inline fun blockquoteTextSource(text: String) = blockquoteTextSource(regularTextSource(text))
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.utils.internal.*
import kotlinx.serialization.Serializable

/**
* @see bold
* @see boldTextSource
*/
@Serializable
data class BoldTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
Expand All @@ -18,6 +18,6 @@ data class BoldTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor)
override val html: String by lazy { boldHTML() }
}

inline fun bold(parts: TextSourcesList) = BoldTextSource(parts.makeString(), parts)
inline fun bold(vararg parts: TextSource) = bold(parts.toList())
inline fun bold(text: String) = bold(regular(text))
inline fun boldTextSource(parts: TextSourcesList) = BoldTextSource(parts.makeString(), parts)
inline fun boldTextSource(vararg parts: TextSource) = boldTextSource(parts.toList())
inline fun boldTextSource(text: String) = boldTextSource(regularTextSource(text))
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import dev.inmo.tgbotapi.utils.internal.*
import kotlinx.serialization.Serializable

/**
* @see botCommand
* @see botCommandTextSource
*/
@Serializable
data class BotCommandTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
Expand All @@ -33,6 +33,6 @@ data class BotCommandTextSource @RiskFeature(DirectInvocationOfTextSourceConstru
/**
* @param command Without leading "/"
*/
inline fun botCommand(command: String) = BotCommandTextSource("/$command")
inline fun botCommandTextSource(command: String) = BotCommandTextSource("/$command")

inline fun botCommand(botCommand: BotCommand) = botCommand(botCommand.command)
inline fun botCommandTextSource(botCommand: BotCommand) = botCommandTextSource(botCommand.command)
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import dev.inmo.tgbotapi.utils.internal.*
import kotlinx.serialization.Serializable

/**
* @see cashTag
* @see cashTagTextSource
*/
@Serializable
data class CashTagTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
Expand All @@ -25,6 +25,6 @@ data class CashTagTextSource @RiskFeature(DirectInvocationOfTextSourceConstructo
override val html: String by lazy { cashTagHTML() }
}

inline fun cashTag(parts: TextSourcesList) = CashTagTextSource(parts.makeString(), parts)
inline fun cashTag(vararg parts: TextSource) = cashTag(parts.toList())
inline fun cashTag(tag: String) = cashTag(regular(tag))
inline fun cashTagTextSource(parts: TextSourcesList) = CashTagTextSource(parts.makeString(), parts)
inline fun cashTagTextSource(vararg parts: TextSource) = cashTagTextSource(parts.toList())
inline fun cashTagTextSource(tag: String) = cashTagTextSource(regularTextSource(tag))
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.utils.internal.*
import kotlinx.serialization.Serializable

/**
* @see code
* @see codeTextSource
*/
@Serializable
data class CodeTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
Expand All @@ -16,4 +16,4 @@ data class CodeTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor)
override val html: String by lazy { source.codeHTML() }
}

inline fun code(code: String) = CodeTextSource(code)
inline fun codeTextSource(code: String) = CodeTextSource(code)
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import dev.inmo.tgbotapi.utils.internal.*
import kotlinx.serialization.Serializable

/**
* @see customEmoji
* @see customEmojiTextSource
*/
@Serializable
data class CustomEmojiTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
Expand All @@ -21,9 +21,9 @@ data class CustomEmojiTextSource @RiskFeature(DirectInvocationOfTextSourceConstr
}

@Suppress("EXPERIMENTAL_API_USAGE")
inline fun customEmoji(emojiId: CustomEmojiId, parts: TextSourcesList) = CustomEmojiTextSource(parts.makeString(), emojiId, parts)
inline fun customEmoji(emojiId: CustomEmojiId, vararg parts: TextSource) = customEmoji(emojiId, parts.toList())
inline fun customEmojiTextSource(emojiId: CustomEmojiId, parts: TextSourcesList) = CustomEmojiTextSource(parts.makeString(), emojiId, parts)
inline fun customEmojiTextSource(emojiId: CustomEmojiId, vararg parts: TextSource) = customEmojiTextSource(emojiId, parts.toList())
/**
* Without sharp (#)
*/
inline fun customEmoji(emojiId: CustomEmojiId, text: String) = customEmoji(emojiId, regular(text))
inline fun customEmojiTextSource(emojiId: CustomEmojiId, text: String) = customEmojiTextSource(emojiId, regularTextSource(text))
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.utils.internal.*
import kotlinx.serialization.Serializable

/**
* @see email
* @see emailTextSource
*/
@Serializable
data class EMailTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
Expand All @@ -18,6 +18,6 @@ data class EMailTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor)
override val html: String by lazy { emailHTML(source) }
}

inline fun email(parts: TextSourcesList) = EMailTextSource(parts.makeString(), parts)
inline fun email(vararg parts: TextSource) = email(parts.toList())
inline fun email(emailAddress: String) = email(regular(emailAddress))
inline fun emailTextSource(parts: TextSourcesList) = EMailTextSource(parts.makeString(), parts)
inline fun emailTextSource(vararg parts: TextSource) = emailTextSource(parts.toList())
inline fun emailTextSource(emailAddress: String) = emailTextSource(regularTextSource(emailAddress))
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.utils.internal.*
import kotlinx.serialization.Serializable

/**
* @see expandableBlockquote
* @see expandableBlockquoteTextSource
*/
@Serializable
data class ExpandableBlockquoteTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
Expand All @@ -18,6 +18,6 @@ data class ExpandableBlockquoteTextSource @RiskFeature(DirectInvocationOfTextSou
override val html: String by lazy { expandableBlockquoteHTML() }
}

inline fun expandableBlockquote(parts: TextSourcesList) = ExpandableBlockquoteTextSource(parts.makeString(), parts)
inline fun expandableBlockquote(vararg parts: TextSource) = expandableBlockquote(parts.toList())
inline fun expandableBlockquote(text: String) = expandableBlockquote(regular(text))
inline fun expandableBlockquoteTextSource(parts: TextSourcesList) = ExpandableBlockquoteTextSource(parts.makeString(), parts)
inline fun expandableBlockquoteTextSource(vararg parts: TextSource) = expandableBlockquoteTextSource(parts.toList())
inline fun expandableBlockquoteTextSource(text: String) = expandableBlockquoteTextSource(regularTextSource(text))
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import dev.inmo.tgbotapi.utils.internal.*
import kotlinx.serialization.Serializable

/**
* @see hashtag
* @see hashtagTextSource
*/
@Serializable
data class HashTagTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
Expand All @@ -33,9 +33,9 @@ data class HashTagTextSource @RiskFeature(DirectInvocationOfTextSourceConstructo
}

@Suppress("EXPERIMENTAL_API_USAGE")
inline fun hashtag(parts: TextSourcesList) = (regular("#") + parts).let { HashTagTextSource(it.makeString(), it) }
inline fun hashtag(vararg parts: TextSource) = hashtag(parts.toList())
inline fun hashtagTextSource(parts: TextSourcesList) = (regularTextSource("#") + parts).let { HashTagTextSource(it.makeString(), it) }
inline fun hashtagTextSource(vararg parts: TextSource) = hashtagTextSource(parts.toList())
/**
* Without sharp (#)
*/
inline fun hashtag(hashtag: String) = hashtag(regular(hashtag))
inline fun hashtagTextSource(hashtag: String) = hashtagTextSource(regularTextSource(hashtag))
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.utils.internal.*
import kotlinx.serialization.Serializable

/**
* @see italic
* @see italicTextSource
*/
@Serializable
data class ItalicTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
Expand All @@ -18,7 +18,7 @@ data class ItalicTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor
override val html: String by lazy { italicHTML() }
}

inline fun italic(parts: TextSourcesList) = ItalicTextSource(parts.makeString(), parts)
inline fun italic(vararg parts: TextSource) = italic(parts.toList())
inline fun italic(text: String) = italic(regular(text))
inline fun italicTextSource(parts: TextSourcesList) = ItalicTextSource(parts.makeString(), parts)
inline fun italicTextSource(vararg parts: TextSource) = italicTextSource(parts.toList())
inline fun italicTextSource(text: String) = italicTextSource(regularTextSource(text))

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ private val String.withoutCommercialAt
}

/**
* @see mention
* @see mentionTextSource
*/
@Serializable
data class MentionTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
Expand All @@ -33,13 +33,13 @@ data class MentionTextSource @RiskFeature(DirectInvocationOfTextSourceConstructo
}
}

inline fun mention(parts: TextSourcesList) = (regular("@") + parts).let { MentionTextSource(it.makeString(), it) }
inline fun mention(vararg parts: TextSource) = mention(parts.toList())
inline fun mentionTextSource(parts: TextSourcesList) = (regularTextSource("@") + parts).let { MentionTextSource(it.makeString(), it) }
inline fun mentionTextSource(vararg parts: TextSource) = mentionTextSource(parts.toList())

/**
* Without leading "@"
*/
inline fun mention(whoToMention: String) = mention(regular(whoToMention))
inline fun mentionTextSource(whoToMention: String) = mentionTextSource(regularTextSource(whoToMention))

inline fun mention(whoToMention: Username) = mention(whoToMention.full.dropWhile { it == '@' })
inline fun mentionTextSource(whoToMention: Username) = mentionTextSource(whoToMention.full.dropWhile { it == '@' })

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.utils.internal.*
import kotlinx.serialization.Serializable

/**
* @see phone
* @see phoneTextSource
*/
@Serializable
data class PhoneNumberTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
Expand All @@ -18,7 +18,7 @@ data class PhoneNumberTextSource @RiskFeature(DirectInvocationOfTextSourceConstr
override val html: String by lazy { phoneHTML() }
}

inline fun phone(parts: TextSourcesList) = PhoneNumberTextSource(parts.makeString(), parts)
inline fun phone(vararg parts: TextSource) = phone(parts.toList())
inline fun phone(number: String) = phone(regular(number))
inline fun phoneTextSource(parts: TextSourcesList) = PhoneNumberTextSource(parts.makeString(), parts)
inline fun phoneTextSource(vararg parts: TextSource) = phoneTextSource(parts.toList())
inline fun phoneTextSource(number: String) = phoneTextSource(regularTextSource(number))

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.utils.internal.*
import kotlinx.serialization.Serializable

/**
* @see pre
* @see preTextSource
*/
@Serializable
data class PreTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
Expand All @@ -17,5 +17,5 @@ data class PreTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) c
override val html: String by lazy { source.preHTML(language) }
}

inline fun pre(code: String, language: String? = null) = PreTextSource(code, language)
inline fun preTextSource(code: String, language: String? = null) = PreTextSource(code, language)

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.utils.internal.*
import kotlinx.serialization.Serializable

/**
* @see regular
* @see regularTextSource
*/
@Serializable
data class RegularTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
Expand All @@ -16,6 +16,6 @@ data class RegularTextSource @RiskFeature(DirectInvocationOfTextSourceConstructo
override val html: String by lazy { source.regularHtml() }
}

inline fun regular(text: String) = RegularTextSource(text)
inline fun regularTextSource(text: String) = RegularTextSource(text)

inline fun regularln(text: String) = regular("$text\n")
inline fun regularTextSourceLn(text: String) = regularTextSource("$text\n")
Loading

0 comments on commit 2d08c44

Please sign in to comment.