diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/set/SetUserEmojiStatus.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/set/SetUserEmojiStatus.kt new file mode 100644 index 0000000000..60af40bdee --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/set/SetUserEmojiStatus.kt @@ -0,0 +1,28 @@ +package dev.inmo.tgbotapi.requests.set + +import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.types.* +import kotlinx.serialization.DeserializationStrategy +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable +import kotlinx.serialization.SerializationStrategy +import kotlinx.serialization.builtins.serializer + +@Serializable +data class SetUserEmojiStatus( + @SerialName(userIdField) + val userId: UserId, + @SerialName(emojiStatusCustomEmojiIdField) + val customEmojiId: CustomEmojiId, + @Serializable(TelegramDateSerializer::class) + @SerialName(emojiStatusExpirationDateField) + val expirationDate: TelegramDate? = null +) : SimpleRequest { + override fun method(): String = "setUserEmojiStatus" + + override val requestSerializer: SerializationStrategy<*> + get() = serializer() + + override val resultDeserializer: DeserializationStrategy + get() = Boolean.serializer() +} \ No newline at end of file diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/DownloadFileParams.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/DownloadFileParams.kt new file mode 100644 index 0000000000..2bf289f140 --- /dev/null +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/DownloadFileParams.kt @@ -0,0 +1,16 @@ +package dev.inmo.tgbotapi.webapps + +import kotlin.js.json + +external interface DownloadFileParams { + val url: String + @JsName("file_name") + val fileName: String +} +fun DownloadFileParams( + url: String, + fileName: String +) = json( + "url" to url, + "file_name" to fileName +).unsafeCast() \ No newline at end of file diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/EmojiStatusParams.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/EmojiStatusParams.kt new file mode 100644 index 0000000000..7770bd96bc --- /dev/null +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/EmojiStatusParams.kt @@ -0,0 +1,13 @@ +package dev.inmo.tgbotapi.webapps + +import dev.inmo.tgbotapi.types.Seconds +import kotlin.js.json + +external interface EmojiStatusParams { + val duration: Seconds? +} +fun EmojiStatusParams( + duration: Seconds +): EmojiStatusParams = json( + "duration" to duration +).unsafeCast() diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/WebApp.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/WebApp.kt index 4d6c659b0f..a79909b8ec 100644 --- a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/WebApp.kt +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/WebApp.kt @@ -1,5 +1,6 @@ package dev.inmo.tgbotapi.webapps +import dev.inmo.tgbotapi.types.CustomEmojiId import dev.inmo.tgbotapi.types.PreparedMessageId import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper import dev.inmo.tgbotapi.webapps.accelerometer.Accelerometer @@ -71,8 +72,6 @@ external class WebApp { fun addToHomeScreen() fun checkHomeScreenStatus(callback: (HomeScreenStatus) -> Unit = definedExternally) - fun shareMessage(messageId: PreparedMessageId, callback: (Boolean) -> Unit = definedExternally) - @JsName("MainButton") val mainButton: BottomButton @JsName("SecondaryButton") @@ -144,6 +143,13 @@ external class WebApp { fun shareToStory(mediaUrl: String, params: StoryShareParams? = definedExternally) + fun shareMessage(messageId: PreparedMessageId, callback: (Boolean) -> Unit = definedExternally) + + fun setEmojiStatus(customEmojiId: CustomEmojiId, params: EmojiStatusParams = definedExternally, callback: (Boolean) -> Unit = definedExternally) + fun requestEmojiStatusAccess(callback: (Boolean) -> Unit = definedExternally) + + fun downloadFile(params: DownloadFileParams, callback: (Boolean) -> Unit = definedExternally) + fun requestWriteAccess(callback: ((Boolean) -> Unit)? = definedExternally) fun requestContact(callback: ((Boolean) -> Unit)? = definedExternally) }