1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 08:13:47 +00:00

Merge pull request #532 from InsanusMokrassar/0.38.5

0.38.5
This commit is contained in:
InsanusMokrassar 2022-02-08 16:53:27 +06:00 committed by GitHub
commit 2d2c745527
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 4 deletions

View File

@ -1,5 +1,18 @@
# TelegramBotAPI changelog # TelegramBotAPI changelog
## 0.38.5
* `Common`:
* `Version`:
* `MicroUtils`: `0.9.5` -> `0.9.6`
* `Core`:
* `Username` got new property `usernameWithoutAt` which will return `username` without leading `@`
* `Utils`:
* Several new functions for working with deep links:
* `makeUsernameDeepLinkPrefix`
* `makeTelegramDeepLink`
* `makeDeepLink`
## 0.38.4 ## 0.38.4
__This update contains including of [Telegram Bot API 5.7](https://core.telegram.org/bots/api-changelog#january-31-2022)__ __This update contains including of [Telegram Bot API 5.7](https://core.telegram.org/bots/api-changelog#january-31-2022)__

View File

@ -12,7 +12,7 @@ klock_version=2.4.13
uuid_version=0.4.0 uuid_version=0.4.0
ktor_version=1.6.7 ktor_version=1.6.7
micro_utils_version=0.9.5 micro_utils_version=0.9.6
javax_activation_version=1.1.1 javax_activation_version=1.1.1
@ -20,6 +20,6 @@ javax_activation_version=1.1.1
dokka_version=1.6.10 dokka_version=1.6.10
library_group=dev.inmo library_group=dev.inmo
library_version=0.38.4 library_version=0.38.5
github_release_plugin_version=2.2.12 github_release_plugin_version=2.2.12

View File

@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip

View File

@ -46,6 +46,9 @@ fun Byte.toChatId(): ChatId = toLong().toChatId()
data class Username( data class Username(
val username: String val username: String
) : ChatIdentifier() { ) : ChatIdentifier() {
val usernameWithoutAt
get() = username.dropWhile { it == '@' }
init { init {
if (!username.startsWith("@")) { if (!username.startsWith("@")) {
throw IllegalArgumentException("Username must starts with `@`") throw IllegalArgumentException("Username must starts with `@`")

View File

@ -9,9 +9,15 @@ import dev.inmo.tgbotapi.types.message.abstracts.Message
private const val internalLinkBeginning = "https://t.me" private const val internalLinkBeginning = "https://t.me"
fun makeUsernameLink(username: String) = "$internalLinkBeginning/$username" fun makeUsernameLink(username: String) = "$internalLinkBeginning/$username"
fun makeUsernameDeepLinkPrefix(username: String) = "${makeUsernameLink(username)}?start="
inline val Username.link inline val Username.link
get() = makeUsernameLink(username) get() = makeUsernameLink(usernameWithoutAt)
inline val Username.deepLinkPrefix
get() = makeUsernameDeepLinkPrefix(usernameWithoutAt)
inline fun makeLink(username: Username) = username.link inline fun makeLink(username: Username) = username.link
inline fun makeTelegramDeepLink(username: String, startParameter: String) = "${makeUsernameDeepLinkPrefix(username)}$startParameter"
inline fun makeDeepLink(username: Username, startParameter: String) = "${username.deepLinkPrefix}$startParameter"
inline fun makeTelegramDeepLink(username: Username, startParameter: String) = makeDeepLink(username, startParameter)
fun makeLinkToMessage( fun makeLinkToMessage(
username: String, username: String,