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

return SetWebhook without certificate

This commit is contained in:
InsanusMokrassar 2020-11-04 23:21:25 +06:00
parent 7a2ecd2dbf
commit 179bb66183
4 changed files with 41 additions and 11 deletions

View File

@ -6,9 +6,6 @@
* Support of `logOut` method (`LogOut` object as a `Request`)
* Support of `close` method (`Close` object as a `Request`)
* `SetWebhook` updates:
* Function `SetWebhook` with `inputFile` has changed this param nullability - `inputFile` now is nullable
* Function `SetWebhook` without `certificate` param now is unavailable. You can use `SetWebhook` with nullable
`inputFile`
* New field `ipAddress`. It works the same as `ip_address` in [setWebhook](https://core.telegram.org/bots/api#setwebhook)
section
* New field `dropPendingUpdates`. It works the same as `drop_pending_updates` in [setWebhook](https://core.telegram.org/bots/api#setwebhook)
@ -18,6 +15,7 @@
* New field `UnbanChatMember#onlyIfBanned`
* New fields `ExtendedChannelChat#linkedGroupChatId` and `ExtendedSupergroupChat#linkedChannelChatId`
* New fields `ExtendedSupergroupChat#location`
* New fields `AudioFile#fileName` and `VideoFile#fileName`
## 0.29.4

View File

@ -58,7 +58,7 @@ fun SetWebhook(
@Suppress("USELESS_CAST")
fun SetWebhook(
url: String,
certificate: InputFile? = null,
certificate: InputFile,
ipAddress: String? = null,
maxAllowedConnections: Int? = null,
allowedUpdates: List<String>? = null,
@ -66,9 +66,31 @@ fun SetWebhook(
): Request<Boolean> = when (certificate) {
is MultipartFile -> SetWebhook(correctWebhookUrl(url), certificate as MultipartFile, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates)
is FileId -> SetWebhook(correctWebhookUrl(url), certificate as FileId, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates)
null -> SetWebhook(correctWebhookUrl(url), null as String?, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates)
}
/**
* Use this method to specify a url and receive incoming updates via an outgoing webhook. Whenever there is an update
* for the bot, we will send an HTTPS POST request to the specified url, containing a JSON-serialized Update.
*
* If you'd like to make sure that the Webhook request comes from Telegram, we recommend using a secret path in the [url],
* e.g. https://www.example.com/<token>. Since nobody else knows your bot's token, you can be pretty sure it's us.
*/
@Suppress("USELESS_CAST")
fun SetWebhook(
url: String,
ipAddress: String? = null,
maxAllowedConnections: Int? = null,
allowedUpdates: List<String>? = null,
dropPendingUpdates: Boolean? = null
): Request<Boolean> = SetWebhook(
correctWebhookUrl(url),
null,
ipAddress,
maxAllowedConnections,
allowedUpdates,
dropPendingUpdates
)
/**
* Use this method to specify a url and receive incoming updates via an outgoing webhook. Whenever there is an update
* for the bot, we will send an HTTPS POST request to the specified url, containing a JSON-serialized Update.

View File

@ -2,8 +2,7 @@ package dev.inmo.tgbotapi.types.files
import dev.inmo.tgbotapi.CommonAbstracts.Performerable
import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.types.FileUniqueId
import dev.inmo.tgbotapi.types.fileUniqueIdField
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.files.abstracts.*
import dev.inmo.tgbotapi.utils.MimeType
import kotlinx.serialization.SerialName
@ -15,14 +14,20 @@ data class AudioFile(
override val fileId: FileId,
@SerialName(fileUniqueIdField)
override val fileUniqueId: FileUniqueId,
@SerialName(durationField)
override val duration: Long? = null,
@SerialName(performerField)
override val performer: String? = null,
@SerialName(titleField)
override val title: String? = null,
@SerialName(fileNameField)
override val fileName: String? = null,
@SerialName(mimeTypeField)
override val mimeType: MimeType? = null,
@SerialName(fileSizeField)
override val fileSize: Long? = null,
@SerialName(thumbField)
override val thumb: PhotoSize? = null
) : TelegramMediaFile, MimedMediaFile, ThumbedMediaFile, PlayableMediaFile, TitledMediaFile, Performerable
) : TelegramMediaFile, CustomNamedMediaFile, MimedMediaFile, ThumbedMediaFile, PlayableMediaFile, TitledMediaFile, Performerable
fun AudioFile.asVoiceFile() = VoiceFile(fileId, fileUniqueId, duration, mimeType, fileSize)

View File

@ -1,11 +1,10 @@
package dev.inmo.tgbotapi.types.files
import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.types.FileUniqueId
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.InputMedia.InputMediaVideo
import dev.inmo.tgbotapi.types.ParseMode.HTMLParseMode
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.fileUniqueIdField
import dev.inmo.tgbotapi.types.files.abstracts.*
import dev.inmo.tgbotapi.utils.MimeType
import dev.inmo.tgbotapi.utils.toHtmlCaptions
@ -18,15 +17,21 @@ data class VideoFile(
override val fileId: FileId,
@SerialName(fileUniqueIdField)
override val fileUniqueId: FileUniqueId,
@SerialName(widthField)
override val width: Int,
@SerialName(heightField)
override val height: Int,
@SerialName(durationField)
override val duration: Long? = null,
@SerialName(thumbField)
override val thumb: PhotoSize? = null,
@SerialName(fileNameField)
override val fileName: String? = null,
@SerialName(mimeTypeField)
override val mimeType: MimeType? = null,
@SerialName(fileSizeField)
override val fileSize: Long? = null
) : TelegramMediaFile, MimedMediaFile, ThumbedMediaFile, PlayableMediaFile, SizedMediaFile
) : TelegramMediaFile, CustomNamedMediaFile, MimedMediaFile, ThumbedMediaFile, PlayableMediaFile, SizedMediaFile
@Suppress("NOTHING_TO_INLINE")
inline fun VideoFile.toInputMediaVideo(