mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 08:13:47 +00:00
WebhookInfo
This commit is contained in:
parent
f4e58375f2
commit
f3ba288ad8
@ -11,6 +11,8 @@
|
|||||||
* Added webhooks functions and workaround for `Reverse Proxy` mode
|
* Added webhooks functions and workaround for `Reverse Proxy` mode
|
||||||
* Added new type of updates `MediaGroupUpdate`, which can be received only from filters
|
* Added new type of updates `MediaGroupUpdate`, which can be received only from filters
|
||||||
* `UpdatesFilter` now use new type of updates for mediagroups
|
* `UpdatesFilter` now use new type of updates for mediagroups
|
||||||
|
* Add `GetWebhookInfo` request and `WebhookInfo` type
|
||||||
|
* Replace updates types into separated place in types
|
||||||
|
|
||||||
## 0.11.0
|
## 0.11.0
|
||||||
|
|
||||||
|
@ -2,27 +2,30 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests
|
|||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ALL_UPDATES_LIST
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.RawUpdate
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.RawUpdate
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.ArrayListSerializer
|
import kotlinx.serialization.internal.ArrayListSerializer
|
||||||
|
|
||||||
const val UPDATE_MESSAGE = "message"
|
@Deprecated("Replaced to other package", ReplaceWith("UPDATE_MESSAGE", "com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_MESSAGE"))
|
||||||
const val UPDATE_EDITED_MESSAGE = "edited_message"
|
const val UPDATE_MESSAGE = com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_MESSAGE
|
||||||
const val UPDATE_CHANNEL_POST = "channel_post"
|
@Deprecated("Replaced to other package", ReplaceWith("UPDATE_EDITED_MESSAGE", "com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_EDITED_MESSAGE"))
|
||||||
const val UPDATE_EDITED_CHANNEL_POST = "edited_channel_post"
|
const val UPDATE_EDITED_MESSAGE = com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_EDITED_MESSAGE
|
||||||
const val UPDATE_CHOSEN_INLINE_RESULT = "chosen_inline_result"
|
@Deprecated("Replaced to other package", ReplaceWith("UPDATE_CHANNEL_POST", "com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_CHANNEL_POST"))
|
||||||
const val UPDATE_INLINE_QUERY = "inline_query"
|
const val UPDATE_CHANNEL_POST = com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_CHANNEL_POST
|
||||||
const val UPDATE_CALLBACK_QUERY = "callback_query"
|
@Deprecated("Replaced to other package", ReplaceWith("UPDATE_EDITED_CHANNEL_POST", "com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_EDITED_CHANNEL_POST"))
|
||||||
const val UPDATE_SHIPPING_QUERY = "shipping_query"
|
const val UPDATE_EDITED_CHANNEL_POST = com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_EDITED_CHANNEL_POST
|
||||||
const val UPDATE_PRE_CHECKOUT_QUERY = "pre_checkout_query"
|
@Deprecated("Replaced to other package", ReplaceWith("UPDATE_CHOSEN_INLINE_RESULT", "com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_CHOSEN_INLINE_RESULT"))
|
||||||
/*
|
const val UPDATE_CHOSEN_INLINE_RESULT = com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_CHOSEN_INLINE_RESULT
|
||||||
|
@Deprecated("Replaced to other package", ReplaceWith("UPDATE_INLINE_QUERY", "com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_INLINE_QUERY"))
|
||||||
|
const val UPDATE_INLINE_QUERY = com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_INLINE_QUERY
|
||||||
|
@Deprecated("Replaced to other package", ReplaceWith("UPDATE_CALLBACK_QUERY", "com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_CALLBACK_QUERY"))
|
||||||
|
const val UPDATE_CALLBACK_QUERY = com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_CALLBACK_QUERY
|
||||||
|
@Deprecated("Replaced to other package", ReplaceWith("UPDATE_SHIPPING_QUERY", "com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_SHIPPING_QUERY"))
|
||||||
|
const val UPDATE_SHIPPING_QUERY = com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_SHIPPING_QUERY
|
||||||
|
@Deprecated("Replaced to other package", ReplaceWith("UPDATE_PRE_CHECKOUT_QUERY", "com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_PRE_CHECKOUT_QUERY"))
|
||||||
|
const val UPDATE_PRE_CHECKOUT_QUERY = com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_PRE_CHECKOUT_QUERY
|
||||||
|
|
||||||
@Optional private val inline_query: RawInlineQuery? = null,
|
|
||||||
@Optional private val chosen_inline_result: Unit? = null,
|
|
||||||
@Optional private val callback_query: RawCallbackQuery? = null,
|
|
||||||
@Optional private val shipping_query: Unit? = null,
|
|
||||||
@Optional private val pre_checkout_query: Unit? = null
|
|
||||||
*/
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class GetUpdates(
|
data class GetUpdates(
|
||||||
@Optional
|
@Optional
|
||||||
@ -32,17 +35,7 @@ data class GetUpdates(
|
|||||||
@Optional
|
@Optional
|
||||||
val timeout: Int? = null,
|
val timeout: Int? = null,
|
||||||
@Optional
|
@Optional
|
||||||
val allowed_updates: List<String>? = listOf(
|
val allowed_updates: List<String>? = ALL_UPDATES_LIST
|
||||||
UPDATE_MESSAGE,
|
|
||||||
UPDATE_EDITED_MESSAGE,
|
|
||||||
UPDATE_CHANNEL_POST,
|
|
||||||
UPDATE_EDITED_CHANNEL_POST,
|
|
||||||
UPDATE_CHOSEN_INLINE_RESULT,
|
|
||||||
UPDATE_INLINE_QUERY,
|
|
||||||
UPDATE_CALLBACK_QUERY,
|
|
||||||
UPDATE_SHIPPING_QUERY,
|
|
||||||
UPDATE_PRE_CHECKOUT_QUERY
|
|
||||||
)
|
|
||||||
): SimpleRequest<List<RawUpdate>> {
|
): SimpleRequest<List<RawUpdate>> {
|
||||||
override fun method(): String = "getUpdates"
|
override fun method(): String = "getUpdates"
|
||||||
|
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.webhook
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.WebhookInfo
|
||||||
|
import kotlinx.serialization.KSerializer
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
object GetWebhookInfo : SimpleRequest<WebhookInfo> {
|
||||||
|
override fun method(): String = "getWebhookInfo"
|
||||||
|
|
||||||
|
override fun resultSerializer(): KSerializer<WebhookInfo> = WebhookInfo.serializer()
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.webhook
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.*
|
@ -71,6 +71,10 @@ const val switchPmTextField = "switch_pm_text"
|
|||||||
const val switchPmParameterField = "switch_pm_parameter"
|
const val switchPmParameterField = "switch_pm_parameter"
|
||||||
const val maxAllowedConnectionsField = "max_connections"
|
const val maxAllowedConnectionsField = "max_connections"
|
||||||
const val allowedUpdatesField = "allowed_updates"
|
const val allowedUpdatesField = "allowed_updates"
|
||||||
|
const val hasCustomCertificateField = "has_custom_certificate"
|
||||||
|
const val pendingUpdateCountField = "pending_update_count"
|
||||||
|
const val lastErrorDateField = "last_error_date"
|
||||||
|
const val lastErrorMessageField = "last_error_message"
|
||||||
|
|
||||||
|
|
||||||
const val photoUrlField = "photo_url"
|
const val photoUrlField = "photo_url"
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types
|
||||||
|
|
||||||
|
const val UPDATE_MESSAGE = "message"
|
||||||
|
const val UPDATE_EDITED_MESSAGE = "edited_message"
|
||||||
|
const val UPDATE_CHANNEL_POST = "channel_post"
|
||||||
|
const val UPDATE_EDITED_CHANNEL_POST = "edited_channel_post"
|
||||||
|
const val UPDATE_CHOSEN_INLINE_RESULT = "chosen_inline_result"
|
||||||
|
const val UPDATE_INLINE_QUERY = "inline_query"
|
||||||
|
const val UPDATE_CALLBACK_QUERY = "callback_query"
|
||||||
|
const val UPDATE_SHIPPING_QUERY = "shipping_query"
|
||||||
|
const val UPDATE_PRE_CHECKOUT_QUERY = "pre_checkout_query"
|
||||||
|
|
||||||
|
val ALL_UPDATES_LIST = listOf(
|
||||||
|
UPDATE_MESSAGE,
|
||||||
|
UPDATE_EDITED_MESSAGE,
|
||||||
|
UPDATE_CHANNEL_POST,
|
||||||
|
UPDATE_EDITED_CHANNEL_POST,
|
||||||
|
UPDATE_CHOSEN_INLINE_RESULT,
|
||||||
|
UPDATE_INLINE_QUERY,
|
||||||
|
UPDATE_CALLBACK_QUERY,
|
||||||
|
UPDATE_SHIPPING_QUERY,
|
||||||
|
UPDATE_PRE_CHECKOUT_QUERY
|
||||||
|
)
|
@ -0,0 +1,32 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types
|
||||||
|
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class WebhookInfo(
|
||||||
|
@SerialName(urlField)
|
||||||
|
val url: String,
|
||||||
|
@SerialName(pendingUpdateCountField)
|
||||||
|
val awaitDeliery: Int,
|
||||||
|
@SerialName(maxAllowedConnectionsField)
|
||||||
|
@Optional
|
||||||
|
val maxConnections: Int = 40, // default count according to documentation
|
||||||
|
@SerialName(hasCustomCertificateField)
|
||||||
|
@Optional
|
||||||
|
val customCertificate: Boolean = false,
|
||||||
|
@SerialName(allowedUpdatesField)
|
||||||
|
@Optional
|
||||||
|
val allowedUpdates: List<String> = ALL_UPDATES_LIST,
|
||||||
|
@SerialName(lastErrorDateField)
|
||||||
|
@Optional
|
||||||
|
val lastErrorDate: TelegramDate? = null,
|
||||||
|
@SerialName(lastErrorMessageField)
|
||||||
|
@Optional
|
||||||
|
val lastErrorMessage: String? = null
|
||||||
|
) {
|
||||||
|
@Transient
|
||||||
|
val isNotUseWebhook: Boolean = url.isEmpty()
|
||||||
|
|
||||||
|
@Transient
|
||||||
|
val hasError: Boolean = lastErrorMessage != null
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.utils.extensions
|
package com.github.insanusmokrassar.TelegramBotAPI.utils.extensions
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseMessageUpdate
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseMessageUpdate
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMediaGroupUpdate
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMediaGroupUpdate
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.utils.extensions
|
package com.github.insanusmokrassar.TelegramBotAPI.utils.extensions
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.InputFile
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.InputFile
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.webhook.SetWebhook
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MediaGroupIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MediaGroupIdentifier
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.MediaGroupMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.MediaGroupMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.*
|
||||||
|
Loading…
Reference in New Issue
Block a user