1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-24 19:18:44 +00:00

Compare commits

..

1 Commits

Author SHA1 Message Date
renovate[bot]
c49fa30521
Merge 00cb04f409 into 4a0c0bdc40 2024-11-05 09:17:55 +00:00
13 changed files with 17 additions and 139 deletions

View File

@ -1,14 +1,5 @@
# TelegramBotAPI changelog # TelegramBotAPI changelog
## 20.0.1
* `Core`:
* Fix of logger propagation (fix of [#860](https://github.com/InsanusMokrassar/ktgbotapi/issues/860))
* Add opportunity to modify keyboards (fix of [#761](https://github.com/InsanusMokrassar/ktgbotapi/issues/761))
* Fields of `OrderInfo` became nullable (fix of [#917](https://github.com/InsanusMokrassar/ktgbotapi/issues/917))
* Add default `toString` to `ChatType` (fix of [#919](https://github.com/InsanusMokrassar/ktgbotapi/issues/919))
* Fix of method in `CreateInvoiceLink` (merging of [#920](https://github.com/InsanusMokrassar/ktgbotapi/issues/920), made by [byteduck-exploit](https://github.com/byteduck-exploit))
## 20.0.0 ## 20.0.0
**THIS UPDATE CONTAINS SUPPORT OF [BOTS API 7.11](https://core.telegram.org/bots/api-changelog#october-31-2024)** **THIS UPDATE CONTAINS SUPPORT OF [BOTS API 7.11](https://core.telegram.org/bots/api-changelog#october-31-2024)**

View File

@ -6,4 +6,4 @@ kotlin.incremental=true
kotlin.incremental.js=true kotlin.incremental.js=true
library_group=dev.inmo library_group=dev.inmo
library_version=20.0.1 library_version=20.0.0

View File

@ -13558,8 +13558,6 @@ public final class dev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup : dev/in
public fun equals (Ljava/lang/Object;)Z public fun equals (Ljava/lang/Object;)Z
public final fun getKeyboard ()Ljava/util/List; public final fun getKeyboard ()Ljava/util/List;
public fun hashCode ()I public fun hashCode ()I
public final fun minus (Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup;)Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup;
public final fun plus (Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup;)Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup;
public fun toString ()Ljava/lang/String; public fun toString ()Ljava/lang/String;
} }
@ -13874,8 +13872,6 @@ public final class dev/inmo/tgbotapi/types/buttons/ReplyKeyboardMarkup : dev/inm
public static final field Companion Ldev/inmo/tgbotapi/types/buttons/ReplyKeyboardMarkup$Companion; public static final field Companion Ldev/inmo/tgbotapi/types/buttons/ReplyKeyboardMarkup$Companion;
public fun <init> (Ljava/util/List;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/String;Ljava/lang/Boolean;Ljava/lang/Boolean;)V public fun <init> (Ljava/util/List;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/String;Ljava/lang/Boolean;Ljava/lang/Boolean;)V
public synthetic fun <init> (Ljava/util/List;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/String;Ljava/lang/Boolean;Ljava/lang/Boolean;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public synthetic fun <init> (Ljava/util/List;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/String;Ljava/lang/Boolean;Ljava/lang/Boolean;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun add (Ldev/inmo/tgbotapi/types/buttons/ReplyKeyboardMarkup;Ljava/lang/String;)Ldev/inmo/tgbotapi/types/buttons/ReplyKeyboardMarkup;
public static synthetic fun add$default (Ldev/inmo/tgbotapi/types/buttons/ReplyKeyboardMarkup;Ldev/inmo/tgbotapi/types/buttons/ReplyKeyboardMarkup;Ljava/lang/String;ILjava/lang/Object;)Ldev/inmo/tgbotapi/types/buttons/ReplyKeyboardMarkup;
public final fun component1 ()Ljava/util/List; public final fun component1 ()Ljava/util/List;
public final fun component2 ()Ljava/lang/Boolean; public final fun component2 ()Ljava/lang/Boolean;
public final fun component3 ()Ljava/lang/Boolean; public final fun component3 ()Ljava/lang/Boolean;
@ -13892,8 +13888,6 @@ public final class dev/inmo/tgbotapi/types/buttons/ReplyKeyboardMarkup : dev/inm
public final fun getResizeKeyboard ()Ljava/lang/Boolean; public final fun getResizeKeyboard ()Ljava/lang/Boolean;
public final fun getSelective ()Ljava/lang/Boolean; public final fun getSelective ()Ljava/lang/Boolean;
public fun hashCode ()I public fun hashCode ()I
public final fun minus (Ldev/inmo/tgbotapi/types/buttons/ReplyKeyboardMarkup;)Ldev/inmo/tgbotapi/types/buttons/ReplyKeyboardMarkup;
public final fun plus (Ldev/inmo/tgbotapi/types/buttons/ReplyKeyboardMarkup;)Ldev/inmo/tgbotapi/types/buttons/ReplyKeyboardMarkup;
public fun toString ()Ljava/lang/String; public fun toString ()Ljava/lang/String;
} }
@ -14758,7 +14752,6 @@ public final class dev/inmo/tgbotapi/types/chat/ChatSerializersKt {
public abstract class dev/inmo/tgbotapi/types/chat/ChatType { public abstract class dev/inmo/tgbotapi/types/chat/ChatType {
public static final field Companion Ldev/inmo/tgbotapi/types/chat/ChatType$Companion; public static final field Companion Ldev/inmo/tgbotapi/types/chat/ChatType$Companion;
public abstract fun getStringified ()Ljava/lang/String; public abstract fun getStringified ()Ljava/lang/String;
public fun toString ()Ljava/lang/String;
} }
public final class dev/inmo/tgbotapi/types/chat/ChatType$Channel : dev/inmo/tgbotapi/types/chat/ChatType { public final class dev/inmo/tgbotapi/types/chat/ChatType$Channel : dev/inmo/tgbotapi/types/chat/ChatType {
@ -27073,10 +27066,7 @@ public class dev/inmo/tgbotapi/utils/MatrixBuilder {
public fun <init> ()V public fun <init> ()V
public final fun add (Ljava/util/List;)Z public final fun add (Ljava/util/List;)Z
public final fun getMatrix ()Ljava/util/List; public final fun getMatrix ()Ljava/util/List;
public final fun modifyRow (ILkotlin/jvm/functions/Function1;)V
public final fun modifyRow (Ljava/util/List;Lkotlin/jvm/functions/Function1;)Z
public final fun plus (Ljava/util/List;)Z public final fun plus (Ljava/util/List;)Z
public final fun remove (I)Ljava/util/List;
public final fun unaryPlus (Ljava/lang/Object;)Z public final fun unaryPlus (Ljava/lang/Object;)Z
} }
@ -27159,9 +27149,6 @@ public class dev/inmo/tgbotapi/utils/RowBuilder {
public fun <init> ()V public fun <init> ()V
public final fun add (Ljava/lang/Object;)Z public final fun add (Ljava/lang/Object;)Z
public final fun getRow ()Ljava/util/List; public final fun getRow ()Ljava/util/List;
public final fun remove (I)Ljava/lang/Object;
public final fun replace (ILjava/lang/Object;)V
public final fun replace (Ljava/lang/Object;Ljava/lang/Object;)Z
public final fun unaryPlus (Ljava/lang/Object;)Z public final fun unaryPlus (Ljava/lang/Object;)Z
} }

View File

@ -34,14 +34,14 @@ class KtorRequestsExecutorBuilder(
} }
fun build() = KtorRequestsExecutor( fun build() = KtorRequestsExecutor(
telegramAPIUrlsKeeper = telegramAPIUrlsKeeper, telegramAPIUrlsKeeper,
client = client, client,
callsFactories = callsFactories, callsFactories,
excludeDefaultFactories = excludeDefaultFactories, excludeDefaultFactories,
requestsLimiter = requestsLimiter, requestsLimiter,
jsonFormatter = jsonFormatter, jsonFormatter,
pipelineStepsHolder = pipelineStepsHolder, pipelineStepsHolder,
logger = logger logger
) )
} }

View File

@ -32,10 +32,10 @@ class DefaultKtorRequestsExecutor internal constructor(
) : BaseRequestsExecutor(telegramAPIUrlsKeeper) { ) : BaseRequestsExecutor(telegramAPIUrlsKeeper) {
private val callsFactories: List<KtorCallFactory> = callsFactories.run { private val callsFactories: List<KtorCallFactory> = callsFactories.run {
if (!excludeDefaultFactories) { if (!excludeDefaultFactories) {
this@DefaultKtorRequestsExecutor.logger.v { "Installing default factories" } logger.v { "Installing default factories" }
this + createTelegramBotDefaultKtorCallRequestsFactories(this@DefaultKtorRequestsExecutor.logger) this + createTelegramBotDefaultKtorCallRequestsFactories(logger)
} else { } else {
this@DefaultKtorRequestsExecutor.logger.v { "Default factories will not be installed" } logger.v { "Default factories will not be installed" }
this this
} }
} }

View File

@ -54,7 +54,7 @@ data class CreateInvoiceLink(
@SerialName(priceDependOnShipAddressField) @SerialName(priceDependOnShipAddressField)
override val priceDependOnShipAddress: Boolean = false override val priceDependOnShipAddress: Boolean = false
) : CommonSendInvoiceData, SimpleRequest<String> { ) : CommonSendInvoiceData, SimpleRequest<String> {
override fun method(): String = "createInvoiceLink" override fun method(): String = "sendInvoice"
override val resultDeserializer: DeserializationStrategy<String> override val resultDeserializer: DeserializationStrategy<String>
get() = String.serializer() get() = String.serializer()
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>

View File

@ -25,23 +25,4 @@ data class InlineKeyboardMarkup(
} }
} }
} }
operator fun plus(other: InlineKeyboardMarkup): InlineKeyboardMarkup {
return InlineKeyboardMarkup(
keyboard + other.keyboard
)
}
operator fun minus(other: InlineKeyboardMarkup): InlineKeyboardMarkup {
val otherButtons = other.keyboard.flatten()
return InlineKeyboardMarkup(
keyboard.mapNotNull { row ->
row.filter { button ->
button !in otherButtons
}.takeIf {
it.isNotEmpty()
}
}
)
}
} }

View File

@ -22,32 +22,4 @@ data class ReplyKeyboardMarkup(
error("Field $inputFieldPlaceholderField length must be in $inputFieldPlaceholderLimit, but was ${inputFieldPlaceholder.length}") error("Field $inputFieldPlaceholderField length must be in $inputFieldPlaceholderLimit, but was ${inputFieldPlaceholder.length}")
} }
} }
fun add(other: ReplyKeyboardMarkup, placeholderDelimiter: String = "\n"): ReplyKeyboardMarkup {
return ReplyKeyboardMarkup(
keyboard = keyboard + other.keyboard,
resizeKeyboard = resizeKeyboard ?.or(other.resizeKeyboard ?: false) ?: other.resizeKeyboard,
oneTimeKeyboard = oneTimeKeyboard ?.or(other.oneTimeKeyboard ?: false) ?: other.oneTimeKeyboard,
inputFieldPlaceholder = inputFieldPlaceholder ?.plus(other.inputFieldPlaceholder ?.let { placeholderDelimiter + it } ?: "") ?: other.inputFieldPlaceholder,
selective = selective ?.or(other.selective ?: false) ?: other.selective,
persistent = persistent ?.or(other.persistent ?: false) ?: other.persistent,
)
}
operator fun plus(other: ReplyKeyboardMarkup): ReplyKeyboardMarkup {
return add(other)
}
operator fun minus(other: ReplyKeyboardMarkup): ReplyKeyboardMarkup {
val otherButtons = other.keyboard.flatten()
return copy(
keyboard.mapNotNull { row ->
row.filter { button ->
button !in otherButtons
}.takeIf {
it.isNotEmpty()
}
}
)
}
} }

View File

@ -29,10 +29,6 @@ sealed class ChatType {
object Channel : ChatType() { override val stringified = "channel" } object Channel : ChatType() { override val stringified = "channel" }
@Serializable(ChatTypeSerializer::class) @Serializable(ChatTypeSerializer::class)
class Unknown(override val stringified: String) : ChatType() class Unknown(override val stringified: String) : ChatType()
override fun toString(): String {
return stringified
}
} }
val String.asChatType val String.asChatType
get() = when (this) { get() = when (this) {

View File

@ -4,21 +4,14 @@ import dev.inmo.tgbotapi.types.*
import kotlinx.serialization.SerialName import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
/**
* All the field of this class are nullable due to specific of [OrderInfo](https://core.telegram.org/bots/api#orderinfo)
* from official bots api
*
* @see dev.inmo.tgbotapi.abstracts.CommonSendInvoiceData
* @see dev.inmo.tgbotapi.requests.send.payments.SendInvoice
*/
@Serializable @Serializable
data class OrderInfo( data class OrderInfo(
@SerialName(nameField) @SerialName(nameField)
val name: String?, val name: String,
@SerialName(phoneNumberField) @SerialName(phoneNumberField)
val phoneNumber: String?, val phoneNumber: String,
@SerialName(emailField) @SerialName(emailField)
val email: String?, val email: String,
@SerialName(shippingAddressField) @SerialName(shippingAddressField)
val shippingAddress: ShippingAddress? val shippingAddress: ShippingAddress
) )

View File

@ -1,6 +1,5 @@
package dev.inmo.tgbotapi.utils package dev.inmo.tgbotapi.utils
import dev.inmo.micro_utils.common.withReplaced
import dev.inmo.tgbotapi.types.buttons.Matrix import dev.inmo.tgbotapi.types.buttons.Matrix
/** /**
@ -68,18 +67,6 @@ open class RowBuilder<T> {
fun add(t: T) = mutRow.add(t) fun add(t: T) = mutRow.add(t)
operator fun T.unaryPlus() = add(this) operator fun T.unaryPlus() = add(this)
fun replace(i: Int, new: T) {
mutRow[i] = new
}
fun replace(old: T, new: T): Boolean {
val i = mutRow.indexOf(old).takeIf { it > -1 } ?: return false
replace(i, new)
return mutRow[i] == new
}
fun remove(i: Int): T {
return mutRow.removeAt(i)
}
} }
open class MatrixBuilder<T> { open class MatrixBuilder<T> {
@ -90,19 +77,4 @@ open class MatrixBuilder<T> {
fun add(t: List<T>) = mutMatrix.add(t) fun add(t: List<T>) = mutMatrix.add(t)
operator fun plus(t: List<T>) = add(t) operator fun plus(t: List<T>) = add(t)
operator fun T.unaryPlus() = add(listOf(this)) operator fun T.unaryPlus() = add(listOf(this))
fun modifyRow(i: Int, block: RowBuilder<T>.() -> Unit) {
val exists = matrix[i]
val rowBuilder = RowBuilder<T>()
exists.forEach { rowBuilder.add(it) }
mutMatrix[i] = rowBuilder.apply(block).row
}
fun modifyRow(row: List<T>, block: RowBuilder<T>.() -> Unit): Boolean {
val i = mutMatrix.indexOf(row).takeIf { it > -1 } ?: return false
modifyRow(i, block)
return true
}
fun remove(i: Int): List<T> {
return mutMatrix.removeAt(i)
}
} }

View File

@ -3390,7 +3390,6 @@ public final class dev/inmo/tgbotapi/extensions/utils/types/buttons/InlineKeyboa
public static synthetic fun inlineQueryInChosenChatButton$default (Ldev/inmo/tgbotapi/utils/RowBuilder;Ljava/lang/String;Ljava/lang/String;ZZZZILjava/lang/Object;)Z public static synthetic fun inlineQueryInChosenChatButton$default (Ldev/inmo/tgbotapi/utils/RowBuilder;Ljava/lang/String;Ljava/lang/String;ZZZZILjava/lang/Object;)Z
public static final fun inlineQueryInCurrentChatButton (Ldev/inmo/tgbotapi/utils/RowBuilder;Ljava/lang/String;Ljava/lang/String;)Z public static final fun inlineQueryInCurrentChatButton (Ldev/inmo/tgbotapi/utils/RowBuilder;Ljava/lang/String;Ljava/lang/String;)Z
public static final fun loginButton (Ldev/inmo/tgbotapi/utils/RowBuilder;Ljava/lang/String;Ldev/inmo/tgbotapi/types/LoginURL;)Z public static final fun loginButton (Ldev/inmo/tgbotapi/utils/RowBuilder;Ljava/lang/String;Ldev/inmo/tgbotapi/types/LoginURL;)Z
public static final fun modified (Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup;Lkotlin/jvm/functions/Function1;)Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup;
public static final fun payButton (Ldev/inmo/tgbotapi/utils/RowBuilder;Ljava/lang/String;)Z public static final fun payButton (Ldev/inmo/tgbotapi/utils/RowBuilder;Ljava/lang/String;)Z
public static final fun urlButton (Ldev/inmo/tgbotapi/utils/RowBuilder;Ljava/lang/String;Ljava/lang/String;)Z public static final fun urlButton (Ldev/inmo/tgbotapi/utils/RowBuilder;Ljava/lang/String;Ljava/lang/String;)Z
public static final fun webAppButton (Ldev/inmo/tgbotapi/utils/RowBuilder;Ljava/lang/String;Ldev/inmo/tgbotapi/types/webapps/WebAppInfo;)Z public static final fun webAppButton (Ldev/inmo/tgbotapi/utils/RowBuilder;Ljava/lang/String;Ldev/inmo/tgbotapi/types/webapps/WebAppInfo;)Z

View File

@ -49,19 +49,6 @@ inline fun flatInlineKeyboard(
block: InlineKeyboardRowBuilder.() -> Unit block: InlineKeyboardRowBuilder.() -> Unit
) = inlineKeyboard { row<InlineKeyboardButton>(block) } ) = inlineKeyboard { row<InlineKeyboardButton>(block) }
/**
* Factory-function for [InlineKeyboardBuilder]. It will [apply] [block] to internally created [InlineKeyboardMarkup]
* and [InlineKeyboardBuilder.build] [InlineKeyboardMarkup] then
*
* @see InlineKeyboardBuilder.row
*/
inline fun InlineKeyboardMarkup.modified(
block: InlineKeyboardBuilder.() -> Unit
) = InlineKeyboardBuilder().apply {
keyboard.forEach { add(it) }
block()
}.build()
/** /**
* Creates and put [PayInlineKeyboardButton] * Creates and put [PayInlineKeyboardButton]