mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-11-17 12:30:20 +00:00
Compare commits
82 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 284fe58848 | |||
| 38c9732da5 | |||
| dee13c03ae | |||
| 6103b70a47 | |||
| 7f5cd0567b | |||
| af159b89b6 | |||
| efe286c181 | |||
| 821bb5b45c | |||
| c92ed92f7c | |||
| 88f6b349ea | |||
| 6c4afac8f8 | |||
| 6273990b00 | |||
| 1a1fd926dd | |||
| affa2a3a57 | |||
| 73a748d8b3 | |||
| fa4d264df4 | |||
| 1b1da33882 | |||
| ccfb774f33 | |||
| 5215e8a315 | |||
| 97a3901cb9 | |||
| 034e87a8ef | |||
| 156fbd72d4 | |||
| 8ec3e01737 | |||
| 1655bedabe | |||
| ac6b580a7e | |||
| c6692c2509 | |||
| 12846a68b9 | |||
| 21f5808b12 | |||
| 64244a60fe | |||
| 4cd7fdb436 | |||
| 6daf98d47d | |||
| c260597799 | |||
| d59e204002 | |||
| 117d891ff2 | |||
| 1e451af508 | |||
| 051f5e22e7 | |||
| 6873c23309 | |||
| a65971be00 | |||
| 4b5baaff8c | |||
| 0840d2e083 | |||
| 085a225eb4 | |||
| b575871a8e | |||
| c96e162845 | |||
| c471d59b3c | |||
| 187f340e88 | |||
| 77ea1f741e | |||
| bff2713bbd | |||
| cf666aad11 | |||
| 93e72230a1 | |||
| b81308da8b | |||
| 0441b53da2 | |||
| 4853a5b3ad | |||
| 40a0d2c37d | |||
| 2e815a4c37 | |||
| 81ed820602 | |||
| b3a657b7d6 | |||
| 8247e7c69c | |||
| 67b7472868 | |||
| 13e4740d0a | |||
| 48db305541 | |||
| 6f512a144c | |||
| cf46139bef | |||
| 14a583e154 | |||
| 5b6753c484 | |||
| f153b31464 | |||
| 6f60ecbf2e | |||
| 9c57ba4da7 | |||
| d84d982eb4 | |||
|
|
2f6f40362a | ||
| e15b18fbcf | |||
| ad5cc6ade6 | |||
| 6b94215a7c | |||
| 9c98411bcb | |||
| b235ab1c28 | |||
| d4e11494e8 | |||
| e6dbf2bde9 | |||
| 5aa0284f28 | |||
| 8b2a50a21f | |||
| a7839df748 | |||
| 3155969954 | |||
| 067a0bf229 | |||
| 009991fa88 |
67
CHANGELOG.md
67
CHANGELOG.md
@@ -1,5 +1,72 @@
|
|||||||
# TelegramBotAPI changelog
|
# TelegramBotAPI changelog
|
||||||
|
|
||||||
|
## 9.2.1
|
||||||
|
|
||||||
|
* `Version`:
|
||||||
|
* `Ktor`: `2.3.3` -> `2.3.4`
|
||||||
|
* `Core`:
|
||||||
|
* All `ChatMember` inheritors have fixes `status` field
|
||||||
|
|
||||||
|
## 9.2.0
|
||||||
|
|
||||||
|
**Add support of [Telegram Bots API 6.9](https://core.telegram.org/bots/api-changelog#september-22-2023)**
|
||||||
|
|
||||||
|
* Rename `ChatAdministratorRightsImpl` -> `ChatCommonAdministratorRights`
|
||||||
|
* All the request chat keyboards has changed their parameters `ChatAdministratorRights` to `ChatCommonAdministratorRights`
|
||||||
|
|
||||||
|
## 9.1.2
|
||||||
|
|
||||||
|
* `Core`:
|
||||||
|
* Fix of `MessageContent` serialization
|
||||||
|
|
||||||
|
## 9.1.1
|
||||||
|
|
||||||
|
* `Core`:
|
||||||
|
* Potential fix of incorrect parsing in `RawMessageEntity`
|
||||||
|
|
||||||
|
## 9.1.0
|
||||||
|
|
||||||
|
**This update contains adding of [Telegram Bot API 6.8](https://core.telegram.org/bots/api-changelog#august-18-2023) support**
|
||||||
|
|
||||||
|
* `Version`:
|
||||||
|
* `Coroutines`: `1.7.2` -> `1.7.3`
|
||||||
|
* `Ktor`: `2.3.2` -> `2.3.3`
|
||||||
|
* `MicroUtils`: `0.19.7` -> `0.19.9`
|
||||||
|
|
||||||
|
## 9.0.0
|
||||||
|
|
||||||
|
**THIS UPDATE CONTAINS BREAKING CHANGES: USERNAMES OF BOTS NOW BECAME NULLABLE**
|
||||||
|
|
||||||
|
* `Version`:
|
||||||
|
* `Coroutines`: `1.6.4` -> `1.7.1`
|
||||||
|
* `Ktor`: `2.3.1` -> `2.3.2`
|
||||||
|
* `MicroUtils`: `0.19.4` -> `0.19.7`
|
||||||
|
* `Core`:
|
||||||
|
* **All bots now have nullable usernames just like common users ([#772](https://github.com/InsanusMokrassar/ktgbotapi/issues/772))**
|
||||||
|
* Decrease possible errors in updates handling by additional handling of update deserialization wrapping ([#773](https://github.com/InsanusMokrassar/ktgbotapi/issues/773))
|
||||||
|
* New interface `GetUpdatesRequest`. You may implement it to show default telegram bot ktor executor that this
|
||||||
|
request is an updates request and should be handled in a different way
|
||||||
|
* Now it is possible to get raw updates with `GetUpdatesRaw` request
|
||||||
|
* `Utils`:
|
||||||
|
* Improve extension `Update.sourceChat` to add opportunity to select some chats by logic different with the default
|
||||||
|
|
||||||
|
## 8.1.0
|
||||||
|
|
||||||
|
**PARTIALLY BREAKING CHANGES: Exclude `.*Impl` classcasts from `ClassCastsNew`**
|
||||||
|
|
||||||
|
* `Version`:
|
||||||
|
* `MicroUtils`: `0.19.2` -> `0.19.4`
|
||||||
|
* `Utils`:
|
||||||
|
* Add deep links formatting for internal `tg://` prefix (thanks to [@klimatov](https://github.com/klimatov))
|
||||||
|
* Exclude `.*Impl` classcasts from `ClassCastsNew`
|
||||||
|
|
||||||
|
## 8.0.1
|
||||||
|
|
||||||
|
* `Version`:
|
||||||
|
* `UUID`: `0.7.0` -> `0.7.1`
|
||||||
|
* `Ktor`: `2.3.0` -> `2.3.1`
|
||||||
|
* `MicroUtils`: `0.19.1` -> `0.19.2`
|
||||||
|
|
||||||
## 8.0.0
|
## 8.0.0
|
||||||
|
|
||||||
**THIS UPDATE CONTAINS BREAKING CHANGES**
|
**THIS UPDATE CONTAINS BREAKING CHANGES**
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# TelegramBotAPI [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [](https://core.telegram.org/bots/api-changelog#april-21-2023)
|
# TelegramBotAPI [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [](https://core.telegram.org/bots/api-changelog#september-22-2023)
|
||||||
|
|
||||||
| Docs | [](https://tgbotapi.inmo.dev/index.html) [](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) |
|
| Docs | [](https://tgbotapi.inmo.dev/index.html) [](https://docs.inmo.dev/tgbotapi/index.html) |
|
||||||
|:----------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
|:----------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
||||||
| Useful repos | [](https://github.com/InsanusMokrassar/TelegramBotAPI-bot_template/generate) [](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/) |
|
| Useful repos | [](https://github.com/InsanusMokrassar/TelegramBotAPI-bot_template/generate) [](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/) |
|
||||||
| Misc | [](https://github.com/KotlinBy/awesome-kotlin) [](https://docs.google.com/forms/d/e/1FAIpQLSctdJHT_aEniyYT0-IUAEfo1hsIlezX2owlkEAYX4KPl2V2_A/viewform?usp=sf_link) |
|
| Misc | [](https://github.com/KotlinBy/awesome-kotlin) [](https://docs.google.com/forms/d/e/1FAIpQLSctdJHT_aEniyYT0-IUAEfo1hsIlezX2owlkEAYX4KPl2V2_A/viewform?usp=sf_link) |
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ Object callback = {
|
|||||||
skipDeprecated.set(true)
|
skipDeprecated.set(true)
|
||||||
|
|
||||||
sourceLink {
|
sourceLink {
|
||||||
localDirectory.set(file("./"))
|
localDirectory.set(file("../"))
|
||||||
remoteUrl.set(new URL("https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/"))
|
remoteUrl.set(new URL("https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/"))
|
||||||
remoteLineSuffix.set("#L")
|
remoteLineSuffix.set("#L")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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=8.0.0
|
library_version=9.2.1
|
||||||
|
|||||||
@@ -1,22 +1,22 @@
|
|||||||
[versions]
|
[versions]
|
||||||
|
|
||||||
kotlin = "1.8.21"
|
kotlin = "1.8.22"
|
||||||
kotlin-serialization = "1.5.1"
|
kotlin-serialization = "1.5.1"
|
||||||
kotlin-coroutines = "1.6.4"
|
kotlin-coroutines = "1.7.3"
|
||||||
|
|
||||||
javax-activation = "1.1.1"
|
javax-activation = "1.1.1"
|
||||||
|
|
||||||
korlibs = "4.0.3"
|
korlibs = "4.0.3"
|
||||||
uuid = "0.7.0"
|
uuid = "0.7.1"
|
||||||
ktor = "2.3.0"
|
ktor = "2.3.4"
|
||||||
|
|
||||||
ksp = "1.8.21-1.0.11"
|
ksp = "1.8.22-1.0.11"
|
||||||
kotlin-poet = "1.14.2"
|
kotlin-poet = "1.14.2"
|
||||||
|
|
||||||
microutils = "0.19.1"
|
microutils = "0.19.9"
|
||||||
|
|
||||||
github-release-plugin = "2.4.1"
|
github-release-plugin = "2.4.1"
|
||||||
dokka = "1.8.10"
|
dokka = "1.8.20"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
|
|
||||||
|
|||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -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.6.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.GetUpdates
|
||||||
|
import dev.inmo.tgbotapi.requests.GetUpdatesRaw
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
|
|
||||||
|
suspend fun TelegramBot.getRawUpdates(
|
||||||
|
offset: UpdateIdentifier? = null,
|
||||||
|
limit: Int = getUpdatesLimit.last,
|
||||||
|
timeout: Seconds? = null,
|
||||||
|
allowed_updates: List<String>? = ALL_UPDATES_LIST
|
||||||
|
) = execute(
|
||||||
|
GetUpdatesRaw(
|
||||||
|
offset, limit, timeout, allowed_updates
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.getRawUpdates(
|
||||||
|
lastUpdate: Update,
|
||||||
|
limit: Int = getUpdatesLimit.last,
|
||||||
|
timeout: Seconds? = null,
|
||||||
|
allowed_updates: List<String>? = ALL_UPDATES_LIST
|
||||||
|
) = getRawUpdates(
|
||||||
|
lastUpdate.updateId + 1, limit, timeout, allowed_updates
|
||||||
|
)
|
||||||
@@ -2,17 +2,17 @@ package dev.inmo.tgbotapi.extensions.api.bot
|
|||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.bot.SetMyDefaultAdministratorRights
|
import dev.inmo.tgbotapi.requests.bot.SetMyDefaultAdministratorRights
|
||||||
import dev.inmo.tgbotapi.types.chat.member.ChatAdministratorRightsImpl
|
import dev.inmo.tgbotapi.types.chat.member.ChatCommonAdministratorRights
|
||||||
|
|
||||||
suspend fun TelegramBot.setMyDefaultAdministratorRights(
|
suspend fun TelegramBot.setMyDefaultAdministratorRights(
|
||||||
rights: ChatAdministratorRightsImpl,
|
rights: ChatCommonAdministratorRights,
|
||||||
forChannels: Boolean? = null
|
forChannels: Boolean? = null
|
||||||
) = execute(SetMyDefaultAdministratorRights(rights, forChannels))
|
) = execute(SetMyDefaultAdministratorRights(rights, forChannels))
|
||||||
|
|
||||||
suspend fun TelegramBot.setMyDefaultAdministratorRightsForChannels(
|
suspend fun TelegramBot.setMyDefaultAdministratorRightsForChannels(
|
||||||
rights: ChatAdministratorRightsImpl
|
rights: ChatCommonAdministratorRights
|
||||||
) = setMyDefaultAdministratorRights(rights, forChannels = true)
|
) = setMyDefaultAdministratorRights(rights, forChannels = true)
|
||||||
|
|
||||||
suspend fun TelegramBot.setMyDefaultAdministratorRightsForGroupsAndSupergroups(
|
suspend fun TelegramBot.setMyDefaultAdministratorRightsForGroupsAndSupergroups(
|
||||||
rights: ChatAdministratorRightsImpl
|
rights: ChatCommonAdministratorRights
|
||||||
) = setMyDefaultAdministratorRights(rights, forChannels = false)
|
) = setMyDefaultAdministratorRights(rights, forChannels = false)
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.chat.forum
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.chat.forum.UnpinAllForumTopicMessages
|
||||||
|
import dev.inmo.tgbotapi.requests.chat.forum.UnpinAllGeneralForumTopicMessages
|
||||||
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
|
import dev.inmo.tgbotapi.types.ForumTopic
|
||||||
|
import dev.inmo.tgbotapi.types.MessageThreadId
|
||||||
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
|
|
||||||
|
suspend fun TelegramBot.unpinAllGeneralForumTopicMessages(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = execute(
|
||||||
|
UnpinAllGeneralForumTopicMessages(
|
||||||
|
chatId
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.unpinAllGeneralForumTopicMessages(
|
||||||
|
chat: Chat
|
||||||
|
) = unpinAllGeneralForumTopicMessages(chat.id)
|
||||||
@@ -0,0 +1,157 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.chat.members
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.chat.members.PromoteChannelAdministrator
|
||||||
|
import dev.inmo.tgbotapi.requests.chat.members.PromoteChatMember
|
||||||
|
import dev.inmo.tgbotapi.types.IdChatIdentifier
|
||||||
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
|
import dev.inmo.tgbotapi.types.TelegramDate
|
||||||
|
import dev.inmo.tgbotapi.types.UserId
|
||||||
|
import dev.inmo.tgbotapi.types.chat.PublicChat
|
||||||
|
import dev.inmo.tgbotapi.types.chat.User
|
||||||
|
|
||||||
|
suspend fun TelegramBot.promoteChannelAdministrator(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
userId: UserId,
|
||||||
|
untilDate: TelegramDate? = null,
|
||||||
|
isAnonymous: Boolean? = null,
|
||||||
|
canChangeInfo: Boolean? = null,
|
||||||
|
canPostMessages: Boolean? = null,
|
||||||
|
canEditMessages: Boolean? = null,
|
||||||
|
canDeleteMessages: Boolean? = null,
|
||||||
|
canInviteUsers: Boolean? = null,
|
||||||
|
canRestrictMembers: Boolean? = null,
|
||||||
|
canPromoteMembers: Boolean? = null,
|
||||||
|
canManageVideoChats: Boolean? = null,
|
||||||
|
canManageChat: Boolean? = null,
|
||||||
|
canPostStories: Boolean? = null,
|
||||||
|
canEditStories: Boolean? = null,
|
||||||
|
canDeleteStories: Boolean? = null
|
||||||
|
) = execute(
|
||||||
|
PromoteChannelAdministrator(
|
||||||
|
chatId = chatId,
|
||||||
|
userId = userId,
|
||||||
|
untilDate = untilDate,
|
||||||
|
isAnonymous = isAnonymous,
|
||||||
|
canChangeInfo = canChangeInfo,
|
||||||
|
canPostMessages = canPostMessages,
|
||||||
|
canEditMessages = canEditMessages,
|
||||||
|
canDeleteMessages = canDeleteMessages,
|
||||||
|
canInviteUsers = canInviteUsers,
|
||||||
|
canRestrictMembers = canRestrictMembers,
|
||||||
|
canPromoteMembers = canPromoteMembers,
|
||||||
|
canManageVideoChats = canManageVideoChats,
|
||||||
|
canManageChat = canManageChat,
|
||||||
|
canPostStories = canPostStories,
|
||||||
|
canEditStories = canEditStories,
|
||||||
|
canDeleteStories = canDeleteStories
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.promoteChannelAdministrator(
|
||||||
|
chat: PublicChat,
|
||||||
|
userId: UserId,
|
||||||
|
untilDate: TelegramDate? = null,
|
||||||
|
isAnonymous: Boolean? = null,
|
||||||
|
canChangeInfo: Boolean? = null,
|
||||||
|
canPostMessages: Boolean? = null,
|
||||||
|
canEditMessages: Boolean? = null,
|
||||||
|
canDeleteMessages: Boolean? = null,
|
||||||
|
canInviteUsers: Boolean? = null,
|
||||||
|
canRestrictMembers: Boolean? = null,
|
||||||
|
canPromoteMembers: Boolean? = null,
|
||||||
|
canManageVideoChats: Boolean? = null,
|
||||||
|
canManageChat: Boolean? = null,
|
||||||
|
canPostStories: Boolean? = null,
|
||||||
|
canEditStories: Boolean? = null,
|
||||||
|
canDeleteStories: Boolean? = null
|
||||||
|
) = promoteChannelAdministrator(
|
||||||
|
chat.id,
|
||||||
|
userId,
|
||||||
|
untilDate = untilDate,
|
||||||
|
isAnonymous = isAnonymous,
|
||||||
|
canChangeInfo = canChangeInfo,
|
||||||
|
canPostMessages = canPostMessages,
|
||||||
|
canEditMessages = canEditMessages,
|
||||||
|
canDeleteMessages = canDeleteMessages,
|
||||||
|
canInviteUsers = canInviteUsers,
|
||||||
|
canRestrictMembers = canRestrictMembers,
|
||||||
|
canPromoteMembers = canPromoteMembers,
|
||||||
|
canManageVideoChats = canManageVideoChats,
|
||||||
|
canManageChat = canManageChat,
|
||||||
|
canPostStories = canPostStories,
|
||||||
|
canEditStories = canEditStories,
|
||||||
|
canDeleteStories = canDeleteStories
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.promoteChannelAdministrator(
|
||||||
|
chatId: IdChatIdentifier,
|
||||||
|
user: User,
|
||||||
|
untilDate: TelegramDate? = null,
|
||||||
|
isAnonymous: Boolean? = null,
|
||||||
|
canChangeInfo: Boolean? = null,
|
||||||
|
canPostMessages: Boolean? = null,
|
||||||
|
canEditMessages: Boolean? = null,
|
||||||
|
canDeleteMessages: Boolean? = null,
|
||||||
|
canInviteUsers: Boolean? = null,
|
||||||
|
canRestrictMembers: Boolean? = null,
|
||||||
|
canPromoteMembers: Boolean? = null,
|
||||||
|
canManageVideoChats: Boolean? = null,
|
||||||
|
canManageChat: Boolean? = null,
|
||||||
|
canPostStories: Boolean? = null,
|
||||||
|
canEditStories: Boolean? = null,
|
||||||
|
canDeleteStories: Boolean? = null
|
||||||
|
) = promoteChannelAdministrator(
|
||||||
|
chatId,
|
||||||
|
user.id,
|
||||||
|
untilDate = untilDate,
|
||||||
|
isAnonymous = isAnonymous,
|
||||||
|
canChangeInfo = canChangeInfo,
|
||||||
|
canPostMessages = canPostMessages,
|
||||||
|
canEditMessages = canEditMessages,
|
||||||
|
canDeleteMessages = canDeleteMessages,
|
||||||
|
canInviteUsers = canInviteUsers,
|
||||||
|
canRestrictMembers = canRestrictMembers,
|
||||||
|
canPromoteMembers = canPromoteMembers,
|
||||||
|
canManageVideoChats = canManageVideoChats,
|
||||||
|
canManageChat = canManageChat,
|
||||||
|
canPostStories = canPostStories,
|
||||||
|
canEditStories = canEditStories,
|
||||||
|
canDeleteStories = canDeleteStories
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.promoteChannelAdministrator(
|
||||||
|
chat: PublicChat,
|
||||||
|
user: User,
|
||||||
|
untilDate: TelegramDate? = null,
|
||||||
|
isAnonymous: Boolean? = null,
|
||||||
|
canChangeInfo: Boolean? = null,
|
||||||
|
canPostMessages: Boolean? = null,
|
||||||
|
canEditMessages: Boolean? = null,
|
||||||
|
canDeleteMessages: Boolean? = null,
|
||||||
|
canInviteUsers: Boolean? = null,
|
||||||
|
canRestrictMembers: Boolean? = null,
|
||||||
|
canPromoteMembers: Boolean? = null,
|
||||||
|
canManageVideoChats: Boolean? = null,
|
||||||
|
canManageChat: Boolean? = null,
|
||||||
|
canPostStories: Boolean? = null,
|
||||||
|
canEditStories: Boolean? = null,
|
||||||
|
canDeleteStories: Boolean? = null
|
||||||
|
) = promoteChannelAdministrator(
|
||||||
|
chat.id,
|
||||||
|
user.id,
|
||||||
|
untilDate = untilDate,
|
||||||
|
isAnonymous = isAnonymous,
|
||||||
|
canChangeInfo = canChangeInfo,
|
||||||
|
canPostMessages = canPostMessages,
|
||||||
|
canEditMessages = canEditMessages,
|
||||||
|
canDeleteMessages = canDeleteMessages,
|
||||||
|
canInviteUsers = canInviteUsers,
|
||||||
|
canRestrictMembers = canRestrictMembers,
|
||||||
|
canPromoteMembers = canPromoteMembers,
|
||||||
|
canManageVideoChats = canManageVideoChats,
|
||||||
|
canManageChat = canManageChat,
|
||||||
|
canPostStories = canPostStories,
|
||||||
|
canEditStories = canEditStories,
|
||||||
|
canDeleteStories = canDeleteStories
|
||||||
|
)
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.chat.members
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.chat.members.PromoteChatMember
|
||||||
|
import dev.inmo.tgbotapi.types.IdChatIdentifier
|
||||||
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
|
import dev.inmo.tgbotapi.types.TelegramDate
|
||||||
|
import dev.inmo.tgbotapi.types.UserId
|
||||||
|
import dev.inmo.tgbotapi.types.chat.PublicChat
|
||||||
|
import dev.inmo.tgbotapi.types.chat.User
|
||||||
|
|
||||||
|
suspend fun TelegramBot.promoteChatAdministrator(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
userId: UserId,
|
||||||
|
untilDate: TelegramDate? = null,
|
||||||
|
isAnonymous: Boolean? = null,
|
||||||
|
canChangeInfo: Boolean? = null,
|
||||||
|
canDeleteMessages: Boolean? = null,
|
||||||
|
canInviteUsers: Boolean? = null,
|
||||||
|
canRestrictMembers: Boolean? = null,
|
||||||
|
canPromoteMembers: Boolean? = null,
|
||||||
|
canManageVideoChats: Boolean? = null,
|
||||||
|
canManageChat: Boolean? = null,
|
||||||
|
) = execute(
|
||||||
|
PromoteChatMember(
|
||||||
|
chatId,
|
||||||
|
userId,
|
||||||
|
untilDate,
|
||||||
|
isAnonymous,
|
||||||
|
canChangeInfo,
|
||||||
|
canDeleteMessages,
|
||||||
|
canInviteUsers,
|
||||||
|
canRestrictMembers,
|
||||||
|
canPromoteMembers,
|
||||||
|
canManageVideoChats,
|
||||||
|
canManageChat
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.promoteChatAdministrator(
|
||||||
|
chat: PublicChat,
|
||||||
|
userId: UserId,
|
||||||
|
untilDate: TelegramDate? = null,
|
||||||
|
isAnonymous: Boolean? = null,
|
||||||
|
canChangeInfo: Boolean? = null,
|
||||||
|
canDeleteMessages: Boolean? = null,
|
||||||
|
canInviteUsers: Boolean? = null,
|
||||||
|
canRestrictMembers: Boolean? = null,
|
||||||
|
canPromoteMembers: Boolean? = null,
|
||||||
|
canManageVideoChats: Boolean? = null,
|
||||||
|
canManageChat: Boolean? = null,
|
||||||
|
) = promoteChatAdministrator(
|
||||||
|
chat.id,
|
||||||
|
userId,
|
||||||
|
untilDate,
|
||||||
|
isAnonymous,
|
||||||
|
canChangeInfo,
|
||||||
|
canDeleteMessages,
|
||||||
|
canInviteUsers,
|
||||||
|
canRestrictMembers,
|
||||||
|
canPromoteMembers,
|
||||||
|
canManageVideoChats,
|
||||||
|
canManageChat
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.promoteChatAdministrator(
|
||||||
|
chatId: IdChatIdentifier,
|
||||||
|
user: User,
|
||||||
|
untilDate: TelegramDate? = null,
|
||||||
|
isAnonymous: Boolean? = null,
|
||||||
|
canChangeInfo: Boolean? = null,
|
||||||
|
canDeleteMessages: Boolean? = null,
|
||||||
|
canInviteUsers: Boolean? = null,
|
||||||
|
canRestrictMembers: Boolean? = null,
|
||||||
|
canPromoteMembers: Boolean? = null,
|
||||||
|
canManageVideoChats: Boolean? = null,
|
||||||
|
canManageChat: Boolean? = null,
|
||||||
|
) = promoteChatAdministrator(
|
||||||
|
chatId,
|
||||||
|
user.id,
|
||||||
|
untilDate,
|
||||||
|
isAnonymous,
|
||||||
|
canChangeInfo,
|
||||||
|
canDeleteMessages,
|
||||||
|
canInviteUsers,
|
||||||
|
canRestrictMembers,
|
||||||
|
canPromoteMembers,
|
||||||
|
canManageVideoChats,
|
||||||
|
canManageChat
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.promoteChatAdministrator(
|
||||||
|
chat: PublicChat,
|
||||||
|
user: User,
|
||||||
|
untilDate: TelegramDate? = null,
|
||||||
|
isAnonymous: Boolean? = null,
|
||||||
|
canChangeInfo: Boolean? = null,
|
||||||
|
canDeleteMessages: Boolean? = null,
|
||||||
|
canInviteUsers: Boolean? = null,
|
||||||
|
canRestrictMembers: Boolean? = null,
|
||||||
|
canPromoteMembers: Boolean? = null,
|
||||||
|
canManageVideoChats: Boolean? = null,
|
||||||
|
canManageChat: Boolean? = null,
|
||||||
|
) = promoteChatAdministrator(
|
||||||
|
chat.id,
|
||||||
|
user.id,
|
||||||
|
untilDate,
|
||||||
|
isAnonymous,
|
||||||
|
canChangeInfo,
|
||||||
|
canDeleteMessages,
|
||||||
|
canInviteUsers,
|
||||||
|
canRestrictMembers,
|
||||||
|
canPromoteMembers,
|
||||||
|
canManageVideoChats,
|
||||||
|
canManageChat
|
||||||
|
)
|
||||||
@@ -1,14 +1,13 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.chat.members
|
package dev.inmo.tgbotapi.extensions.api.chat.members
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.common.Warning
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.chat.members.PromoteChatMember
|
import dev.inmo.tgbotapi.requests.chat.members.PromoteChatMember
|
||||||
import dev.inmo.tgbotapi.types.IdChatIdentifier
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.TelegramDate
|
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
|
||||||
import dev.inmo.tgbotapi.types.chat.PublicChat
|
import dev.inmo.tgbotapi.types.chat.PublicChat
|
||||||
import dev.inmo.tgbotapi.types.chat.User
|
import dev.inmo.tgbotapi.types.chat.User
|
||||||
|
|
||||||
|
@Warning("This method is too common. Use it with caution")
|
||||||
suspend fun TelegramBot.promoteChatMember(
|
suspend fun TelegramBot.promoteChatMember(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
userId: UserId,
|
userId: UserId,
|
||||||
@@ -24,27 +23,34 @@ suspend fun TelegramBot.promoteChatMember(
|
|||||||
canPromoteMembers: Boolean? = null,
|
canPromoteMembers: Boolean? = null,
|
||||||
canManageVideoChats: Boolean? = null,
|
canManageVideoChats: Boolean? = null,
|
||||||
canManageChat: Boolean? = null,
|
canManageChat: Boolean? = null,
|
||||||
canManageTopics: Boolean? = null
|
canManageTopics: Boolean? = null,
|
||||||
|
canPostStories: Boolean? = null,
|
||||||
|
canEditStories: Boolean? = null,
|
||||||
|
canDeleteStories: Boolean? = null
|
||||||
) = execute(
|
) = execute(
|
||||||
PromoteChatMember(
|
PromoteChatMember(
|
||||||
chatId,
|
chatId = chatId,
|
||||||
userId,
|
userId = userId,
|
||||||
untilDate,
|
untilDate = untilDate,
|
||||||
isAnonymous,
|
isAnonymous = isAnonymous,
|
||||||
canChangeInfo,
|
canChangeInfo = canChangeInfo,
|
||||||
canPostMessages,
|
canPostMessages = canPostMessages,
|
||||||
canEditMessages,
|
canEditMessages = canEditMessages,
|
||||||
canDeleteMessages,
|
canDeleteMessages = canDeleteMessages,
|
||||||
canInviteUsers,
|
canInviteUsers = canInviteUsers,
|
||||||
canRestrictMembers,
|
canRestrictMembers = canRestrictMembers,
|
||||||
canPinMessages,
|
canPinMessages = canPinMessages,
|
||||||
canPromoteMembers,
|
canPromoteMembers = canPromoteMembers,
|
||||||
canManageVideoChats,
|
canManageVideoChats = canManageVideoChats,
|
||||||
canManageChat,
|
canManageChat = canManageChat,
|
||||||
canManageTopics
|
canManageTopics = canManageTopics,
|
||||||
|
canPostStories = canPostStories,
|
||||||
|
canEditStories = canEditStories,
|
||||||
|
canDeleteStories = canDeleteStories
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@Warning("This method is too common. Use it with caution")
|
||||||
suspend fun TelegramBot.promoteChatMember(
|
suspend fun TelegramBot.promoteChatMember(
|
||||||
chat: PublicChat,
|
chat: PublicChat,
|
||||||
userId: UserId,
|
userId: UserId,
|
||||||
@@ -60,25 +66,32 @@ suspend fun TelegramBot.promoteChatMember(
|
|||||||
canPromoteMembers: Boolean? = null,
|
canPromoteMembers: Boolean? = null,
|
||||||
canManageVideoChats: Boolean? = null,
|
canManageVideoChats: Boolean? = null,
|
||||||
canManageChat: Boolean? = null,
|
canManageChat: Boolean? = null,
|
||||||
canManageTopics: Boolean? = null
|
canManageTopics: Boolean? = null,
|
||||||
|
canPostStories: Boolean? = null,
|
||||||
|
canEditStories: Boolean? = null,
|
||||||
|
canDeleteStories: Boolean? = null
|
||||||
) = promoteChatMember(
|
) = promoteChatMember(
|
||||||
chat.id,
|
chat.id,
|
||||||
userId,
|
userId,
|
||||||
untilDate,
|
untilDate = untilDate,
|
||||||
isAnonymous,
|
isAnonymous = isAnonymous,
|
||||||
canChangeInfo,
|
canChangeInfo = canChangeInfo,
|
||||||
canPostMessages,
|
canPostMessages = canPostMessages,
|
||||||
canEditMessages,
|
canEditMessages = canEditMessages,
|
||||||
canDeleteMessages,
|
canDeleteMessages = canDeleteMessages,
|
||||||
canInviteUsers,
|
canInviteUsers = canInviteUsers,
|
||||||
canRestrictMembers,
|
canRestrictMembers = canRestrictMembers,
|
||||||
canPinMessages,
|
canPinMessages = canPinMessages,
|
||||||
canPromoteMembers,
|
canPromoteMembers = canPromoteMembers,
|
||||||
canManageVideoChats,
|
canManageVideoChats = canManageVideoChats,
|
||||||
canManageChat,
|
canManageChat = canManageChat,
|
||||||
canManageTopics
|
canManageTopics = canManageTopics,
|
||||||
|
canPostStories = canPostStories,
|
||||||
|
canEditStories = canEditStories,
|
||||||
|
canDeleteStories = canDeleteStories
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@Warning("This method is too common. Use it with caution")
|
||||||
suspend fun TelegramBot.promoteChatMember(
|
suspend fun TelegramBot.promoteChatMember(
|
||||||
chatId: IdChatIdentifier,
|
chatId: IdChatIdentifier,
|
||||||
user: User,
|
user: User,
|
||||||
@@ -94,25 +107,32 @@ suspend fun TelegramBot.promoteChatMember(
|
|||||||
canPromoteMembers: Boolean? = null,
|
canPromoteMembers: Boolean? = null,
|
||||||
canManageVideoChats: Boolean? = null,
|
canManageVideoChats: Boolean? = null,
|
||||||
canManageChat: Boolean? = null,
|
canManageChat: Boolean? = null,
|
||||||
canManageTopics: Boolean? = null
|
canManageTopics: Boolean? = null,
|
||||||
|
canPostStories: Boolean? = null,
|
||||||
|
canEditStories: Boolean? = null,
|
||||||
|
canDeleteStories: Boolean? = null
|
||||||
) = promoteChatMember(
|
) = promoteChatMember(
|
||||||
chatId,
|
chatId,
|
||||||
user.id,
|
user.id,
|
||||||
untilDate,
|
untilDate = untilDate,
|
||||||
isAnonymous,
|
isAnonymous = isAnonymous,
|
||||||
canChangeInfo,
|
canChangeInfo = canChangeInfo,
|
||||||
canPostMessages,
|
canPostMessages = canPostMessages,
|
||||||
canEditMessages,
|
canEditMessages = canEditMessages,
|
||||||
canDeleteMessages,
|
canDeleteMessages = canDeleteMessages,
|
||||||
canInviteUsers,
|
canInviteUsers = canInviteUsers,
|
||||||
canRestrictMembers,
|
canRestrictMembers = canRestrictMembers,
|
||||||
canPinMessages,
|
canPinMessages = canPinMessages,
|
||||||
canPromoteMembers,
|
canPromoteMembers = canPromoteMembers,
|
||||||
canManageVideoChats,
|
canManageVideoChats = canManageVideoChats,
|
||||||
canManageChat,
|
canManageChat = canManageChat,
|
||||||
canManageTopics
|
canManageTopics = canManageTopics,
|
||||||
|
canPostStories = canPostStories,
|
||||||
|
canEditStories = canEditStories,
|
||||||
|
canDeleteStories = canDeleteStories
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@Warning("This method is too common. Use it with caution")
|
||||||
suspend fun TelegramBot.promoteChatMember(
|
suspend fun TelegramBot.promoteChatMember(
|
||||||
chat: PublicChat,
|
chat: PublicChat,
|
||||||
user: User,
|
user: User,
|
||||||
@@ -128,21 +148,27 @@ suspend fun TelegramBot.promoteChatMember(
|
|||||||
canPromoteMembers: Boolean? = null,
|
canPromoteMembers: Boolean? = null,
|
||||||
canManageVideoChats: Boolean? = null,
|
canManageVideoChats: Boolean? = null,
|
||||||
canManageChat: Boolean? = null,
|
canManageChat: Boolean? = null,
|
||||||
canManageTopics: Boolean? = null
|
canManageTopics: Boolean? = null,
|
||||||
|
canPostStories: Boolean? = null,
|
||||||
|
canEditStories: Boolean? = null,
|
||||||
|
canDeleteStories: Boolean? = null
|
||||||
) = promoteChatMember(
|
) = promoteChatMember(
|
||||||
chat.id,
|
chat.id,
|
||||||
user.id,
|
user.id,
|
||||||
untilDate,
|
untilDate = untilDate,
|
||||||
isAnonymous,
|
isAnonymous = isAnonymous,
|
||||||
canChangeInfo,
|
canChangeInfo = canChangeInfo,
|
||||||
canPostMessages,
|
canPostMessages = canPostMessages,
|
||||||
canEditMessages,
|
canEditMessages = canEditMessages,
|
||||||
canDeleteMessages,
|
canDeleteMessages = canDeleteMessages,
|
||||||
canInviteUsers,
|
canInviteUsers = canInviteUsers,
|
||||||
canRestrictMembers,
|
canRestrictMembers = canRestrictMembers,
|
||||||
canPinMessages,
|
canPinMessages = canPinMessages,
|
||||||
canPromoteMembers,
|
canPromoteMembers = canPromoteMembers,
|
||||||
canManageVideoChats,
|
canManageVideoChats = canManageVideoChats,
|
||||||
canManageChat,
|
canManageChat = canManageChat,
|
||||||
canManageTopics
|
canManageTopics = canManageTopics,
|
||||||
|
canPostStories = canPostStories,
|
||||||
|
canEditStories = canEditStories,
|
||||||
|
canDeleteStories = canDeleteStories
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,133 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.chat.members
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.chat.members.PromoteChatMember
|
||||||
|
import dev.inmo.tgbotapi.requests.chat.members.PromoteSupergroupAdministrator
|
||||||
|
import dev.inmo.tgbotapi.types.IdChatIdentifier
|
||||||
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
|
import dev.inmo.tgbotapi.types.TelegramDate
|
||||||
|
import dev.inmo.tgbotapi.types.UserId
|
||||||
|
import dev.inmo.tgbotapi.types.chat.PublicChat
|
||||||
|
import dev.inmo.tgbotapi.types.chat.User
|
||||||
|
|
||||||
|
suspend fun TelegramBot.promoteSupergroupAdministrator(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
userId: UserId,
|
||||||
|
untilDate: TelegramDate? = null,
|
||||||
|
isAnonymous: Boolean? = null,
|
||||||
|
canChangeInfo: Boolean? = null,
|
||||||
|
canDeleteMessages: Boolean? = null,
|
||||||
|
canInviteUsers: Boolean? = null,
|
||||||
|
canRestrictMembers: Boolean? = null,
|
||||||
|
canPinMessages: Boolean? = null,
|
||||||
|
canPromoteMembers: Boolean? = null,
|
||||||
|
canManageVideoChats: Boolean? = null,
|
||||||
|
canManageChat: Boolean? = null,
|
||||||
|
canManageTopics: Boolean? = null,
|
||||||
|
) = execute(
|
||||||
|
PromoteSupergroupAdministrator(
|
||||||
|
chatId = chatId,
|
||||||
|
userId = userId,
|
||||||
|
untilDate = untilDate,
|
||||||
|
isAnonymous = isAnonymous,
|
||||||
|
canChangeInfo = canChangeInfo,
|
||||||
|
canDeleteMessages = canDeleteMessages,
|
||||||
|
canInviteUsers = canInviteUsers,
|
||||||
|
canRestrictMembers = canRestrictMembers,
|
||||||
|
canPinMessages = canPinMessages,
|
||||||
|
canPromoteMembers = canPromoteMembers,
|
||||||
|
canManageVideoChats = canManageVideoChats,
|
||||||
|
canManageChat = canManageChat,
|
||||||
|
canManageTopics = canManageTopics
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.promoteSupergroupAdministrator(
|
||||||
|
chat: PublicChat,
|
||||||
|
userId: UserId,
|
||||||
|
untilDate: TelegramDate? = null,
|
||||||
|
isAnonymous: Boolean? = null,
|
||||||
|
canChangeInfo: Boolean? = null,
|
||||||
|
canDeleteMessages: Boolean? = null,
|
||||||
|
canInviteUsers: Boolean? = null,
|
||||||
|
canRestrictMembers: Boolean? = null,
|
||||||
|
canPinMessages: Boolean? = null,
|
||||||
|
canPromoteMembers: Boolean? = null,
|
||||||
|
canManageVideoChats: Boolean? = null,
|
||||||
|
canManageChat: Boolean? = null,
|
||||||
|
canManageTopics: Boolean? = null,
|
||||||
|
) = promoteSupergroupAdministrator(
|
||||||
|
chat.id,
|
||||||
|
userId,
|
||||||
|
untilDate = untilDate,
|
||||||
|
isAnonymous = isAnonymous,
|
||||||
|
canChangeInfo = canChangeInfo,
|
||||||
|
canDeleteMessages = canDeleteMessages,
|
||||||
|
canInviteUsers = canInviteUsers,
|
||||||
|
canRestrictMembers = canRestrictMembers,
|
||||||
|
canPinMessages = canPinMessages,
|
||||||
|
canPromoteMembers = canPromoteMembers,
|
||||||
|
canManageVideoChats = canManageVideoChats,
|
||||||
|
canManageChat = canManageChat,
|
||||||
|
canManageTopics = canManageTopics
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.promoteSupergroupAdministrator(
|
||||||
|
chatId: IdChatIdentifier,
|
||||||
|
user: User,
|
||||||
|
untilDate: TelegramDate? = null,
|
||||||
|
isAnonymous: Boolean? = null,
|
||||||
|
canChangeInfo: Boolean? = null,
|
||||||
|
canDeleteMessages: Boolean? = null,
|
||||||
|
canInviteUsers: Boolean? = null,
|
||||||
|
canRestrictMembers: Boolean? = null,
|
||||||
|
canPinMessages: Boolean? = null,
|
||||||
|
canPromoteMembers: Boolean? = null,
|
||||||
|
canManageVideoChats: Boolean? = null,
|
||||||
|
canManageChat: Boolean? = null,
|
||||||
|
canManageTopics: Boolean? = null,
|
||||||
|
) = promoteSupergroupAdministrator(
|
||||||
|
chatId,
|
||||||
|
user.id,
|
||||||
|
untilDate = untilDate,
|
||||||
|
isAnonymous = isAnonymous,
|
||||||
|
canChangeInfo = canChangeInfo,
|
||||||
|
canDeleteMessages = canDeleteMessages,
|
||||||
|
canInviteUsers = canInviteUsers,
|
||||||
|
canRestrictMembers = canRestrictMembers,
|
||||||
|
canPinMessages = canPinMessages,
|
||||||
|
canPromoteMembers = canPromoteMembers,
|
||||||
|
canManageVideoChats = canManageVideoChats,
|
||||||
|
canManageChat = canManageChat,
|
||||||
|
canManageTopics = canManageTopics
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.promoteSupergroupAdministrator(
|
||||||
|
chat: PublicChat,
|
||||||
|
user: User,
|
||||||
|
untilDate: TelegramDate? = null,
|
||||||
|
isAnonymous: Boolean? = null,
|
||||||
|
canChangeInfo: Boolean? = null,
|
||||||
|
canDeleteMessages: Boolean? = null,
|
||||||
|
canInviteUsers: Boolean? = null,
|
||||||
|
canRestrictMembers: Boolean? = null,
|
||||||
|
canPinMessages: Boolean? = null,
|
||||||
|
canPromoteMembers: Boolean? = null,
|
||||||
|
canManageVideoChats: Boolean? = null,
|
||||||
|
canManageChat: Boolean? = null,
|
||||||
|
canManageTopics: Boolean? = null,
|
||||||
|
) = promoteSupergroupAdministrator(
|
||||||
|
chat.id,
|
||||||
|
user.id,
|
||||||
|
untilDate = untilDate,
|
||||||
|
isAnonymous = isAnonymous,
|
||||||
|
canChangeInfo = canChangeInfo,
|
||||||
|
canDeleteMessages = canDeleteMessages,
|
||||||
|
canInviteUsers = canInviteUsers,
|
||||||
|
canRestrictMembers = canRestrictMembers,
|
||||||
|
canPinMessages = canPinMessages,
|
||||||
|
canPromoteMembers = canPromoteMembers,
|
||||||
|
canManageVideoChats = canManageVideoChats,
|
||||||
|
canManageChat = canManageChat,
|
||||||
|
canManageTopics = canManageTopics
|
||||||
|
)
|
||||||
@@ -62,6 +62,10 @@ suspend fun BehaviourContext.waitText(
|
|||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitContent(initRequest, errorFactory).mapContent<TextContent>()
|
) = waitContent(initRequest, errorFactory).mapContent<TextContent>()
|
||||||
|
suspend fun BehaviourContext.waitStory(
|
||||||
|
initRequest: Request<*>? = null,
|
||||||
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
|
) = waitContent(initRequest, errorFactory).mapContent<StoryContent>()
|
||||||
suspend fun BehaviourContext.waitVenue(
|
suspend fun BehaviourContext.waitVenue(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
|
|||||||
@@ -74,6 +74,10 @@ suspend fun BehaviourContext.waitTextMessage(
|
|||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitContentMessage(initRequest, errorFactory).mapWithContent<TextContent>()
|
) = waitContentMessage(initRequest, errorFactory).mapWithContent<TextContent>()
|
||||||
|
suspend fun BehaviourContext.waitStoryMessage(
|
||||||
|
initRequest: Request<*>? = null,
|
||||||
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
|
) = waitContentMessage(initRequest, errorFactory).mapWithContent<StoryContent>()
|
||||||
suspend fun BehaviourContext.waitVenueMessage(
|
suspend fun BehaviourContext.waitVenueMessage(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
|
|||||||
@@ -174,6 +174,25 @@ suspend fun BehaviourContext.waitWriteAccessAllowed(
|
|||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitEvents<WriteAccessAllowed>(initRequest, errorFactory)
|
) = waitEvents<WriteAccessAllowed>(initRequest, errorFactory)
|
||||||
|
suspend fun BehaviourContext.waitWriteAccessAllowedFromRequest(
|
||||||
|
initRequest: Request<*>? = null,
|
||||||
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
|
) = waitEvents<WriteAccessAllowed.FromRequest>(initRequest, errorFactory)
|
||||||
|
|
||||||
|
suspend fun BehaviourContext.waitWriteAccessAllowedFromAttachmentMenu(
|
||||||
|
initRequest: Request<*>? = null,
|
||||||
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
|
) = waitEvents<WriteAccessAllowed.FromAttachmentMenu>(initRequest, errorFactory)
|
||||||
|
|
||||||
|
suspend fun BehaviourContext.waitWriteAccessAllowedFromWebAppLink(
|
||||||
|
initRequest: Request<*>? = null,
|
||||||
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
|
) = waitEvents<WriteAccessAllowed.FromWebAppLink>(initRequest, errorFactory)
|
||||||
|
|
||||||
|
suspend fun BehaviourContext.waitWriteAccessAllowedOther(
|
||||||
|
initRequest: Request<*>? = null,
|
||||||
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
|
) = waitEvents<WriteAccessAllowed.Other>(initRequest, errorFactory)
|
||||||
|
|
||||||
suspend fun BehaviourContext.waitChatSharedRequest(
|
suspend fun BehaviourContext.waitChatSharedRequest(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
|
|||||||
@@ -171,6 +171,22 @@ suspend fun BehaviourContext.waitWriteAccessAllowedEventsMessages(
|
|||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitEventsMessages<WriteAccessAllowed>(initRequest, errorFactory)
|
) = waitEventsMessages<WriteAccessAllowed>(initRequest, errorFactory)
|
||||||
|
suspend fun BehaviourContext.waitWriteAccessAllowedFromRequestEventsMessages(
|
||||||
|
initRequest: Request<*>? = null,
|
||||||
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
|
) = waitEventsMessages<WriteAccessAllowed.FromRequest>(initRequest, errorFactory)
|
||||||
|
suspend fun BehaviourContext.waitWriteAccessAllowedFromAttachmentMenuEventsMessages(
|
||||||
|
initRequest: Request<*>? = null,
|
||||||
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
|
) = waitEventsMessages<WriteAccessAllowed.FromAttachmentMenu>(initRequest, errorFactory)
|
||||||
|
suspend fun BehaviourContext.waitWriteAccessAllowedFromWebAppLinkEventsMessages(
|
||||||
|
initRequest: Request<*>? = null,
|
||||||
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
|
) = waitEventsMessages<WriteAccessAllowed.FromWebAppLink>(initRequest, errorFactory)
|
||||||
|
suspend fun BehaviourContext.waitWriteAccessAllowedOtherEventsMessages(
|
||||||
|
initRequest: Request<*>? = null,
|
||||||
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
|
) = waitEventsMessages<WriteAccessAllowed.Other>(initRequest, errorFactory)
|
||||||
|
|
||||||
suspend fun BehaviourContext.waitChatSharedRequestEventsMessages(
|
suspend fun BehaviourContext.waitChatSharedRequestEventsMessages(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.filters
|
|||||||
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver
|
||||||
import dev.inmo.tgbotapi.extensions.utils.extensions.sourceChat
|
import dev.inmo.tgbotapi.extensions.utils.extensions.sourceChat
|
||||||
|
import dev.inmo.tgbotapi.extensions.utils.extensions.sourceUser
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery
|
import dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery
|
||||||
import dev.inmo.tgbotapi.types.chat.ChatJoinRequest
|
import dev.inmo.tgbotapi.types.chat.ChatJoinRequest
|
||||||
import dev.inmo.tgbotapi.types.chat.member.ChatMemberUpdated
|
import dev.inmo.tgbotapi.types.chat.member.ChatMemberUpdated
|
||||||
@@ -15,7 +16,9 @@ import dev.inmo.tgbotapi.types.update.abstracts.Update
|
|||||||
* Allow only events from the same chat as base [Message]
|
* Allow only events from the same chat as base [Message]
|
||||||
*/
|
*/
|
||||||
val MessageFilterByChat: BehaviourContextAndTwoTypesReceiver<Boolean, Message, Update> = { message, update ->
|
val MessageFilterByChat: BehaviourContextAndTwoTypesReceiver<Boolean, Message, Update> = { message, update ->
|
||||||
update.sourceChat() ?.id == message.chat.id
|
update.sourceChat() ?.let {
|
||||||
|
it.id == message.chat.id
|
||||||
|
} != false
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Allow only events from the same chat as base [List] of [Message]
|
* Allow only events from the same chat as base [List] of [Message]
|
||||||
@@ -29,31 +32,41 @@ val MessagesFilterByChat: BehaviourContextAndTwoTypesReceiver<Boolean, List<Mess
|
|||||||
* Allow only updates from the same user as base [CallbackQuery.user]
|
* Allow only updates from the same user as base [CallbackQuery.user]
|
||||||
*/
|
*/
|
||||||
val CallbackQueryFilterByUser: BehaviourContextAndTwoTypesReceiver<Boolean, CallbackQuery, Update> = { query, update ->
|
val CallbackQueryFilterByUser: BehaviourContextAndTwoTypesReceiver<Boolean, CallbackQuery, Update> = { query, update ->
|
||||||
update.sourceChat() ?.id == query.user.id
|
update.sourceUser() ?.let {
|
||||||
|
it.id == query.user.id
|
||||||
|
} != false
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Allow only updates from the same user as base [ShippingQuery.user]
|
* Allow only updates from the same user as base [ShippingQuery.user]
|
||||||
*/
|
*/
|
||||||
val ShippingQueryFilterByUser: BehaviourContextAndTwoTypesReceiver<Boolean, ShippingQuery, Update> = { query, update ->
|
val ShippingQueryFilterByUser: BehaviourContextAndTwoTypesReceiver<Boolean, ShippingQuery, Update> = { query, update ->
|
||||||
update.sourceChat() ?.id == query.user.id
|
update.sourceUser() ?.let {
|
||||||
|
it.id == query.user.id
|
||||||
|
} != false
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Allow only updates from the same user as base [ShippingQuery.user]
|
* Allow only updates from the same user as base [ShippingQuery.user]
|
||||||
*/
|
*/
|
||||||
val PreCheckoutQueryFilterByUser: BehaviourContextAndTwoTypesReceiver<Boolean, PreCheckoutQuery, Update> = { query, update ->
|
val PreCheckoutQueryFilterByUser: BehaviourContextAndTwoTypesReceiver<Boolean, PreCheckoutQuery, Update> = { query, update ->
|
||||||
update.sourceChat() ?.id == query.user.id
|
update.sourceUser() ?.let {
|
||||||
|
it.id == query.user.id
|
||||||
|
} != false
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Allow only updates from the same user as base [InlineQuery.from]
|
* Allow only updates from the same user as base [InlineQuery.from]
|
||||||
*/
|
*/
|
||||||
val InlineQueryFilterByUser: BehaviourContextAndTwoTypesReceiver<Boolean, InlineQuery, Update> = { query, update ->
|
val InlineQueryFilterByUser: BehaviourContextAndTwoTypesReceiver<Boolean, InlineQuery, Update> = { query, update ->
|
||||||
update.sourceChat() ?.id == query.from.id
|
update.sourceUser() ?.let {
|
||||||
|
it.id == query.user.id
|
||||||
|
} != false
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Allow only events from the same chat as base [ChatMemberUpdated]
|
* Allow only events from the same chat as base [ChatMemberUpdated]
|
||||||
*/
|
*/
|
||||||
val ChatMemberUpdatedFilterByChat: BehaviourContextAndTwoTypesReceiver<Boolean, ChatMemberUpdated, Update> = { updated, update ->
|
val ChatMemberUpdatedFilterByChat: BehaviourContextAndTwoTypesReceiver<Boolean, ChatMemberUpdated, Update> = { updated, update ->
|
||||||
update.sourceChat() ?.id == updated.chat.id
|
update.sourceChat() ?.let {
|
||||||
|
it.id == updated.chat.id
|
||||||
|
} != false
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Allow only events from the same chat as base [ChatMemberUpdated]
|
* Allow only events from the same chat as base [ChatMemberUpdated]
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
|
package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.ChatJoinRequestFilterByChat
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByChatChatJoinRequestMarkerFactory
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByChatChatJoinRequestMarkerFactory
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||||
@@ -25,7 +24,7 @@ import dev.inmo.tgbotapi.types.update.abstracts.Update
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onChatJoinRequest(
|
suspend fun <BC : BehaviourContext> BC.onChatJoinRequest(
|
||||||
initialFilter: SimpleFilter<ChatJoinRequest>? = null,
|
initialFilter: SimpleFilter<ChatJoinRequest>? = null,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatJoinRequest, Update>? = ChatJoinRequestFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatJoinRequest, Update>? = null,
|
||||||
markerFactory: MarkerFactory<in ChatJoinRequest, Any> = ByChatChatJoinRequestMarkerFactory,
|
markerFactory: MarkerFactory<in ChatJoinRequest, Any> = ByChatChatJoinRequestMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatJoinRequest>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatJoinRequest>
|
||||||
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
|
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ internal suspend fun <BC : BehaviourContext> BC.commandUncounted(
|
|||||||
commandRegex: Regex,
|
commandRegex: Regex,
|
||||||
requireOnlyCommandInMessage: Boolean = true,
|
requireOnlyCommandInMessage: Boolean = true,
|
||||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
||||||
): Job = onText(
|
): Job = onText(
|
||||||
@@ -49,7 +49,7 @@ suspend fun <BC : BehaviourContext> BC.command(
|
|||||||
commandRegex: Regex,
|
commandRegex: Regex,
|
||||||
requireOnlyCommandInMessage: Boolean = true,
|
requireOnlyCommandInMessage: Boolean = true,
|
||||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
||||||
): Job = runCatchingSafely {
|
): Job = runCatchingSafely {
|
||||||
@@ -78,7 +78,7 @@ suspend fun <BC : BehaviourContext> BC.command(
|
|||||||
command: String,
|
command: String,
|
||||||
requireOnlyCommandInMessage: Boolean = true,
|
requireOnlyCommandInMessage: Boolean = true,
|
||||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
||||||
) = command(command.toRegex(), requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
) = command(command.toRegex(), requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||||
@@ -87,7 +87,7 @@ suspend fun <BC : BehaviourContext> BC.command(
|
|||||||
botCommand: BotCommand,
|
botCommand: BotCommand,
|
||||||
requireOnlyCommandInMessage: Boolean = true,
|
requireOnlyCommandInMessage: Boolean = true,
|
||||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
||||||
) = command(botCommand.command, requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
) = command(botCommand.command, requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||||
@@ -96,7 +96,7 @@ suspend fun <BC : BehaviourContext> BC.onCommand(
|
|||||||
commandRegex: Regex,
|
commandRegex: Regex,
|
||||||
requireOnlyCommandInMessage: Boolean = true,
|
requireOnlyCommandInMessage: Boolean = true,
|
||||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
||||||
): Job = command(commandRegex, requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
): Job = command(commandRegex, requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||||
@@ -105,7 +105,7 @@ suspend fun <BC : BehaviourContext> BC.onCommand(
|
|||||||
command: String,
|
command: String,
|
||||||
requireOnlyCommandInMessage: Boolean = true,
|
requireOnlyCommandInMessage: Boolean = true,
|
||||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
||||||
): Job = onCommand(command.toRegex(), requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
): Job = onCommand(command.toRegex(), requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||||
@@ -114,7 +114,7 @@ suspend fun <BC : BehaviourContext> BC.onCommand(
|
|||||||
botCommand: BotCommand,
|
botCommand: BotCommand,
|
||||||
requireOnlyCommandInMessage: Boolean = true,
|
requireOnlyCommandInMessage: Boolean = true,
|
||||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
||||||
): Job = onCommand(botCommand.command, requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
): Job = onCommand(botCommand.command, requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||||
@@ -122,7 +122,7 @@ suspend fun <BC : BehaviourContext> BC.onCommand(
|
|||||||
suspend fun <BC : BehaviourContext> BC.commandWithArgs(
|
suspend fun <BC : BehaviourContext> BC.commandWithArgs(
|
||||||
commandRegex: Regex,
|
commandRegex: Regex,
|
||||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
|
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
|
||||||
) = command(
|
) = command(
|
||||||
@@ -142,7 +142,7 @@ suspend fun <BC : BehaviourContext> BC.commandWithArgs(
|
|||||||
suspend fun <BC : BehaviourContext> BC.commandWithArgs(
|
suspend fun <BC : BehaviourContext> BC.commandWithArgs(
|
||||||
command: String,
|
command: String,
|
||||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
|
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
|
||||||
) = commandWithArgs(
|
) = commandWithArgs(
|
||||||
@@ -156,7 +156,7 @@ suspend fun <BC : BehaviourContext> BC.commandWithArgs(
|
|||||||
suspend fun <BC : BehaviourContext> BC.commandWithArgs(
|
suspend fun <BC : BehaviourContext> BC.commandWithArgs(
|
||||||
botCommand: BotCommand,
|
botCommand: BotCommand,
|
||||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
|
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
|
||||||
) = commandWithArgs(
|
) = commandWithArgs(
|
||||||
@@ -170,7 +170,7 @@ suspend fun <BC : BehaviourContext> BC.commandWithArgs(
|
|||||||
suspend fun <BC : BehaviourContext> BC.onCommandWithArgs(
|
suspend fun <BC : BehaviourContext> BC.onCommandWithArgs(
|
||||||
commandRegex: Regex,
|
commandRegex: Regex,
|
||||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
|
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
|
||||||
): Job = commandWithArgs(commandRegex, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
): Job = commandWithArgs(commandRegex, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||||
@@ -178,7 +178,7 @@ suspend fun <BC : BehaviourContext> BC.onCommandWithArgs(
|
|||||||
suspend fun <BC : BehaviourContext> BC.onCommandWithArgs(
|
suspend fun <BC : BehaviourContext> BC.onCommandWithArgs(
|
||||||
command: String,
|
command: String,
|
||||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
|
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
|
||||||
): Job = onCommandWithArgs(command.toRegex(), initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
): Job = onCommandWithArgs(command.toRegex(), initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||||
@@ -186,7 +186,7 @@ suspend fun <BC : BehaviourContext> BC.onCommandWithArgs(
|
|||||||
suspend fun <BC : BehaviourContext> BC.onCommandWithArgs(
|
suspend fun <BC : BehaviourContext> BC.onCommandWithArgs(
|
||||||
botCommand: BotCommand,
|
botCommand: BotCommand,
|
||||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
|
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
|
||||||
): Job = onCommandWithArgs(botCommand.command, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
): Job = onCommandWithArgs(botCommand.command, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import kotlinx.coroutines.Job
|
|||||||
suspend fun <BC : BehaviourContext> BC.unhandledCommand(
|
suspend fun <BC : BehaviourContext> BC.unhandledCommand(
|
||||||
requireOnlyCommandInMessage: Boolean = true,
|
requireOnlyCommandInMessage: Boolean = true,
|
||||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
||||||
): Job = onText(
|
): Job = onText(
|
||||||
@@ -48,7 +48,7 @@ suspend fun <BC : BehaviourContext> BC.unhandledCommand(
|
|||||||
suspend fun <BC : BehaviourContext> BC.onUnhandledCommand(
|
suspend fun <BC : BehaviourContext> BC.onUnhandledCommand(
|
||||||
requireOnlyCommandInMessage: Boolean = true,
|
requireOnlyCommandInMessage: Boolean = true,
|
||||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
||||||
): Job = unhandledCommand(requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
): Job = unhandledCommand(requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||||
@@ -56,7 +56,7 @@ suspend fun <BC : BehaviourContext> BC.onUnhandledCommand(
|
|||||||
@PreviewFeature
|
@PreviewFeature
|
||||||
suspend fun <BC : BehaviourContext> BC.unhandledCommandWithArgs(
|
suspend fun <BC : BehaviourContext> BC.unhandledCommandWithArgs(
|
||||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Map<String, Array<String>>>
|
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Map<String, Array<String>>>
|
||||||
) = onUnhandledCommand(
|
) = onUnhandledCommand(
|
||||||
@@ -74,7 +74,7 @@ suspend fun <BC : BehaviourContext> BC.unhandledCommandWithArgs(
|
|||||||
@PreviewFeature
|
@PreviewFeature
|
||||||
suspend fun <BC : BehaviourContext> BC.onUnhandledCommandWithArgs(
|
suspend fun <BC : BehaviourContext> BC.onUnhandledCommandWithArgs(
|
||||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Map<String, Array<String>>>
|
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Map<String, Array<String>>>
|
||||||
): Job = unhandledCommandWithArgs(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
): Job = unhandledCommandWithArgs(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ internal suspend inline fun <BC : BehaviourContext, reified T : MessageContent>
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onContentMessage(
|
suspend fun <BC : BehaviourContext> BC.onContentMessage(
|
||||||
initialFilter: CommonMessageFilter<MessageContent>? = null,
|
initialFilter: CommonMessageFilter<MessageContent>? = null,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<MessageContent>, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<MessageContent>, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in CommonMessage<MessageContent>, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in CommonMessage<MessageContent>, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<MessageContent>>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<MessageContent>>
|
||||||
) = onContentMessageWithType(
|
) = onContentMessageWithType(
|
||||||
@@ -70,7 +70,7 @@ suspend fun <BC : BehaviourContext> BC.onContentMessage(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onContact(
|
suspend fun <BC : BehaviourContext> BC.onContact(
|
||||||
initialFilter: CommonMessageFilter<ContactContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<ContactContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ContactMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ContactMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in ContactMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in ContactMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ContactMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ContactMessage>
|
||||||
) = onContentMessageWithType(
|
) = onContentMessageWithType(
|
||||||
@@ -94,7 +94,7 @@ suspend fun <BC : BehaviourContext> BC.onContact(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onDice(
|
suspend fun <BC : BehaviourContext> BC.onDice(
|
||||||
initialFilter: CommonMessageFilter<DiceContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<DiceContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DiceMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DiceMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in DiceMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in DiceMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, DiceMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, DiceMessage>
|
||||||
) = onContentMessageWithType(
|
) = onContentMessageWithType(
|
||||||
@@ -118,7 +118,7 @@ suspend fun <BC : BehaviourContext> BC.onDice(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onGame(
|
suspend fun <BC : BehaviourContext> BC.onGame(
|
||||||
initialFilter: CommonMessageFilter<GameContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<GameContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, GameMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, GameMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in GameMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in GameMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, GameMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, GameMessage>
|
||||||
) = onContentMessageWithType(
|
) = onContentMessageWithType(
|
||||||
@@ -142,7 +142,7 @@ suspend fun <BC : BehaviourContext> BC.onGame(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onLocation(
|
suspend fun <BC : BehaviourContext> BC.onLocation(
|
||||||
initialFilter: CommonMessageFilter<LocationContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<LocationContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, LocationMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, LocationMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in LocationMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in LocationMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, LocationMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, LocationMessage>
|
||||||
) = onContentMessageWithType(
|
) = onContentMessageWithType(
|
||||||
@@ -166,7 +166,7 @@ suspend fun <BC : BehaviourContext> BC.onLocation(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onLiveLocation(
|
suspend fun <BC : BehaviourContext> BC.onLiveLocation(
|
||||||
initialFilter: CommonMessageFilter<LiveLocationContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<LiveLocationContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, LiveLocationMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, LiveLocationMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in LiveLocationMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in LiveLocationMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, LiveLocationMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, LiveLocationMessage>
|
||||||
) = onContentMessageWithType(
|
) = onContentMessageWithType(
|
||||||
@@ -190,7 +190,7 @@ suspend fun <BC : BehaviourContext> BC.onLiveLocation(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onStaticLocation(
|
suspend fun <BC : BehaviourContext> BC.onStaticLocation(
|
||||||
initialFilter: CommonMessageFilter<StaticLocationContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<StaticLocationContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, StaticLocationMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, StaticLocationMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in StaticLocationMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in StaticLocationMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, StaticLocationMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, StaticLocationMessage>
|
||||||
) = onContentMessageWithType(
|
) = onContentMessageWithType(
|
||||||
@@ -214,7 +214,7 @@ suspend fun <BC : BehaviourContext> BC.onStaticLocation(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onPoll(
|
suspend fun <BC : BehaviourContext> BC.onPoll(
|
||||||
initialFilter: CommonMessageFilter<PollContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<PollContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, PollMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, PollMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in PollMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in PollMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, PollMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, PollMessage>
|
||||||
) = onContentMessageWithType(
|
) = onContentMessageWithType(
|
||||||
@@ -238,7 +238,7 @@ suspend fun <BC : BehaviourContext> BC.onPoll(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onText(
|
suspend fun <BC : BehaviourContext> BC.onText(
|
||||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
||||||
) = onContentMessageWithType(
|
) = onContentMessageWithType(
|
||||||
@@ -248,6 +248,30 @@ suspend fun <BC : BehaviourContext> BC.onText(
|
|||||||
scenarioReceiver
|
scenarioReceiver
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||||
|
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||||
|
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||||
|
* to combinate several filters
|
||||||
|
* @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
|
||||||
|
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
|
||||||
|
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
|
||||||
|
* data
|
||||||
|
*/
|
||||||
|
suspend fun <BC : BehaviourContext> BC.onStory(
|
||||||
|
initialFilter: CommonMessageFilter<StoryContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, StoryMessage, Update>? = MessageFilterByChat,
|
||||||
|
markerFactory: MarkerFactory<in StoryMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, StoryMessage>
|
||||||
|
) = onContentMessageWithType(
|
||||||
|
initialFilter,
|
||||||
|
subcontextUpdatesFilter,
|
||||||
|
markerFactory,
|
||||||
|
scenarioReceiver
|
||||||
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||||
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||||
@@ -262,7 +286,7 @@ suspend fun <BC : BehaviourContext> BC.onText(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onTextedContent(
|
suspend fun <BC : BehaviourContext> BC.onTextedContent(
|
||||||
initialFilter: CommonMessageFilter<TextedContent>? = null,
|
initialFilter: CommonMessageFilter<TextedContent>? = null,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextedMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextedMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in TextedMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in TextedMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextedMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextedMessage>
|
||||||
) = onContentMessageWithType(
|
) = onContentMessageWithType(
|
||||||
@@ -286,7 +310,7 @@ suspend fun <BC : BehaviourContext> BC.onTextedContent(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onVenue(
|
suspend fun <BC : BehaviourContext> BC.onVenue(
|
||||||
initialFilter: CommonMessageFilter<VenueContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<VenueContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VenueMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VenueMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in VenueMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in VenueMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, VenueMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, VenueMessage>
|
||||||
) = onContentMessageWithType(
|
) = onContentMessageWithType(
|
||||||
@@ -310,7 +334,7 @@ suspend fun <BC : BehaviourContext> BC.onVenue(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onAudioMediaGroup(
|
suspend fun <BC : BehaviourContext> BC.onAudioMediaGroup(
|
||||||
initialFilter: CommonMessageFilter<AudioMediaGroupPartContent>? = null,
|
initialFilter: CommonMessageFilter<AudioMediaGroupPartContent>? = null,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, AudioMediaGroupMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, AudioMediaGroupMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in AudioMediaGroupMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in AudioMediaGroupMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, AudioMediaGroupMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, AudioMediaGroupMessage>
|
||||||
) = onContentMessageWithType(
|
) = onContentMessageWithType(
|
||||||
@@ -334,7 +358,7 @@ suspend fun <BC : BehaviourContext> BC.onAudioMediaGroup(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onDocumentMediaGroupContent(
|
suspend fun <BC : BehaviourContext> BC.onDocumentMediaGroupContent(
|
||||||
initialFilter: CommonMessageFilter<DocumentMediaGroupPartContent>? = null,
|
initialFilter: CommonMessageFilter<DocumentMediaGroupPartContent>? = null,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DocumentMediaGroupMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DocumentMediaGroupMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in DocumentMediaGroupMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in DocumentMediaGroupMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, DocumentMediaGroupMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, DocumentMediaGroupMessage>
|
||||||
) = onContentMessageWithType(
|
) = onContentMessageWithType(
|
||||||
@@ -358,7 +382,7 @@ suspend fun <BC : BehaviourContext> BC.onDocumentMediaGroupContent(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onTextedMediaContent(
|
suspend fun <BC : BehaviourContext> BC.onTextedMediaContent(
|
||||||
initialFilter: CommonMessageFilter<TextedMediaContent>? = null,
|
initialFilter: CommonMessageFilter<TextedMediaContent>? = null,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextedMediaMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextedMediaMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in TextedMediaMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in TextedMediaMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextedMediaMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextedMediaMessage>
|
||||||
) = onContentMessageWithType(
|
) = onContentMessageWithType(
|
||||||
@@ -382,7 +406,7 @@ suspend fun <BC : BehaviourContext> BC.onTextedMediaContent(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onMediaCollection(
|
suspend fun <BC : BehaviourContext> BC.onMediaCollection(
|
||||||
initialFilter: CommonMessageFilter<MediaCollectionContent<TelegramMediaFile>>? = null,
|
initialFilter: CommonMessageFilter<MediaCollectionContent<TelegramMediaFile>>? = null,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaCollectionMessage<TelegramMediaFile>, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaCollectionMessage<TelegramMediaFile>, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in MediaCollectionMessage<TelegramMediaFile>, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in MediaCollectionMessage<TelegramMediaFile>, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MediaCollectionMessage<TelegramMediaFile>>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MediaCollectionMessage<TelegramMediaFile>>
|
||||||
) = onContentMessageWithType(
|
) = onContentMessageWithType(
|
||||||
@@ -406,7 +430,7 @@ suspend fun <BC : BehaviourContext> BC.onMediaCollection(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onMedia(
|
suspend fun <BC : BehaviourContext> BC.onMedia(
|
||||||
initialFilter: CommonMessageFilter<MediaContent>? = null,
|
initialFilter: CommonMessageFilter<MediaContent>? = null,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in MediaMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in MediaMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MediaMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MediaMessage>
|
||||||
) = onContentMessageWithType(
|
) = onContentMessageWithType(
|
||||||
@@ -430,7 +454,7 @@ suspend fun <BC : BehaviourContext> BC.onMedia(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onAnimation(
|
suspend fun <BC : BehaviourContext> BC.onAnimation(
|
||||||
initialFilter: CommonMessageFilter<AnimationContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<AnimationContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, AnimationMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, AnimationMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in AnimationMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in AnimationMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, AnimationMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, AnimationMessage>
|
||||||
) = onContentMessageWithType(
|
) = onContentMessageWithType(
|
||||||
@@ -454,7 +478,7 @@ suspend fun <BC : BehaviourContext> BC.onAnimation(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onAudio(
|
suspend fun <BC : BehaviourContext> BC.onAudio(
|
||||||
initialFilter: CommonMessageFilter<AudioContent>? = null,
|
initialFilter: CommonMessageFilter<AudioContent>? = null,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, AudioMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, AudioMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in AudioMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in AudioMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, AudioMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, AudioMessage>
|
||||||
) = onContentMessageWithType(
|
) = onContentMessageWithType(
|
||||||
@@ -478,7 +502,7 @@ suspend fun <BC : BehaviourContext> BC.onAudio(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onDocument(
|
suspend fun <BC : BehaviourContext> BC.onDocument(
|
||||||
initialFilter: CommonMessageFilter<DocumentContent>? = null,
|
initialFilter: CommonMessageFilter<DocumentContent>? = null,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DocumentMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DocumentMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in DocumentMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in DocumentMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, DocumentMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, DocumentMessage>
|
||||||
) = onContentMessageWithType(
|
) = onContentMessageWithType(
|
||||||
@@ -502,7 +526,7 @@ suspend fun <BC : BehaviourContext> BC.onDocument(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onPhoto(
|
suspend fun <BC : BehaviourContext> BC.onPhoto(
|
||||||
initialFilter: CommonMessageFilter<PhotoContent>? = null,
|
initialFilter: CommonMessageFilter<PhotoContent>? = null,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, PhotoMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, PhotoMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in PhotoMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in PhotoMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, PhotoMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, PhotoMessage>
|
||||||
) = onContentMessageWithType(
|
) = onContentMessageWithType(
|
||||||
@@ -526,7 +550,7 @@ suspend fun <BC : BehaviourContext> BC.onPhoto(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onSticker(
|
suspend fun <BC : BehaviourContext> BC.onSticker(
|
||||||
initialFilter: CommonMessageFilter<StickerContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<StickerContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, StickerMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, StickerMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in StickerMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in StickerMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, StickerMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, StickerMessage>
|
||||||
) = onContentMessageWithType(
|
) = onContentMessageWithType(
|
||||||
@@ -550,7 +574,7 @@ suspend fun <BC : BehaviourContext> BC.onSticker(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onVideo(
|
suspend fun <BC : BehaviourContext> BC.onVideo(
|
||||||
initialFilter: CommonMessageFilter<VideoContent>? = null,
|
initialFilter: CommonMessageFilter<VideoContent>? = null,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VideoMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VideoMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in VideoMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in VideoMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, VideoMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, VideoMessage>
|
||||||
) = onContentMessageWithType(
|
) = onContentMessageWithType(
|
||||||
@@ -574,7 +598,7 @@ suspend fun <BC : BehaviourContext> BC.onVideo(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onVideoNote(
|
suspend fun <BC : BehaviourContext> BC.onVideoNote(
|
||||||
initialFilter: CommonMessageFilter<VideoNoteContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<VideoNoteContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VideoNoteMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VideoNoteMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in VideoNoteMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in VideoNoteMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, VideoNoteMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, VideoNoteMessage>
|
||||||
) = onContentMessageWithType(
|
) = onContentMessageWithType(
|
||||||
@@ -598,7 +622,7 @@ suspend fun <BC : BehaviourContext> BC.onVideoNote(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onVoice(
|
suspend fun <BC : BehaviourContext> BC.onVoice(
|
||||||
initialFilter: CommonMessageFilter<VoiceContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<VoiceContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VoiceMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VoiceMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in VoiceMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in VoiceMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, VoiceMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, VoiceMessage>
|
||||||
) = onContentMessageWithType(
|
) = onContentMessageWithType(
|
||||||
@@ -622,7 +646,7 @@ suspend fun <BC : BehaviourContext> BC.onVoice(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onInvoice(
|
suspend fun <BC : BehaviourContext> BC.onInvoice(
|
||||||
initialFilter: CommonMessageFilter<InvoiceContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<InvoiceContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, InvoiceMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, InvoiceMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in InvoiceMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in InvoiceMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, InvoiceMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, InvoiceMessage>
|
||||||
) = onContentMessageWithType(
|
) = onContentMessageWithType(
|
||||||
@@ -646,7 +670,7 @@ suspend fun <BC : BehaviourContext> BC.onInvoice(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onVisualContent(
|
suspend fun <BC : BehaviourContext> BC.onVisualContent(
|
||||||
initialFilter: CommonMessageFilter<VisualMediaGroupPartContent>? = null,
|
initialFilter: CommonMessageFilter<VisualMediaGroupPartContent>? = null,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VisualMediaGroupMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VisualMediaGroupMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in VisualMediaGroupMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in VisualMediaGroupMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, VisualMediaGroupMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, VisualMediaGroupMessage>
|
||||||
) = onContentMessageWithType(
|
) = onContentMessageWithType(
|
||||||
@@ -670,7 +694,7 @@ suspend fun <BC : BehaviourContext> BC.onVisualContent(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onMediaContent(
|
suspend fun <BC : BehaviourContext> BC.onMediaContent(
|
||||||
initialFilter: CommonMessageFilter<MediaContent>? = null,
|
initialFilter: CommonMessageFilter<MediaContent>? = null,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in MediaMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in MediaMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MediaMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MediaMessage>
|
||||||
) = onContentMessageWithType(
|
) = onContentMessageWithType(
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import kotlinx.coroutines.flow.filter
|
|||||||
private val startRegex = Regex("start")
|
private val startRegex = Regex("start")
|
||||||
suspend fun <BC : BehaviourContext> BC.onDeepLink(
|
suspend fun <BC : BehaviourContext> BC.onDeepLink(
|
||||||
initialFilter: SimpleFilter<Pair<TextMessage, String>>? = null,
|
initialFilter: SimpleFilter<Pair<TextMessage, String>>? = null,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, Pair<TextMessage, String>, Update> = { (message, _), update -> MessageFilterByChat(this, message, update) },
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, Pair<TextMessage, String>, Update>? = { (message, _), update -> MessageFilterByChat(this, message, update) },
|
||||||
markerFactory: MarkerFactory<Pair<TextMessage, String>, Any> = MarkerFactory { (message, _) -> ByChatMessageMarkerFactory(message) },
|
markerFactory: MarkerFactory<Pair<TextMessage, String>, Any> = MarkerFactory { (message, _) -> ByChatMessageMarkerFactory(message) },
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, Pair<TextMessage, String>>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, Pair<TextMessage, String>>
|
||||||
): Job = on(
|
): Job = on(
|
||||||
@@ -50,7 +50,7 @@ suspend fun <BC : BehaviourContext> BC.onDeepLink(
|
|||||||
suspend fun <BC : BehaviourContext> BC.onDeepLink(
|
suspend fun <BC : BehaviourContext> BC.onDeepLink(
|
||||||
regex: Regex,
|
regex: Regex,
|
||||||
initialFilter: SimpleFilter<Pair<TextMessage, String>>? = null,
|
initialFilter: SimpleFilter<Pair<TextMessage, String>>? = null,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, Pair<TextMessage, String>, Update> = { (message, _), update -> MessageFilterByChat(this, message, update) },
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, Pair<TextMessage, String>, Update>? = { (message, _), update -> MessageFilterByChat(this, message, update) },
|
||||||
markerFactory: MarkerFactory<Pair<TextMessage, String>, Any> = MarkerFactory { (message, _) -> ByChatMessageMarkerFactory(message) },
|
markerFactory: MarkerFactory<Pair<TextMessage, String>, Any> = MarkerFactory { (message, _) -> ByChatMessageMarkerFactory(message) },
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, Pair<TextMessage, String>>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, Pair<TextMessage, String>>
|
||||||
): Job {
|
): Job {
|
||||||
@@ -63,7 +63,7 @@ suspend fun <BC : BehaviourContext> BC.onDeepLink(
|
|||||||
suspend fun <BC : BehaviourContext> BC.onDeepLink(
|
suspend fun <BC : BehaviourContext> BC.onDeepLink(
|
||||||
deepLink: String,
|
deepLink: String,
|
||||||
initialFilter: SimpleFilter<Pair<TextMessage, String>>? = null,
|
initialFilter: SimpleFilter<Pair<TextMessage, String>>? = null,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, Pair<TextMessage, String>, Update> = { (message, _), update -> MessageFilterByChat(this, message, update) },
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, Pair<TextMessage, String>, Update>? = { (message, _), update -> MessageFilterByChat(this, message, update) },
|
||||||
markerFactory: MarkerFactory<Pair<TextMessage, String>, Any> = MarkerFactory { (message, _) -> ByChatMessageMarkerFactory(message) },
|
markerFactory: MarkerFactory<Pair<TextMessage, String>, Any> = MarkerFactory { (message, _) -> ByChatMessageMarkerFactory(message) },
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, Pair<TextMessage, String>>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, Pair<TextMessage, String>>
|
||||||
): Job = onDeepLink(Regex("^$deepLink$"), initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
): Job = onDeepLink(Regex("^$deepLink$"), initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ internal suspend inline fun <BC : BehaviourContext, reified T : MessageContent>
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onEditedContentMessage(
|
suspend fun <BC : BehaviourContext> BC.onEditedContentMessage(
|
||||||
initialFilter: CommonMessageFilter<MessageContent>? = null,
|
initialFilter: CommonMessageFilter<MessageContent>? = null,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<MessageContent>, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<MessageContent>, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in CommonMessage<MessageContent>, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in CommonMessage<MessageContent>, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<MessageContent>>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<MessageContent>>
|
||||||
)= onEditedContent(
|
)= onEditedContent(
|
||||||
@@ -64,7 +64,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedContentMessage(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onEditedContact(
|
suspend fun <BC : BehaviourContext> BC.onEditedContact(
|
||||||
initialFilter: CommonMessageFilter<ContactContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<ContactContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ContactMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ContactMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in ContactMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in ContactMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ContactMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ContactMessage>
|
||||||
)= onEditedContent(
|
)= onEditedContent(
|
||||||
@@ -88,7 +88,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedContact(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onEditedDice(
|
suspend fun <BC : BehaviourContext> BC.onEditedDice(
|
||||||
initialFilter: CommonMessageFilter<DiceContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<DiceContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DiceMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DiceMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in DiceMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in DiceMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, DiceMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, DiceMessage>
|
||||||
)= onEditedContent(
|
)= onEditedContent(
|
||||||
@@ -112,7 +112,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedDice(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onEditedGame(
|
suspend fun <BC : BehaviourContext> BC.onEditedGame(
|
||||||
initialFilter: CommonMessageFilter<GameContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<GameContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, GameMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, GameMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in GameMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in GameMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, GameMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, GameMessage>
|
||||||
)= onEditedContent(
|
)= onEditedContent(
|
||||||
@@ -136,7 +136,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedGame(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onEditedLocation(
|
suspend fun <BC : BehaviourContext> BC.onEditedLocation(
|
||||||
initialFilter: CommonMessageFilter<LocationContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<LocationContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, LocationMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, LocationMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in LocationMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in LocationMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, LocationMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, LocationMessage>
|
||||||
)= onEditedContent(
|
)= onEditedContent(
|
||||||
@@ -160,7 +160,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedLocation(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onEditedText(
|
suspend fun <BC : BehaviourContext> BC.onEditedText(
|
||||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
|
||||||
)= onEditedContent(
|
)= onEditedContent(
|
||||||
@@ -184,7 +184,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedText(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onEditedVenue(
|
suspend fun <BC : BehaviourContext> BC.onEditedVenue(
|
||||||
initialFilter: CommonMessageFilter<VenueContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<VenueContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VenueMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VenueMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in VenueMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in VenueMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, VenueMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, VenueMessage>
|
||||||
)= onEditedContent(
|
)= onEditedContent(
|
||||||
@@ -208,7 +208,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedVenue(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onEditedAudioMediaGroup(
|
suspend fun <BC : BehaviourContext> BC.onEditedAudioMediaGroup(
|
||||||
initialFilter: CommonMessageFilter<AudioMediaGroupPartContent>? = null,
|
initialFilter: CommonMessageFilter<AudioMediaGroupPartContent>? = null,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, AudioMediaGroupMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, AudioMediaGroupMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in AudioMediaGroupMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in AudioMediaGroupMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, AudioMediaGroupMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, AudioMediaGroupMessage>
|
||||||
)= onEditedContent(
|
)= onEditedContent(
|
||||||
@@ -232,7 +232,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedAudioMediaGroup(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onEditedDocumentMediaGroupContent(
|
suspend fun <BC : BehaviourContext> BC.onEditedDocumentMediaGroupContent(
|
||||||
initialFilter: CommonMessageFilter<DocumentMediaGroupPartContent>? = null,
|
initialFilter: CommonMessageFilter<DocumentMediaGroupPartContent>? = null,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DocumentMediaGroupMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DocumentMediaGroupMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in DocumentMediaGroupMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in DocumentMediaGroupMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, DocumentMediaGroupMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, DocumentMediaGroupMessage>
|
||||||
)= onEditedContent(
|
)= onEditedContent(
|
||||||
@@ -256,7 +256,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedDocumentMediaGroupContent(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onEditedTextedMediaContent(
|
suspend fun <BC : BehaviourContext> BC.onEditedTextedMediaContent(
|
||||||
initialFilter: CommonMessageFilter<TextedMediaContent>? = null,
|
initialFilter: CommonMessageFilter<TextedMediaContent>? = null,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextedMediaMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextedMediaMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in TextedMediaMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in TextedMediaMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextedMediaMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextedMediaMessage>
|
||||||
)= onEditedContent(
|
)= onEditedContent(
|
||||||
@@ -280,7 +280,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedTextedMediaContent(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onEditedMediaCollection(
|
suspend fun <BC : BehaviourContext> BC.onEditedMediaCollection(
|
||||||
initialFilter: CommonMessageFilter<MediaCollectionContent<TelegramMediaFile>>? = null,
|
initialFilter: CommonMessageFilter<MediaCollectionContent<TelegramMediaFile>>? = null,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaCollectionMessage<TelegramMediaFile>, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaCollectionMessage<TelegramMediaFile>, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in MediaCollectionMessage<TelegramMediaFile>, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in MediaCollectionMessage<TelegramMediaFile>, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MediaCollectionMessage<TelegramMediaFile>>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MediaCollectionMessage<TelegramMediaFile>>
|
||||||
)= onEditedContent(
|
)= onEditedContent(
|
||||||
@@ -304,7 +304,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedMediaCollection(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onEditedMedia(
|
suspend fun <BC : BehaviourContext> BC.onEditedMedia(
|
||||||
initialFilter: CommonMessageFilter<MediaContent>? = null,
|
initialFilter: CommonMessageFilter<MediaContent>? = null,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in MediaMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in MediaMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MediaMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MediaMessage>
|
||||||
)= onEditedContent(
|
)= onEditedContent(
|
||||||
@@ -328,7 +328,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedMedia(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onEditedAnimation(
|
suspend fun <BC : BehaviourContext> BC.onEditedAnimation(
|
||||||
initialFilter: CommonMessageFilter<AnimationContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<AnimationContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, AnimationMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, AnimationMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in AnimationMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in AnimationMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, AnimationMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, AnimationMessage>
|
||||||
)= onEditedContent(
|
)= onEditedContent(
|
||||||
@@ -352,7 +352,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedAnimation(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onEditedAudio(
|
suspend fun <BC : BehaviourContext> BC.onEditedAudio(
|
||||||
initialFilter: CommonMessageFilter<AudioContent>? = null,
|
initialFilter: CommonMessageFilter<AudioContent>? = null,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, AudioMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, AudioMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in AudioMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in AudioMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, AudioMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, AudioMessage>
|
||||||
)= onEditedContent(
|
)= onEditedContent(
|
||||||
@@ -376,7 +376,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedAudio(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onEditedDocument(
|
suspend fun <BC : BehaviourContext> BC.onEditedDocument(
|
||||||
initialFilter: CommonMessageFilter<DocumentContent>? = null,
|
initialFilter: CommonMessageFilter<DocumentContent>? = null,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DocumentMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DocumentMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in DocumentMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in DocumentMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, DocumentMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, DocumentMessage>
|
||||||
)= onEditedContent(
|
)= onEditedContent(
|
||||||
@@ -400,7 +400,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedDocument(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onEditedPhoto(
|
suspend fun <BC : BehaviourContext> BC.onEditedPhoto(
|
||||||
initialFilter: CommonMessageFilter<PhotoContent>? = null,
|
initialFilter: CommonMessageFilter<PhotoContent>? = null,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, PhotoMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, PhotoMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in PhotoMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in PhotoMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, PhotoMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, PhotoMessage>
|
||||||
)= onEditedContent(
|
)= onEditedContent(
|
||||||
@@ -424,7 +424,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedPhoto(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onEditedSticker(
|
suspend fun <BC : BehaviourContext> BC.onEditedSticker(
|
||||||
initialFilter: CommonMessageFilter<StickerContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<StickerContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, StickerMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, StickerMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in StickerMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in StickerMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, StickerMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, StickerMessage>
|
||||||
)= onEditedContent(
|
)= onEditedContent(
|
||||||
@@ -448,7 +448,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedSticker(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onEditedVideo(
|
suspend fun <BC : BehaviourContext> BC.onEditedVideo(
|
||||||
initialFilter: CommonMessageFilter<VideoContent>? = null,
|
initialFilter: CommonMessageFilter<VideoContent>? = null,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VideoMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VideoMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in VideoMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in VideoMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, VideoMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, VideoMessage>
|
||||||
)= onEditedContent(
|
)= onEditedContent(
|
||||||
@@ -472,7 +472,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedVideo(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onEditedVideoNote(
|
suspend fun <BC : BehaviourContext> BC.onEditedVideoNote(
|
||||||
initialFilter: CommonMessageFilter<VideoNoteContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<VideoNoteContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VideoNoteMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VideoNoteMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in VideoNoteMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in VideoNoteMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, VideoNoteMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, VideoNoteMessage>
|
||||||
)= onEditedContent(
|
)= onEditedContent(
|
||||||
@@ -496,7 +496,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedVideoNote(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onEditedVoice(
|
suspend fun <BC : BehaviourContext> BC.onEditedVoice(
|
||||||
initialFilter: CommonMessageFilter<VoiceContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<VoiceContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VoiceMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, VoiceMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in VoiceMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in VoiceMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, VoiceMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, VoiceMessage>
|
||||||
)= onEditedContent(
|
)= onEditedContent(
|
||||||
@@ -520,7 +520,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedVoice(
|
|||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onEditedInvoice(
|
suspend fun <BC : BehaviourContext> BC.onEditedInvoice(
|
||||||
initialFilter: CommonMessageFilter<InvoiceContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<InvoiceContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, InvoiceMessage, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, InvoiceMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in InvoiceMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in InvoiceMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, InvoiceMessage>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, InvoiceMessage>
|
||||||
)= onEditedContent(
|
)= onEditedContent(
|
||||||
|
|||||||
@@ -655,10 +655,90 @@ suspend fun <BC : BehaviourContext> BC.onGeneralForumTopicUnhidden(
|
|||||||
* data
|
* data
|
||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onWriteAccessAllowed(
|
suspend fun <BC : BehaviourContext> BC.onWriteAccessAllowed(
|
||||||
initialFilter: SimpleFilter<SupergroupEventMessage<WriteAccessAllowed>>? = null,
|
initialFilter: SimpleFilter<ChatEventMessage<WriteAccessAllowed>>? = null,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, SupergroupEventMessage<WriteAccessAllowed>, Update>? = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatEventMessage<WriteAccessAllowed>, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in ChatEventMessage<WriteAccessAllowed>, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in ChatEventMessage<WriteAccessAllowed>, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, SupergroupEventMessage<WriteAccessAllowed>>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatEventMessage<WriteAccessAllowed>>
|
||||||
|
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||||
|
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||||
|
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||||
|
* to combinate several filters
|
||||||
|
* @param markerFactory Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
|
||||||
|
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
|
||||||
|
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
|
||||||
|
* data
|
||||||
|
*/
|
||||||
|
suspend fun <BC : BehaviourContext> BC.onWriteAccessAllowedFromRequest(
|
||||||
|
initialFilter: SimpleFilter<ChatEventMessage<WriteAccessAllowed.FromRequest>>? = null,
|
||||||
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatEventMessage<WriteAccessAllowed.FromRequest>, Update>? = MessageFilterByChat,
|
||||||
|
markerFactory: MarkerFactory<in ChatEventMessage<WriteAccessAllowed.FromRequest>, Any> = ByChatMessageMarkerFactory,
|
||||||
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatEventMessage<WriteAccessAllowed.FromRequest>>
|
||||||
|
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||||
|
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||||
|
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||||
|
* to combinate several filters
|
||||||
|
* @param markerFactory Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
|
||||||
|
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
|
||||||
|
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
|
||||||
|
* data
|
||||||
|
*/
|
||||||
|
suspend fun <BC : BehaviourContext> BC.onWriteAccessAllowedFromAttachmentMenu(
|
||||||
|
initialFilter: SimpleFilter<ChatEventMessage<WriteAccessAllowed.FromAttachmentMenu>>? = null,
|
||||||
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatEventMessage<WriteAccessAllowed.FromAttachmentMenu>, Update>? = MessageFilterByChat,
|
||||||
|
markerFactory: MarkerFactory<in ChatEventMessage<WriteAccessAllowed.FromAttachmentMenu>, Any> = ByChatMessageMarkerFactory,
|
||||||
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatEventMessage<WriteAccessAllowed.FromAttachmentMenu>>
|
||||||
|
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||||
|
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||||
|
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||||
|
* to combinate several filters
|
||||||
|
* @param markerFactory Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
|
||||||
|
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
|
||||||
|
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
|
||||||
|
* data
|
||||||
|
*/
|
||||||
|
suspend fun <BC : BehaviourContext> BC.onWriteAccessAllowedOther(
|
||||||
|
initialFilter: SimpleFilter<ChatEventMessage<WriteAccessAllowed.Other>>? = null,
|
||||||
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatEventMessage<WriteAccessAllowed.Other>, Update>? = MessageFilterByChat,
|
||||||
|
markerFactory: MarkerFactory<in ChatEventMessage<WriteAccessAllowed.Other>, Any> = ByChatMessageMarkerFactory,
|
||||||
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatEventMessage<WriteAccessAllowed.Other>>
|
||||||
|
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||||
|
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||||
|
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||||
|
* to combinate several filters
|
||||||
|
* @param markerFactory Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
|
||||||
|
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
|
||||||
|
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
|
||||||
|
* data
|
||||||
|
*/
|
||||||
|
suspend fun <BC : BehaviourContext> BC.onWriteAccessAllowedFromWebAppLink(
|
||||||
|
initialFilter: SimpleFilter<ChatEventMessage<WriteAccessAllowed.FromWebAppLink>>? = null,
|
||||||
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatEventMessage<WriteAccessAllowed.FromWebAppLink>, Update>? = MessageFilterByChat,
|
||||||
|
markerFactory: MarkerFactory<in ChatEventMessage<WriteAccessAllowed.FromWebAppLink>, Any> = ByChatMessageMarkerFactory,
|
||||||
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatEventMessage<WriteAccessAllowed.FromWebAppLink>>
|
||||||
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ internal suspend inline fun <BC : BehaviourContext, reified T : InlineQuery> BC.
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||||
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
* @param subcontextUpdatesFilter **Default is [InlineQueryFilterByUser]]**. This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||||
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||||
@@ -40,7 +40,7 @@ suspend fun <BC : BehaviourContext> BC.onAnyInlineQuery(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||||
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
* @param subcontextUpdatesFilter **Default is [InlineQueryFilterByUser]]**. This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||||
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||||
@@ -60,7 +60,7 @@ suspend fun <BC : BehaviourContext> BC.onBaseInlineQuery(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||||
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
* @param subcontextUpdatesFilter **Default is [InlineQueryFilterByUser]]**. This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||||
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import dev.inmo.tgbotapi.types.chat.User
|
|||||||
*
|
*
|
||||||
* @see FromUser
|
* @see FromUser
|
||||||
*/
|
*/
|
||||||
@ClassCastsIncluded
|
@ClassCastsIncluded(excludeRegex = ".*Impl")
|
||||||
interface WithUser {
|
interface WithUser {
|
||||||
val user: User
|
val user: User
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package dev.inmo.tgbotapi.bot.ktor.base
|
|||||||
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
||||||
import dev.inmo.tgbotapi.bot.ktor.KtorCallFactory
|
import dev.inmo.tgbotapi.bot.ktor.KtorCallFactory
|
||||||
import dev.inmo.tgbotapi.bot.exceptions.newRequestException
|
import dev.inmo.tgbotapi.bot.exceptions.newRequestException
|
||||||
import dev.inmo.tgbotapi.requests.GetUpdates
|
import dev.inmo.tgbotapi.requests.GetUpdatesRequest
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
import dev.inmo.tgbotapi.types.Response
|
import dev.inmo.tgbotapi.types.Response
|
||||||
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
||||||
@@ -35,7 +35,7 @@ abstract class AbstractRequestCallFactory : KtorCallFactory {
|
|||||||
)
|
)
|
||||||
accept(ContentType.Application.Json)
|
accept(ContentType.Application.Json)
|
||||||
|
|
||||||
if (request is GetUpdates) {
|
if (request is GetUpdatesRequest) {
|
||||||
request.timeout?.times(1000L) ?.let { customTimeoutMillis ->
|
request.timeout?.times(1000L) ?.let { customTimeoutMillis ->
|
||||||
if (customTimeoutMillis > 0) {
|
if (customTimeoutMillis > 0) {
|
||||||
timeout {
|
timeout {
|
||||||
|
|||||||
@@ -22,13 +22,11 @@ private val updatesListSerializer = ListSerializer(
|
|||||||
*/
|
*/
|
||||||
@Serializable
|
@Serializable
|
||||||
data class GetUpdates(
|
data class GetUpdates(
|
||||||
val offset: UpdateIdentifier? = null,// set `last update id + 1` to receive next part of updates
|
override val offset: UpdateIdentifier? = null,// set `last update id + 1` to receive next part of updates
|
||||||
val limit: Int = getUpdatesLimit.last,
|
override val limit: Int = getUpdatesLimit.last,
|
||||||
val timeout: Seconds? = null,
|
override val timeout: Seconds? = null,
|
||||||
val allowed_updates: List<String>? = ALL_UPDATES_LIST
|
override val allowed_updates: List<String>? = ALL_UPDATES_LIST
|
||||||
): SimpleRequest<List<Update>> {
|
): GetUpdatesRequest<List<Update>> {
|
||||||
override fun method(): String = "getUpdates"
|
|
||||||
|
|
||||||
override val resultDeserializer: DeserializationStrategy<List<Update>>
|
override val resultDeserializer: DeserializationStrategy<List<Update>>
|
||||||
get() = updatesListSerializer
|
get() = updatesListSerializer
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package dev.inmo.tgbotapi.requests
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
|
import dev.inmo.tgbotapi.types.ALL_UPDATES_LIST
|
||||||
|
import dev.inmo.tgbotapi.types.Seconds
|
||||||
|
import dev.inmo.tgbotapi.types.UpdateIdentifier
|
||||||
|
import dev.inmo.tgbotapi.types.getUpdatesLimit
|
||||||
|
import kotlinx.serialization.DeserializationStrategy
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
import kotlinx.serialization.SerializationStrategy
|
||||||
|
import kotlinx.serialization.json.JsonArray
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Raw variant of [GetUpdates]. This type will be useful in case you wish to get some updates and handle them by
|
||||||
|
* yourself or with [dev.inmo.tgbotapi.utils.convertWithMediaGroupUpdates]
|
||||||
|
*/
|
||||||
|
@Serializable
|
||||||
|
data class GetUpdatesRaw(
|
||||||
|
override val offset: UpdateIdentifier? = null,// set `last update id + 1` to receive next part of updates
|
||||||
|
override val limit: Int = getUpdatesLimit.last,
|
||||||
|
override val timeout: Seconds? = null,
|
||||||
|
override val allowed_updates: List<String>? = ALL_UPDATES_LIST
|
||||||
|
): GetUpdatesRequest<JsonArray> {
|
||||||
|
override fun method(): String = "getUpdates"
|
||||||
|
|
||||||
|
override val resultDeserializer: DeserializationStrategy<JsonArray>
|
||||||
|
get() = JsonArray.serializer()
|
||||||
|
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
|
||||||
|
init {
|
||||||
|
if (limit !in getUpdatesLimit) {
|
||||||
|
error("GetUpdates request can be called only with limit in range $getUpdatesLimit (actual value is $limit)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package dev.inmo.tgbotapi.requests
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
|
import dev.inmo.tgbotapi.types.ALL_UPDATES_LIST
|
||||||
|
import dev.inmo.tgbotapi.types.Seconds
|
||||||
|
import dev.inmo.tgbotapi.types.UpdateIdentifier
|
||||||
|
import dev.inmo.tgbotapi.types.getUpdatesLimit
|
||||||
|
|
||||||
|
interface GetUpdatesRequest<T : Any> : SimpleRequest<T> {
|
||||||
|
val offset: UpdateIdentifier?
|
||||||
|
val limit: Int
|
||||||
|
val timeout: Seconds?
|
||||||
|
val allowed_updates: List<String>?
|
||||||
|
|
||||||
|
override fun method(): String = "getUpdates"
|
||||||
|
}
|
||||||
@@ -2,14 +2,14 @@ package dev.inmo.tgbotapi.requests.bot
|
|||||||
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.chat.member.ChatAdministratorRightsImpl
|
import dev.inmo.tgbotapi.types.chat.member.ChatCommonAdministratorRights
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.builtins.serializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
class SetMyDefaultAdministratorRights(
|
class SetMyDefaultAdministratorRights(
|
||||||
@SerialName(rightsField)
|
@SerialName(rightsField)
|
||||||
val rights: ChatAdministratorRightsImpl,
|
val rights: ChatCommonAdministratorRights,
|
||||||
@SerialName(forChannelsField)
|
@SerialName(forChannelsField)
|
||||||
val forChannels: Boolean? = null
|
val forChannels: Boolean? = null
|
||||||
) : SimpleRequest<Boolean> {
|
) : SimpleRequest<Boolean> {
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package dev.inmo.tgbotapi.requests.chat.forum
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class UnpinAllGeneralForumTopicMessages (
|
||||||
|
@SerialName(chatIdField)
|
||||||
|
override val chatId: ChatIdentifier,
|
||||||
|
): ModifyForumRequest {
|
||||||
|
override fun method(): String = "unpinAllGeneralForumTopicMessages"
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.requests.chat.members
|
package dev.inmo.tgbotapi.requests.chat.members
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.common.Warning
|
||||||
import dev.inmo.tgbotapi.abstracts.types.UntilDate
|
import dev.inmo.tgbotapi.abstracts.types.UntilDate
|
||||||
import dev.inmo.tgbotapi.requests.chat.abstracts.ChatMemberRequest
|
import dev.inmo.tgbotapi.requests.chat.abstracts.ChatMemberRequest
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
@@ -7,6 +8,7 @@ import kotlinx.serialization.*
|
|||||||
import kotlinx.serialization.builtins.serializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
@Warning("This method is too common. Use it with caution")
|
||||||
data class PromoteChatMember(
|
data class PromoteChatMember(
|
||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
override val chatId: ChatIdentifier,
|
override val chatId: ChatIdentifier,
|
||||||
@@ -37,7 +39,13 @@ data class PromoteChatMember(
|
|||||||
@SerialName(canManageChatField)
|
@SerialName(canManageChatField)
|
||||||
private val canManageChat: Boolean? = null,
|
private val canManageChat: Boolean? = null,
|
||||||
@SerialName(canManageTopicsField)
|
@SerialName(canManageTopicsField)
|
||||||
private val canManageTopics: Boolean? = null
|
private val canManageTopics: Boolean? = null,
|
||||||
|
@SerialName(canPostStoriesField)
|
||||||
|
private val canPostStories: Boolean? = null,
|
||||||
|
@SerialName(canEditStoriesField)
|
||||||
|
private val canEditStories: Boolean? = null,
|
||||||
|
@SerialName(canDeleteStoriesField)
|
||||||
|
private val canDeleteStories: Boolean? = null
|
||||||
) : ChatMemberRequest<Boolean>, UntilDate {
|
) : ChatMemberRequest<Boolean>, UntilDate {
|
||||||
override fun method(): String = "promoteChatMember"
|
override fun method(): String = "promoteChatMember"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
@@ -45,3 +53,109 @@ data class PromoteChatMember(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun PromoteChatMember(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
userId: UserId,
|
||||||
|
untilDate: TelegramDate? = null,
|
||||||
|
isAnonymous: Boolean? = null,
|
||||||
|
canChangeInfo: Boolean? = null,
|
||||||
|
canDeleteMessages: Boolean? = null,
|
||||||
|
canInviteUsers: Boolean? = null,
|
||||||
|
canRestrictMembers: Boolean? = null,
|
||||||
|
canPromoteMembers: Boolean? = null,
|
||||||
|
canManageVideoChats: Boolean? = null,
|
||||||
|
canManageChat: Boolean? = null,
|
||||||
|
) = PromoteChatMember(
|
||||||
|
chatId = chatId,
|
||||||
|
userId = userId,
|
||||||
|
untilDate = untilDate,
|
||||||
|
isAnonymous = isAnonymous,
|
||||||
|
canChangeInfo = canChangeInfo,
|
||||||
|
canPostMessages = null,
|
||||||
|
canEditMessages = null,
|
||||||
|
canDeleteMessages = canDeleteMessages,
|
||||||
|
canInviteUsers = canInviteUsers,
|
||||||
|
canRestrictMembers = canRestrictMembers,
|
||||||
|
canPinMessages = null,
|
||||||
|
canPromoteMembers = canPromoteMembers,
|
||||||
|
canManageVideoChats = canManageVideoChats,
|
||||||
|
canManageChat = canManageChat,
|
||||||
|
canManageTopics = null,
|
||||||
|
canPostStories = null,
|
||||||
|
canEditStories = null,
|
||||||
|
canDeleteStories = null
|
||||||
|
)
|
||||||
|
|
||||||
|
fun PromoteChannelAdministrator(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
userId: UserId,
|
||||||
|
untilDate: TelegramDate? = null,
|
||||||
|
isAnonymous: Boolean? = null,
|
||||||
|
canChangeInfo: Boolean? = null,
|
||||||
|
canPostMessages: Boolean? = null,
|
||||||
|
canEditMessages: Boolean? = null,
|
||||||
|
canDeleteMessages: Boolean? = null,
|
||||||
|
canInviteUsers: Boolean? = null,
|
||||||
|
canRestrictMembers: Boolean? = null,
|
||||||
|
canPromoteMembers: Boolean? = null,
|
||||||
|
canManageVideoChats: Boolean? = null,
|
||||||
|
canManageChat: Boolean? = null,
|
||||||
|
canPostStories: Boolean? = null,
|
||||||
|
canEditStories: Boolean? = null,
|
||||||
|
canDeleteStories: Boolean? = null
|
||||||
|
) = PromoteChatMember(
|
||||||
|
chatId = chatId,
|
||||||
|
userId = userId,
|
||||||
|
untilDate = untilDate,
|
||||||
|
isAnonymous = isAnonymous,
|
||||||
|
canChangeInfo = canChangeInfo,
|
||||||
|
canPostMessages = canPostMessages,
|
||||||
|
canEditMessages = canEditMessages,
|
||||||
|
canDeleteMessages = canDeleteMessages,
|
||||||
|
canInviteUsers = canInviteUsers,
|
||||||
|
canRestrictMembers = canRestrictMembers,
|
||||||
|
canPinMessages = null,
|
||||||
|
canPromoteMembers = canPromoteMembers,
|
||||||
|
canManageVideoChats = canManageVideoChats,
|
||||||
|
canManageChat = canManageChat,
|
||||||
|
canManageTopics = null,
|
||||||
|
canPostStories = canPostStories,
|
||||||
|
canEditStories = canEditStories,
|
||||||
|
canDeleteStories = canDeleteStories
|
||||||
|
)
|
||||||
|
|
||||||
|
fun PromoteSupergroupAdministrator(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
userId: UserId,
|
||||||
|
untilDate: TelegramDate? = null,
|
||||||
|
isAnonymous: Boolean? = null,
|
||||||
|
canChangeInfo: Boolean? = null,
|
||||||
|
canDeleteMessages: Boolean? = null,
|
||||||
|
canInviteUsers: Boolean? = null,
|
||||||
|
canRestrictMembers: Boolean? = null,
|
||||||
|
canPinMessages: Boolean? = null,
|
||||||
|
canPromoteMembers: Boolean? = null,
|
||||||
|
canManageVideoChats: Boolean? = null,
|
||||||
|
canManageChat: Boolean? = null,
|
||||||
|
canManageTopics: Boolean? = null,
|
||||||
|
) = PromoteChatMember(
|
||||||
|
chatId = chatId,
|
||||||
|
userId = userId,
|
||||||
|
untilDate = untilDate,
|
||||||
|
isAnonymous = isAnonymous,
|
||||||
|
canChangeInfo = canChangeInfo,
|
||||||
|
canPostMessages = null,
|
||||||
|
canEditMessages = null,
|
||||||
|
canDeleteMessages = canDeleteMessages,
|
||||||
|
canInviteUsers = canInviteUsers,
|
||||||
|
canRestrictMembers = canRestrictMembers,
|
||||||
|
canPinMessages = canPinMessages,
|
||||||
|
canPromoteMembers = canPromoteMembers,
|
||||||
|
canManageVideoChats = canManageVideoChats,
|
||||||
|
canManageChat = canManageChat,
|
||||||
|
canManageTopics = canManageTopics,
|
||||||
|
canPostStories = null,
|
||||||
|
canEditStories = null,
|
||||||
|
canDeleteStories = null
|
||||||
|
)
|
||||||
|
|||||||
@@ -177,6 +177,11 @@ val stickerKeywordLengthLimit = 0 .. 64
|
|||||||
|
|
||||||
const val botActionActualityTime: Seconds = 5
|
const val botActionActualityTime: Seconds = 5
|
||||||
|
|
||||||
|
val cloudStorageKeyLimit = 1 .. 128
|
||||||
|
val cloudStorageValueLimit = 0 .. 4096
|
||||||
|
val cloudStorageKeyRegex = Regex("[A-Za-z0-9_-]{${cloudStorageKeyLimit.first},${cloudStorageKeyLimit.last}}")
|
||||||
|
val cloudStorageValueRegex = Regex(".{${cloudStorageValueLimit.first},${cloudStorageValueLimit.last}}")
|
||||||
|
|
||||||
// Made as lazy for correct work in K/JS
|
// Made as lazy for correct work in K/JS
|
||||||
val telegramInlineModeGifPermittedMimeTypes by lazy {
|
val telegramInlineModeGifPermittedMimeTypes by lazy {
|
||||||
listOf(
|
listOf(
|
||||||
@@ -210,10 +215,12 @@ const val firstNameField = "first_name"
|
|||||||
const val lastNameField = "last_name"
|
const val lastNameField = "last_name"
|
||||||
const val languageCodeField = "language_code"
|
const val languageCodeField = "language_code"
|
||||||
const val addedToAttachmentMenuField = "added_to_attachment_menu"
|
const val addedToAttachmentMenuField = "added_to_attachment_menu"
|
||||||
|
const val allowsWriteToPMField = "allows_write_to_pm"
|
||||||
const val isPremiumField = "is_premium"
|
const val isPremiumField = "is_premium"
|
||||||
const val hasPrivateForwardsField = "has_private_forwards"
|
const val hasPrivateForwardsField = "has_private_forwards"
|
||||||
const val hasRestrictedVoiceAndVideoMessagesField = "has_restricted_voice_and_video_messages"
|
const val hasRestrictedVoiceAndVideoMessagesField = "has_restricted_voice_and_video_messages"
|
||||||
const val emojiStatusCustomEmojiIdField = "emoji_status_custom_emoji_id"
|
const val emojiStatusCustomEmojiIdField = "emoji_status_custom_emoji_id"
|
||||||
|
const val emojiStatusExpirationDateField = "emoji_status_expiration_date"
|
||||||
const val iconCustomEmojiIdField = "icon_custom_emoji_id"
|
const val iconCustomEmojiIdField = "icon_custom_emoji_id"
|
||||||
const val canJoinGroupsField = "can_join_groups"
|
const val canJoinGroupsField = "can_join_groups"
|
||||||
const val canReadAllGroupMessagesField = "can_read_all_group_messages"
|
const val canReadAllGroupMessagesField = "can_read_all_group_messages"
|
||||||
@@ -273,6 +280,9 @@ const val correctOptionIdField = "correct_option_id"
|
|||||||
const val allowsMultipleAnswersField = "allows_multiple_answers"
|
const val allowsMultipleAnswersField = "allows_multiple_answers"
|
||||||
const val isAnonymousField = "is_anonymous"
|
const val isAnonymousField = "is_anonymous"
|
||||||
const val canManageTopicsField = "can_manage_topics"
|
const val canManageTopicsField = "can_manage_topics"
|
||||||
|
const val canPostStoriesField = "can_post_stories"
|
||||||
|
const val canEditStoriesField = "can_edit_stories"
|
||||||
|
const val canDeleteStoriesField = "can_delete_stories"
|
||||||
const val captionEntitiesField = "caption_entities"
|
const val captionEntitiesField = "caption_entities"
|
||||||
const val hasSpoilerField = "has_spoiler"
|
const val hasSpoilerField = "has_spoiler"
|
||||||
const val loginUrlField = "login_url"
|
const val loginUrlField = "login_url"
|
||||||
@@ -289,6 +299,7 @@ const val pinnedMessageField = "pinned_message"
|
|||||||
const val activeUsernamesField = "active_usernames"
|
const val activeUsernamesField = "active_usernames"
|
||||||
const val customTitleField = "custom_title"
|
const val customTitleField = "custom_title"
|
||||||
const val optionIdsField = "option_ids"
|
const val optionIdsField = "option_ids"
|
||||||
|
const val voterChatField = "voter_chat"
|
||||||
const val ipAddressField = "ip_address"
|
const val ipAddressField = "ip_address"
|
||||||
const val linkedChatIdField = "linked_chat_id"
|
const val linkedChatIdField = "linked_chat_id"
|
||||||
const val hasHiddenMembersField = "has_hidden_members"
|
const val hasHiddenMembersField = "has_hidden_members"
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
|||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable(InlineQueryResultSerializer::class)
|
@Serializable(InlineQueryResultSerializer::class)
|
||||||
@ClassCastsIncluded
|
@ClassCastsIncluded(excludeRegex = ".*Impl")
|
||||||
interface InlineQueryResult {
|
interface InlineQueryResult {
|
||||||
val type: String
|
val type: String
|
||||||
val id: InlineQueryIdentifier
|
val id: InlineQueryIdentifier
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.types.buttons
|
|||||||
|
|
||||||
import dev.inmo.tgbotapi.types.botAdministratorRightsField
|
import dev.inmo.tgbotapi.types.botAdministratorRightsField
|
||||||
import dev.inmo.tgbotapi.types.botIsMemberField
|
import dev.inmo.tgbotapi.types.botIsMemberField
|
||||||
import dev.inmo.tgbotapi.types.chat.member.ChatAdministratorRights
|
import dev.inmo.tgbotapi.types.chat.member.ChatCommonAdministratorRights
|
||||||
import dev.inmo.tgbotapi.types.chatHasUsernameField
|
import dev.inmo.tgbotapi.types.chatHasUsernameField
|
||||||
import dev.inmo.tgbotapi.types.chatIsChannelField
|
import dev.inmo.tgbotapi.types.chatIsChannelField
|
||||||
import dev.inmo.tgbotapi.types.chatIsCreatedField
|
import dev.inmo.tgbotapi.types.chatIsCreatedField
|
||||||
@@ -30,9 +30,9 @@ data class KeyboardButtonRequestChat(
|
|||||||
@SerialName(chatIsCreatedField)
|
@SerialName(chatIsCreatedField)
|
||||||
val isOwnedBy: Boolean? = null,
|
val isOwnedBy: Boolean? = null,
|
||||||
@SerialName(userAdministratorRightsField)
|
@SerialName(userAdministratorRightsField)
|
||||||
val userRightsInChat: ChatAdministratorRights? = null,
|
val userRightsInChat: ChatCommonAdministratorRights? = null,
|
||||||
@SerialName(botAdministratorRightsField)
|
@SerialName(botAdministratorRightsField)
|
||||||
val botRightsInChat: ChatAdministratorRights? = null,
|
val botRightsInChat: ChatCommonAdministratorRights? = null,
|
||||||
@SerialName(botIsMemberField)
|
@SerialName(botIsMemberField)
|
||||||
val botIsMember: Boolean? = null
|
val botIsMember: Boolean? = null
|
||||||
) {
|
) {
|
||||||
@@ -41,8 +41,8 @@ data class KeyboardButtonRequestChat(
|
|||||||
requestId: RequestId,
|
requestId: RequestId,
|
||||||
isPublic: Boolean? = null,
|
isPublic: Boolean? = null,
|
||||||
isOwnedBy: Boolean? = null,
|
isOwnedBy: Boolean? = null,
|
||||||
userRightsInChat: ChatAdministratorRights? = null,
|
userRightsInChat: ChatCommonAdministratorRights? = null,
|
||||||
botRightsInChat: ChatAdministratorRights? = null,
|
botRightsInChat: ChatCommonAdministratorRights? = null,
|
||||||
botIsMember: Boolean? = null
|
botIsMember: Boolean? = null
|
||||||
) = KeyboardButtonRequestChat(
|
) = KeyboardButtonRequestChat(
|
||||||
requestId = requestId,
|
requestId = requestId,
|
||||||
@@ -60,8 +60,8 @@ data class KeyboardButtonRequestChat(
|
|||||||
isForum: Boolean? = null,
|
isForum: Boolean? = null,
|
||||||
isPublic: Boolean? = null,
|
isPublic: Boolean? = null,
|
||||||
isOwnedBy: Boolean? = null,
|
isOwnedBy: Boolean? = null,
|
||||||
userRightsInChat: ChatAdministratorRights? = null,
|
userRightsInChat: ChatCommonAdministratorRights? = null,
|
||||||
botRightsInChat: ChatAdministratorRights? = null,
|
botRightsInChat: ChatCommonAdministratorRights? = null,
|
||||||
botIsMember: Boolean? = null
|
botIsMember: Boolean? = null
|
||||||
) = KeyboardButtonRequestChat(
|
) = KeyboardButtonRequestChat(
|
||||||
requestId = requestId,
|
requestId = requestId,
|
||||||
|
|||||||
@@ -5,20 +5,14 @@ import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.*
|
|||||||
import dev.inmo.tgbotapi.types.webapps.WebAppInfo
|
import dev.inmo.tgbotapi.types.webapps.WebAppInfo
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and put [PayInlineKeyboardButton]
|
* Creates [PayInlineKeyboardButton]
|
||||||
*
|
|
||||||
* @see inlineKeyboard
|
|
||||||
* @see InlineKeyboardBuilder.row
|
|
||||||
*/
|
*/
|
||||||
inline fun payInlineButton(
|
inline fun payInlineButton(
|
||||||
text: String
|
text: String
|
||||||
) = PayInlineKeyboardButton(text)
|
) = PayInlineKeyboardButton(text)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and put [CallbackDataInlineKeyboardButton]
|
* Creates [CallbackDataInlineKeyboardButton]
|
||||||
*
|
|
||||||
* @see inlineKeyboard
|
|
||||||
* @see InlineKeyboardBuilder.row
|
|
||||||
*/
|
*/
|
||||||
inline fun dataInlineButton(
|
inline fun dataInlineButton(
|
||||||
text: String,
|
text: String,
|
||||||
@@ -26,20 +20,14 @@ inline fun dataInlineButton(
|
|||||||
) = CallbackDataInlineKeyboardButton(text, data)
|
) = CallbackDataInlineKeyboardButton(text, data)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and put [CallbackGameInlineKeyboardButton]
|
* Creates [CallbackGameInlineKeyboardButton]
|
||||||
*
|
|
||||||
* @see inlineKeyboard
|
|
||||||
* @see InlineKeyboardBuilder.row
|
|
||||||
*/
|
*/
|
||||||
inline fun gameInlineButton(
|
inline fun gameInlineButton(
|
||||||
text: String
|
text: String
|
||||||
) = CallbackGameInlineKeyboardButton(text)
|
) = CallbackGameInlineKeyboardButton(text)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and put [LoginURLInlineKeyboardButton]
|
* Creates [LoginURLInlineKeyboardButton]
|
||||||
*
|
|
||||||
* @see inlineKeyboard
|
|
||||||
* @see InlineKeyboardBuilder.row
|
|
||||||
*/
|
*/
|
||||||
inline fun loginInlineButton(
|
inline fun loginInlineButton(
|
||||||
text: String,
|
text: String,
|
||||||
@@ -47,10 +35,7 @@ inline fun loginInlineButton(
|
|||||||
) = LoginURLInlineKeyboardButton(text, loginUrl)
|
) = LoginURLInlineKeyboardButton(text, loginUrl)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and put [SwitchInlineQueryCurrentChatInlineKeyboardButton]
|
* Creates [SwitchInlineQueryCurrentChatInlineKeyboardButton]
|
||||||
*
|
|
||||||
* @see inlineKeyboard
|
|
||||||
* @see InlineKeyboardBuilder.row
|
|
||||||
*/
|
*/
|
||||||
inline fun inlineQueryInCurrentChatInlineButton(
|
inline fun inlineQueryInCurrentChatInlineButton(
|
||||||
text: String,
|
text: String,
|
||||||
@@ -58,10 +43,7 @@ inline fun inlineQueryInCurrentChatInlineButton(
|
|||||||
) = SwitchInlineQueryCurrentChatInlineKeyboardButton(text, data)
|
) = SwitchInlineQueryCurrentChatInlineKeyboardButton(text, data)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and put [SwitchInlineQueryChosenChatInlineKeyboardButton]
|
* Creates [SwitchInlineQueryChosenChatInlineKeyboardButton]
|
||||||
*
|
|
||||||
* @see inlineKeyboard
|
|
||||||
* @see InlineKeyboardBuilder.row
|
|
||||||
*/
|
*/
|
||||||
inline fun inlineQueryInCurrentChatInlineButton(
|
inline fun inlineQueryInCurrentChatInlineButton(
|
||||||
text: String,
|
text: String,
|
||||||
@@ -69,10 +51,7 @@ inline fun inlineQueryInCurrentChatInlineButton(
|
|||||||
) = SwitchInlineQueryChosenChatInlineKeyboardButton(text, parameters)
|
) = SwitchInlineQueryChosenChatInlineKeyboardButton(text, parameters)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and put [SwitchInlineQueryChosenChatInlineKeyboardButton]
|
* Creates [SwitchInlineQueryChosenChatInlineKeyboardButton]
|
||||||
*
|
|
||||||
* @see inlineKeyboard
|
|
||||||
* @see InlineKeyboardBuilder.row
|
|
||||||
*/
|
*/
|
||||||
inline fun inlineQueryInCurrentChatInlineButton(
|
inline fun inlineQueryInCurrentChatInlineButton(
|
||||||
text: String,
|
text: String,
|
||||||
@@ -93,10 +72,7 @@ inline fun inlineQueryInCurrentChatInlineButton(
|
|||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and put [SwitchInlineQueryChosenChatInlineKeyboardButton]
|
* Creates [SwitchInlineQueryChosenChatInlineKeyboardButton]
|
||||||
*
|
|
||||||
* @see inlineKeyboard
|
|
||||||
* @see InlineKeyboardBuilder.row
|
|
||||||
*/
|
*/
|
||||||
inline fun inlineQueryInAnyCurrentChatInlineButton(
|
inline fun inlineQueryInAnyCurrentChatInlineButton(
|
||||||
text: String,
|
text: String,
|
||||||
@@ -104,10 +80,7 @@ inline fun inlineQueryInAnyCurrentChatInlineButton(
|
|||||||
) = inlineQueryInCurrentChatInlineButton(text, query, allowUsers = true, allowBots = true, allowGroups = true, allowChannels = true)
|
) = inlineQueryInCurrentChatInlineButton(text, query, allowUsers = true, allowBots = true, allowGroups = true, allowChannels = true)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and put [SwitchInlineQueryInlineKeyboardButton]
|
* Creates [SwitchInlineQueryInlineKeyboardButton]
|
||||||
*
|
|
||||||
* @see inlineKeyboard
|
|
||||||
* @see InlineKeyboardBuilder.row
|
|
||||||
*/
|
*/
|
||||||
inline fun inlineQueryInlineButton(
|
inline fun inlineQueryInlineButton(
|
||||||
text: String,
|
text: String,
|
||||||
@@ -115,10 +88,7 @@ inline fun inlineQueryInlineButton(
|
|||||||
) = SwitchInlineQueryInlineKeyboardButton(text, data)
|
) = SwitchInlineQueryInlineKeyboardButton(text, data)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and put [URLInlineKeyboardButton]
|
* Creates [URLInlineKeyboardButton]
|
||||||
*
|
|
||||||
* @see inlineKeyboard
|
|
||||||
* @see InlineKeyboardBuilder.row
|
|
||||||
*/
|
*/
|
||||||
inline fun urlInlineButton(
|
inline fun urlInlineButton(
|
||||||
text: String,
|
text: String,
|
||||||
@@ -126,10 +96,7 @@ inline fun urlInlineButton(
|
|||||||
) = URLInlineKeyboardButton(text, url)
|
) = URLInlineKeyboardButton(text, url)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and put [WebAppInlineKeyboardButton]. Please, remember that this button is available in private chats only
|
* Creates [WebAppInlineKeyboardButton]. Please, remember that this button is available in private chats only
|
||||||
*
|
|
||||||
* @see inlineKeyboard
|
|
||||||
* @see InlineKeyboardBuilder.row
|
|
||||||
*/
|
*/
|
||||||
inline fun webAppInlineButton(
|
inline fun webAppInlineButton(
|
||||||
text: String,
|
text: String,
|
||||||
@@ -137,10 +104,7 @@ inline fun webAppInlineButton(
|
|||||||
) = WebAppInlineKeyboardButton(text, webApp)
|
) = WebAppInlineKeyboardButton(text, webApp)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and put [WebAppInlineKeyboardButton]. Please, remember that this button is available in private chats only
|
* Creates [WebAppInlineKeyboardButton]. Please, remember that this button is available in private chats only
|
||||||
*
|
|
||||||
* @see inlineKeyboard
|
|
||||||
* @see InlineKeyboardBuilder.row
|
|
||||||
*/
|
*/
|
||||||
inline fun webAppInlineButton(
|
inline fun webAppInlineButton(
|
||||||
text: String,
|
text: String,
|
||||||
|
|||||||
@@ -1,47 +1,34 @@
|
|||||||
package dev.inmo.tgbotapi.types.buttons.reply
|
package dev.inmo.tgbotapi.types.buttons.reply
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.buttons.*
|
import dev.inmo.tgbotapi.types.buttons.*
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.*
|
import dev.inmo.tgbotapi.types.chat.member.ChatCommonAdministratorRights
|
||||||
import dev.inmo.tgbotapi.types.chat.member.ChatAdministratorRights
|
|
||||||
import dev.inmo.tgbotapi.types.request.RequestId
|
import dev.inmo.tgbotapi.types.request.RequestId
|
||||||
import dev.inmo.tgbotapi.types.webapps.WebAppInfo
|
import dev.inmo.tgbotapi.types.webapps.WebAppInfo
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and put [SimpleKeyboardButton]
|
* Creates [SimpleKeyboardButton]
|
||||||
*
|
|
||||||
* @see replyKeyboard
|
|
||||||
* @see ReplyKeyboardBuilder.row
|
|
||||||
*/
|
*/
|
||||||
inline fun simpleReplyButton(
|
inline fun simpleReplyButton(
|
||||||
text: String
|
text: String
|
||||||
) = SimpleKeyboardButton(text)
|
) = SimpleKeyboardButton(text)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and put [RequestContactKeyboardButton]
|
* Creates [RequestContactKeyboardButton]
|
||||||
*
|
|
||||||
* @see replyKeyboard
|
|
||||||
* @see ReplyKeyboardBuilder.row
|
|
||||||
*/
|
*/
|
||||||
inline fun requestContactReplyButton(
|
inline fun requestContactReplyButton(
|
||||||
text: String
|
text: String
|
||||||
) = RequestContactKeyboardButton(text)
|
) = RequestContactKeyboardButton(text)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and put [RequestLocationKeyboardButton]
|
* Creates [RequestLocationKeyboardButton]
|
||||||
*
|
|
||||||
* @see replyKeyboard
|
|
||||||
* @see ReplyKeyboardBuilder.row
|
|
||||||
*/
|
*/
|
||||||
inline fun requestLocationReplyButton(
|
inline fun requestLocationReplyButton(
|
||||||
text: String
|
text: String
|
||||||
) = RequestLocationKeyboardButton(text)
|
) = RequestLocationKeyboardButton(text)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and put [RequestPollKeyboardButton]
|
* Creates [RequestPollKeyboardButton]
|
||||||
*
|
|
||||||
* @see replyKeyboard
|
|
||||||
* @see ReplyKeyboardBuilder.row
|
|
||||||
*/
|
*/
|
||||||
inline fun requestPollReplyButton(
|
inline fun requestPollReplyButton(
|
||||||
text: String,
|
text: String,
|
||||||
@@ -49,10 +36,7 @@ inline fun requestPollReplyButton(
|
|||||||
) = RequestPollKeyboardButton(text, pollType)
|
) = RequestPollKeyboardButton(text, pollType)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and put [WebAppKeyboardButton]
|
* Creates [WebAppKeyboardButton]
|
||||||
*
|
|
||||||
* @see replyKeyboard
|
|
||||||
* @see ReplyKeyboardBuilder.row
|
|
||||||
*/
|
*/
|
||||||
inline fun webAppReplyButton(
|
inline fun webAppReplyButton(
|
||||||
text: String,
|
text: String,
|
||||||
@@ -60,10 +44,7 @@ inline fun webAppReplyButton(
|
|||||||
) = WebAppKeyboardButton(text, webApp)
|
) = WebAppKeyboardButton(text, webApp)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and put [WebAppKeyboardButton]
|
* Creates [WebAppKeyboardButton]
|
||||||
*
|
|
||||||
* @see replyKeyboard
|
|
||||||
* @see ReplyKeyboardBuilder.row
|
|
||||||
*/
|
*/
|
||||||
inline fun webAppReplyButton(
|
inline fun webAppReplyButton(
|
||||||
text: String,
|
text: String,
|
||||||
@@ -72,10 +53,7 @@ inline fun webAppReplyButton(
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and put [RequestUserKeyboardButton]
|
* Creates [RequestUserKeyboardButton]
|
||||||
*
|
|
||||||
* @see replyKeyboard
|
|
||||||
* @see ReplyKeyboardBuilder.row
|
|
||||||
*/
|
*/
|
||||||
inline fun requestUserReplyButton(
|
inline fun requestUserReplyButton(
|
||||||
text: String,
|
text: String,
|
||||||
@@ -86,10 +64,7 @@ inline fun requestUserReplyButton(
|
|||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Bot]
|
* Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Bot]
|
||||||
*
|
|
||||||
* @see replyKeyboard
|
|
||||||
* @see ReplyKeyboardBuilder.row
|
|
||||||
*/
|
*/
|
||||||
inline fun requestBotReplyButton(
|
inline fun requestBotReplyButton(
|
||||||
text: String,
|
text: String,
|
||||||
@@ -100,10 +75,7 @@ inline fun requestBotReplyButton(
|
|||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Common]
|
* Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Common]
|
||||||
*
|
|
||||||
* @see replyKeyboard
|
|
||||||
* @see ReplyKeyboardBuilder.row
|
|
||||||
*/
|
*/
|
||||||
inline fun requestUserReplyButton(
|
inline fun requestUserReplyButton(
|
||||||
text: String,
|
text: String,
|
||||||
@@ -115,10 +87,7 @@ inline fun requestUserReplyButton(
|
|||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Any]
|
* Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Any]
|
||||||
*
|
|
||||||
* @see replyKeyboard
|
|
||||||
* @see ReplyKeyboardBuilder.row
|
|
||||||
*/
|
*/
|
||||||
inline fun requestUserOrBotReplyButton(
|
inline fun requestUserOrBotReplyButton(
|
||||||
text: String,
|
text: String,
|
||||||
@@ -130,10 +99,7 @@ inline fun requestUserOrBotReplyButton(
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and put [RequestChatKeyboardButton]
|
* Creates [RequestChatKeyboardButton]
|
||||||
*
|
|
||||||
* @see replyKeyboard
|
|
||||||
* @see ReplyKeyboardBuilder.row
|
|
||||||
*/
|
*/
|
||||||
inline fun requestChatReplyButton(
|
inline fun requestChatReplyButton(
|
||||||
text: String,
|
text: String,
|
||||||
@@ -144,10 +110,7 @@ inline fun requestChatReplyButton(
|
|||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and put [RequestChatKeyboardButton] with [KeyboardButtonRequestChat]
|
* Creates [RequestChatKeyboardButton] with [KeyboardButtonRequestChat]
|
||||||
*
|
|
||||||
* @see replyKeyboard
|
|
||||||
* @see ReplyKeyboardBuilder.row
|
|
||||||
*/
|
*/
|
||||||
inline fun requestChatReplyButton(
|
inline fun requestChatReplyButton(
|
||||||
text: String,
|
text: String,
|
||||||
@@ -156,8 +119,8 @@ inline fun requestChatReplyButton(
|
|||||||
isForum: Boolean? = null,
|
isForum: Boolean? = null,
|
||||||
isPublic: Boolean? = null,
|
isPublic: Boolean? = null,
|
||||||
isOwnedBy: Boolean? = null,
|
isOwnedBy: Boolean? = null,
|
||||||
userRightsInChat: ChatAdministratorRights? = null,
|
userRightsInChat: ChatCommonAdministratorRights? = null,
|
||||||
botRightsInChat: ChatAdministratorRights? = null,
|
botRightsInChat: ChatCommonAdministratorRights? = null,
|
||||||
botIsMember: Boolean = false
|
botIsMember: Boolean = false
|
||||||
) = requestChatReplyButton(
|
) = requestChatReplyButton(
|
||||||
text,
|
text,
|
||||||
@@ -174,18 +137,15 @@ inline fun requestChatReplyButton(
|
|||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and put [RequestChatKeyboardButton] with [KeyboardButtonRequestChat.Channel]
|
* Creates [RequestChatKeyboardButton] with [KeyboardButtonRequestChat.Channel]
|
||||||
*
|
|
||||||
* @see replyKeyboard
|
|
||||||
* @see ReplyKeyboardBuilder.row
|
|
||||||
*/
|
*/
|
||||||
inline fun requestChannelReplyButton(
|
inline fun requestChannelReplyButton(
|
||||||
text: String,
|
text: String,
|
||||||
requestId: RequestId,
|
requestId: RequestId,
|
||||||
isPublic: Boolean? = null,
|
isPublic: Boolean? = null,
|
||||||
isOwnedBy: Boolean? = null,
|
isOwnedBy: Boolean? = null,
|
||||||
userRightsInChat: ChatAdministratorRights? = null,
|
userRightsInChat: ChatCommonAdministratorRights? = null,
|
||||||
botRightsInChat: ChatAdministratorRights? = null,
|
botRightsInChat: ChatCommonAdministratorRights? = null,
|
||||||
botIsMember: Boolean = false
|
botIsMember: Boolean = false
|
||||||
) = requestChatReplyButton(
|
) = requestChatReplyButton(
|
||||||
text,
|
text,
|
||||||
@@ -201,10 +161,7 @@ inline fun requestChannelReplyButton(
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and put [RequestChatKeyboardButton] with [KeyboardButtonRequestChat.Group]
|
* Creates [RequestChatKeyboardButton] with [KeyboardButtonRequestChat.Group]
|
||||||
*
|
|
||||||
* @see replyKeyboard
|
|
||||||
* @see ReplyKeyboardBuilder.row
|
|
||||||
*/
|
*/
|
||||||
inline fun requestChannelReplyButton(
|
inline fun requestChannelReplyButton(
|
||||||
text: String,
|
text: String,
|
||||||
@@ -212,8 +169,8 @@ inline fun requestChannelReplyButton(
|
|||||||
isForum: Boolean? = null,
|
isForum: Boolean? = null,
|
||||||
isPublic: Boolean? = null,
|
isPublic: Boolean? = null,
|
||||||
isOwnedBy: Boolean? = null,
|
isOwnedBy: Boolean? = null,
|
||||||
userRightsInChat: ChatAdministratorRights? = null,
|
userRightsInChat: ChatCommonAdministratorRights? = null,
|
||||||
botRightsInChat: ChatAdministratorRights? = null,
|
botRightsInChat: ChatCommonAdministratorRights? = null,
|
||||||
botIsMember: Boolean? = null
|
botIsMember: Boolean? = null
|
||||||
) = requestChatReplyButton(
|
) = requestChatReplyButton(
|
||||||
text,
|
text,
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ sealed interface AbleToAddInAttachmentMenuChat : Chat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Serializable(PreviewChatSerializer::class)
|
@Serializable(PreviewChatSerializer::class)
|
||||||
@ClassCastsIncluded
|
@ClassCastsIncluded(excludeRegex = ".*Impl")
|
||||||
sealed interface Chat {
|
sealed interface Chat {
|
||||||
val id: IdChatIdentifier
|
val id: IdChatIdentifier
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,14 @@ package dev.inmo.tgbotapi.types.chat
|
|||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer
|
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer
|
||||||
|
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||||
|
import korlibs.time.DateTime
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.json.JsonObject
|
import kotlinx.serialization.json.JsonObject
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
@RiskFeature("This class is a subject of changes. It is better to use ExtendedChannelChat due")
|
||||||
data class ExtendedChannelChatImpl(
|
data class ExtendedChannelChatImpl(
|
||||||
@SerialName(idField)
|
@SerialName(idField)
|
||||||
override val id: ChatId,
|
override val id: ChatId,
|
||||||
@@ -33,6 +36,7 @@ data class ExtendedChannelChatImpl(
|
|||||||
) : ExtendedChannelChat
|
) : ExtendedChannelChat
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
@RiskFeature("This class is a subject of changes. It is better to use ExtendedGroupChat due")
|
||||||
data class ExtendedGroupChatImpl(
|
data class ExtendedGroupChatImpl(
|
||||||
@SerialName(idField)
|
@SerialName(idField)
|
||||||
override val id: ChatId,
|
override val id: ChatId,
|
||||||
@@ -54,6 +58,7 @@ data class ExtendedGroupChatImpl(
|
|||||||
) : ExtendedGroupChat
|
) : ExtendedGroupChat
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
@RiskFeature("This class is a subject of changes. It is better to use ExtendedPrivateChat due")
|
||||||
data class ExtendedPrivateChatImpl(
|
data class ExtendedPrivateChatImpl(
|
||||||
@SerialName(idField)
|
@SerialName(idField)
|
||||||
override val id: UserId,
|
override val id: UserId,
|
||||||
@@ -74,12 +79,15 @@ data class ExtendedPrivateChatImpl(
|
|||||||
@SerialName(hasRestrictedVoiceAndVideoMessagesField)
|
@SerialName(hasRestrictedVoiceAndVideoMessagesField)
|
||||||
override val hasRestrictedVoiceAndVideoMessages: Boolean = false,
|
override val hasRestrictedVoiceAndVideoMessages: Boolean = false,
|
||||||
@SerialName(emojiStatusCustomEmojiIdField)
|
@SerialName(emojiStatusCustomEmojiIdField)
|
||||||
override val statusEmojiId: CustomEmojiId? = null
|
override val statusEmojiId: CustomEmojiId? = null,
|
||||||
|
@SerialName(emojiStatusExpirationDateField)
|
||||||
|
override val statusEmojiExpiration: TelegramDate? = null
|
||||||
) : ExtendedPrivateChat
|
) : ExtendedPrivateChat
|
||||||
|
|
||||||
typealias ExtendedUser = ExtendedPrivateChatImpl
|
typealias ExtendedUser = ExtendedPrivateChatImpl
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
@RiskFeature("This class is a subject of changes. It is better to use ExtendedSupergroupChat due")
|
||||||
data class ExtendedSupergroupChatImpl(
|
data class ExtendedSupergroupChatImpl(
|
||||||
@SerialName(idField)
|
@SerialName(idField)
|
||||||
override val id: ChatId,
|
override val id: ChatId,
|
||||||
@@ -121,6 +129,7 @@ data class ExtendedSupergroupChatImpl(
|
|||||||
) : ExtendedSupergroupChat
|
) : ExtendedSupergroupChat
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
@RiskFeature("This class is a subject of changes. It is better to use ExtendedForumChat due")
|
||||||
data class ExtendedForumChatImpl(
|
data class ExtendedForumChatImpl(
|
||||||
@SerialName(idField)
|
@SerialName(idField)
|
||||||
override val id: IdChatIdentifier,
|
override val id: IdChatIdentifier,
|
||||||
@@ -164,12 +173,12 @@ data class ExtendedForumChatImpl(
|
|||||||
@Serializable
|
@Serializable
|
||||||
data class ExtendedBot(
|
data class ExtendedBot(
|
||||||
override val id: UserId,
|
override val id: UserId,
|
||||||
@SerialName(usernameField)
|
|
||||||
override val username: Username,
|
|
||||||
@SerialName(firstNameField)
|
@SerialName(firstNameField)
|
||||||
override val firstName: String,
|
override val firstName: String,
|
||||||
@SerialName(lastNameField)
|
@SerialName(lastNameField)
|
||||||
override val lastName: String = "",
|
override val lastName: String = "",
|
||||||
|
@SerialName(usernameField)
|
||||||
|
override val username: Username? = null,
|
||||||
@SerialName(canJoinGroupsField)
|
@SerialName(canJoinGroupsField)
|
||||||
val canJoinGroups: Boolean = false,
|
val canJoinGroups: Boolean = false,
|
||||||
@SerialName(canReadAllGroupMessagesField)
|
@SerialName(canReadAllGroupMessagesField)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.types.chat
|
|||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer
|
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer
|
||||||
|
import korlibs.time.DateTime
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable(ExtendedChatSerializer.Companion::class)
|
@Serializable(ExtendedChatSerializer.Companion::class)
|
||||||
@@ -21,6 +22,7 @@ sealed interface ExtendedPrivateChat : PrivateChat, ExtendedChatWithUsername {
|
|||||||
val hasPrivateForwards: Boolean
|
val hasPrivateForwards: Boolean
|
||||||
val hasRestrictedVoiceAndVideoMessages: Boolean
|
val hasRestrictedVoiceAndVideoMessages: Boolean
|
||||||
val statusEmojiId: CustomEmojiId?
|
val statusEmojiId: CustomEmojiId?
|
||||||
|
val statusEmojiExpiration: TelegramDate?
|
||||||
|
|
||||||
val allowCreateUserIdLink: Boolean
|
val allowCreateUserIdLink: Boolean
|
||||||
get() = hasPrivateForwards
|
get() = hasPrivateForwards
|
||||||
|
|||||||
@@ -4,10 +4,12 @@ import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
|||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
||||||
|
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
@RiskFeature("This class is a subject of changes. It is better to use GroupChat due")
|
||||||
data class GroupChatImpl(
|
data class GroupChatImpl(
|
||||||
@SerialName(idField)
|
@SerialName(idField)
|
||||||
override val id: ChatId,
|
override val id: ChatId,
|
||||||
@@ -16,6 +18,7 @@ data class GroupChatImpl(
|
|||||||
) : GroupChat
|
) : GroupChat
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
@RiskFeature("This class is a subject of changes. It is better to use PrivateChat due")
|
||||||
data class PrivateChatImpl(
|
data class PrivateChatImpl(
|
||||||
@SerialName(idField)
|
@SerialName(idField)
|
||||||
override val id: UserId,
|
override val id: UserId,
|
||||||
@@ -28,6 +31,7 @@ data class PrivateChatImpl(
|
|||||||
) : PrivateChat
|
) : PrivateChat
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
@RiskFeature("This class is a subject of changes. It is better to use SupergroupChat due")
|
||||||
data class SupergroupChatImpl(
|
data class SupergroupChatImpl(
|
||||||
@SerialName(idField)
|
@SerialName(idField)
|
||||||
override val id: ChatId,
|
override val id: ChatId,
|
||||||
@@ -38,6 +42,7 @@ data class SupergroupChatImpl(
|
|||||||
) : SupergroupChat
|
) : SupergroupChat
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
@RiskFeature("This class is a subject of changes. It is better to use ForumChat due")
|
||||||
data class ForumChatImpl(
|
data class ForumChatImpl(
|
||||||
@SerialName(idField)
|
@SerialName(idField)
|
||||||
override val id: IdChatIdentifier,
|
override val id: IdChatIdentifier,
|
||||||
@@ -48,6 +53,7 @@ data class ForumChatImpl(
|
|||||||
) : ForumChat
|
) : ForumChat
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
@RiskFeature("This class is a subject of changes. It is better to use ChannelChat due")
|
||||||
data class ChannelChatImpl(
|
data class ChannelChatImpl(
|
||||||
@SerialName(idField)
|
@SerialName(idField)
|
||||||
override val id: ChatId,
|
override val id: ChatId,
|
||||||
@@ -61,19 +67,17 @@ data class ChannelChatImpl(
|
|||||||
sealed class User : PrivateChat
|
sealed class User : PrivateChat
|
||||||
|
|
||||||
@Serializable(UserSerializer::class)
|
@Serializable(UserSerializer::class)
|
||||||
sealed class Bot : User() {
|
sealed class Bot : User()
|
||||||
abstract override val username: Username
|
|
||||||
}
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class CommonBot(
|
data class CommonBot(
|
||||||
override val id: UserId,
|
override val id: UserId,
|
||||||
@SerialName(usernameField)
|
|
||||||
override val username: Username,
|
|
||||||
@SerialName(firstNameField)
|
@SerialName(firstNameField)
|
||||||
override val firstName: String,
|
override val firstName: String,
|
||||||
@SerialName(lastNameField)
|
@SerialName(lastNameField)
|
||||||
override val lastName: String = ""
|
override val lastName: String = "",
|
||||||
|
@SerialName(usernameField)
|
||||||
|
override val username: Username? = null,
|
||||||
) : Bot() {
|
) : Bot() {
|
||||||
@SerialName(isBotField)
|
@SerialName(isBotField)
|
||||||
private val isBot = true
|
private val isBot = true
|
||||||
|
|||||||
@@ -35,9 +35,15 @@ data class AdministratorChatMemberImpl(
|
|||||||
@SerialName(customTitleField)
|
@SerialName(customTitleField)
|
||||||
override val customTitle: String? = null,
|
override val customTitle: String? = null,
|
||||||
@SerialName(canManageTopicsField)
|
@SerialName(canManageTopicsField)
|
||||||
override val canManageTopics: Boolean = false
|
override val canManageTopics: Boolean = false,
|
||||||
|
@SerialName(canPostStoriesField)
|
||||||
|
override val canPostStories: Boolean = false,
|
||||||
|
@SerialName(canEditStoriesField)
|
||||||
|
override val canEditStories: Boolean = false,
|
||||||
|
@SerialName(canDeleteStoriesField)
|
||||||
|
override val canDeleteStories: Boolean = false
|
||||||
) : AdministratorChatMember {
|
) : AdministratorChatMember {
|
||||||
@SerialName(statusField)
|
@SerialName(statusField)
|
||||||
@Required
|
@Required
|
||||||
private val type: String = "administrator"
|
override val status: ChatMember.Status = ChatMember.Status.Administrator
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,4 +16,43 @@ sealed interface ChatAdministratorRights : SpecialChatAdministratorRights {
|
|||||||
val canPromoteMembers: Boolean
|
val canPromoteMembers: Boolean
|
||||||
val canPostMessages: Boolean
|
val canPostMessages: Boolean
|
||||||
val canEditMessages: Boolean
|
val canEditMessages: Boolean
|
||||||
|
val canPostStories: Boolean
|
||||||
|
val canEditStories: Boolean
|
||||||
|
val canDeleteStories: Boolean
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
operator fun invoke(
|
||||||
|
canChangeInfo: Boolean = false,
|
||||||
|
canPostMessages: Boolean = false,
|
||||||
|
canEditMessages: Boolean = false,
|
||||||
|
canRemoveMessages: Boolean = false,
|
||||||
|
canInviteUsers: Boolean = false,
|
||||||
|
canRestrictMembers: Boolean = false,
|
||||||
|
canPinMessages: Boolean = false,
|
||||||
|
canPromoteMembers: Boolean = false,
|
||||||
|
canManageVideoChats: Boolean = false,
|
||||||
|
canManageChat: Boolean = false,
|
||||||
|
isAnonymous: Boolean = false,
|
||||||
|
canManageTopics: Boolean = false,
|
||||||
|
canPostStories: Boolean = false,
|
||||||
|
canEditStories: Boolean = false,
|
||||||
|
canDeleteStories: Boolean = false
|
||||||
|
) = ChatCommonAdministratorRights(
|
||||||
|
canChangeInfo = canChangeInfo,
|
||||||
|
canPostMessages = canPostMessages,
|
||||||
|
canEditMessages = canEditMessages,
|
||||||
|
canRemoveMessages = canRemoveMessages,
|
||||||
|
canInviteUsers = canInviteUsers,
|
||||||
|
canRestrictMembers = canRestrictMembers,
|
||||||
|
canPinMessages = canPinMessages,
|
||||||
|
canPromoteMembers = canPromoteMembers,
|
||||||
|
canManageVideoChats = canManageVideoChats,
|
||||||
|
canManageChat = canManageChat,
|
||||||
|
isAnonymous = isAnonymous,
|
||||||
|
canManageTopics = canManageTopics,
|
||||||
|
canPostStories = canPostStories,
|
||||||
|
canEditStories = canEditStories,
|
||||||
|
canDeleteStories = canDeleteStories
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import kotlinx.serialization.SerialName
|
|||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class ChatAdministratorRightsImpl(
|
data class ChatCommonAdministratorRights(
|
||||||
@SerialName(canChangeInfoField)
|
@SerialName(canChangeInfoField)
|
||||||
override val canChangeInfo: Boolean = false,
|
override val canChangeInfo: Boolean = false,
|
||||||
@SerialName(canPostMessagesField)
|
@SerialName(canPostMessagesField)
|
||||||
@@ -29,5 +29,20 @@ data class ChatAdministratorRightsImpl(
|
|||||||
@SerialName(isAnonymousField)
|
@SerialName(isAnonymousField)
|
||||||
override val isAnonymous: Boolean = false,
|
override val isAnonymous: Boolean = false,
|
||||||
@SerialName(canManageTopicsField)
|
@SerialName(canManageTopicsField)
|
||||||
override val canManageTopics: Boolean = false
|
override val canManageTopics: Boolean = false,
|
||||||
|
@SerialName(canPostStoriesField)
|
||||||
|
override val canPostStories: Boolean = false,
|
||||||
|
@SerialName(canEditStoriesField)
|
||||||
|
override val canEditStories: Boolean = false,
|
||||||
|
@SerialName(canDeleteStoriesField)
|
||||||
|
override val canDeleteStories: Boolean = false
|
||||||
) : ChatAdministratorRights
|
) : ChatAdministratorRights
|
||||||
|
|
||||||
|
@Deprecated(
|
||||||
|
"Renamed to ChatCommonAdministratorRights and will be removed soon",
|
||||||
|
ReplaceWith(
|
||||||
|
"ChatCommonAdministratorRights",
|
||||||
|
"dev.inmo.tgbotapi.types.chat.member.ChatCommonAdministratorRights"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
typealias ChatAdministratorRightsImpl = ChatCommonAdministratorRights
|
||||||
@@ -4,8 +4,10 @@ import dev.inmo.tgbotapi.abstracts.WithUser
|
|||||||
import dev.inmo.tgbotapi.types.statusField
|
import dev.inmo.tgbotapi.types.statusField
|
||||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||||
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
|
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
|
||||||
|
import kotlinx.serialization.DeserializationStrategy
|
||||||
import kotlinx.serialization.KSerializer
|
import kotlinx.serialization.KSerializer
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
import kotlinx.serialization.builtins.serializer
|
||||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||||
import kotlinx.serialization.encoding.Decoder
|
import kotlinx.serialization.encoding.Decoder
|
||||||
import kotlinx.serialization.encoding.Encoder
|
import kotlinx.serialization.encoding.Encoder
|
||||||
@@ -13,7 +15,38 @@ import kotlinx.serialization.json.JsonObject
|
|||||||
import kotlinx.serialization.json.jsonPrimitive
|
import kotlinx.serialization.json.jsonPrimitive
|
||||||
|
|
||||||
@Serializable(ChatMemberSerializer::class)
|
@Serializable(ChatMemberSerializer::class)
|
||||||
sealed interface ChatMember : WithUser
|
sealed interface ChatMember : WithUser {
|
||||||
|
@Serializable(StatusSerializer::class)
|
||||||
|
enum class Status(
|
||||||
|
val status: String,
|
||||||
|
val deserializationStrategy: DeserializationStrategy<ChatMember>
|
||||||
|
) {
|
||||||
|
Creator("creator", OwnerChatMember.serializer()),
|
||||||
|
Administrator("administrator", AdministratorChatMemberImpl.serializer()),
|
||||||
|
Member("member", MemberChatMemberImpl.serializer()),
|
||||||
|
Restricted("restricted", RestrictedChatMember.serializer()),
|
||||||
|
Left("left", LeftChatMemberImpl.serializer()),
|
||||||
|
Kicked("kicked", KickedChatMember.serializer())
|
||||||
|
}
|
||||||
|
|
||||||
|
object StatusSerializer : KSerializer<Status> {
|
||||||
|
override val descriptor: SerialDescriptor
|
||||||
|
get() = String.serializer().descriptor
|
||||||
|
|
||||||
|
override fun deserialize(decoder: Decoder): Status {
|
||||||
|
val status = decoder.decodeString()
|
||||||
|
return Status.values().first {
|
||||||
|
it.status == status
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun serialize(encoder: Encoder, value: Status) {
|
||||||
|
encoder.encodeString(value.status)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val status: Status
|
||||||
|
}
|
||||||
|
|
||||||
@RiskFeature
|
@RiskFeature
|
||||||
object ChatMemberSerializer : KSerializer<ChatMember> {
|
object ChatMemberSerializer : KSerializer<ChatMember> {
|
||||||
@@ -21,15 +54,14 @@ object ChatMemberSerializer : KSerializer<ChatMember> {
|
|||||||
|
|
||||||
override fun deserialize(decoder: Decoder): ChatMember {
|
override fun deserialize(decoder: Decoder): ChatMember {
|
||||||
val json = JsonObject.serializer().deserialize(decoder)
|
val json = JsonObject.serializer().deserialize(decoder)
|
||||||
return when (json[statusField] ?.jsonPrimitive ?.content ?: error("Status field of chat member must be specified, but incoming json contains next: $json")) {
|
val status = json[statusField] ?.jsonPrimitive ?.content ?: error("Status field of chat member must be specified, but incoming json contains next: $json")
|
||||||
"creator" -> nonstrictJsonFormat.decodeFromJsonElement(OwnerChatMember.serializer(), json)
|
return ChatMember.Status.values().firstNotNullOfOrNull {
|
||||||
"administrator" -> nonstrictJsonFormat.decodeFromJsonElement(AdministratorChatMemberImpl.serializer(), json)
|
if (it.status == status) {
|
||||||
"member" -> nonstrictJsonFormat.decodeFromJsonElement(MemberChatMemberImpl.serializer(), json)
|
nonstrictJsonFormat.decodeFromJsonElement(it.deserializationStrategy, json)
|
||||||
"restricted" -> nonstrictJsonFormat.decodeFromJsonElement(RestrictedChatMember.serializer(), json)
|
} else {
|
||||||
"left" -> nonstrictJsonFormat.decodeFromJsonElement(LeftChatMemberImpl.serializer(), json)
|
null
|
||||||
"kicked" -> nonstrictJsonFormat.decodeFromJsonElement(KickedChatMember.serializer(), json)
|
}
|
||||||
else -> error("Unknown type of chat member in json: $json")
|
} ?: error("Unknown type of chat member in json: $json")
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun serialize(encoder: Encoder, value: ChatMember) {
|
override fun serialize(encoder: Encoder, value: ChatMember) {
|
||||||
|
|||||||
@@ -13,5 +13,5 @@ data class KickedChatMember(
|
|||||||
) : BannedChatMember {
|
) : BannedChatMember {
|
||||||
@SerialName(statusField)
|
@SerialName(statusField)
|
||||||
@Required
|
@Required
|
||||||
private val type: String = "kicked"
|
override val status: ChatMember.Status = ChatMember.Status.Kicked
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,11 @@ import dev.inmo.tgbotapi.types.chat.User
|
|||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class LeftChatMemberImpl(@SerialName(userField) override val user: User) : LeftChatMember {
|
data class LeftChatMemberImpl(
|
||||||
|
@SerialName(userField)
|
||||||
|
override val user: User
|
||||||
|
) : LeftChatMember {
|
||||||
@SerialName(statusField)
|
@SerialName(statusField)
|
||||||
@Required
|
@Required
|
||||||
private val type: String = "left"
|
override val status: ChatMember.Status = ChatMember.Status.Left
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,11 @@ import dev.inmo.tgbotapi.types.chat.User
|
|||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class MemberChatMemberImpl(@SerialName(userField) override val user: User) : MemberChatMember {
|
data class MemberChatMemberImpl(
|
||||||
|
@SerialName(userField)
|
||||||
|
override val user: User
|
||||||
|
) : MemberChatMember {
|
||||||
@SerialName(statusField)
|
@SerialName(statusField)
|
||||||
@Required
|
@Required
|
||||||
private val type: String = "member"
|
override val status: ChatMember.Status = ChatMember.Status.Member
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,14 @@ data class OwnerChatMember(
|
|||||||
override val canManageChat: Boolean = true
|
override val canManageChat: Boolean = true
|
||||||
@Transient
|
@Transient
|
||||||
override val canManageTopics: Boolean = true
|
override val canManageTopics: Boolean = true
|
||||||
|
@Transient
|
||||||
|
override val canPostStories: Boolean = true
|
||||||
|
@Transient
|
||||||
|
override val canEditStories: Boolean = true
|
||||||
|
@Transient
|
||||||
|
override val canDeleteStories: Boolean = true
|
||||||
|
|
||||||
@SerialName(statusField)
|
@SerialName(statusField)
|
||||||
@Required
|
@Required
|
||||||
private val type: String = "creator"
|
override val status: ChatMember.Status = ChatMember.Status.Creator
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,5 +44,5 @@ data class RestrictedChatMember(
|
|||||||
) : BannedChatMember, SpecialRightsChatMember, ChatPermissions {
|
) : BannedChatMember, SpecialRightsChatMember, ChatPermissions {
|
||||||
@SerialName(statusField)
|
@SerialName(statusField)
|
||||||
@Required
|
@Required
|
||||||
private val type: String = "restricted"
|
override val status: ChatMember.Status = ChatMember.Status.Restricted
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,75 @@
|
|||||||
package dev.inmo.tgbotapi.types.message.ChatEvents.forum
|
package dev.inmo.tgbotapi.types.message.ChatEvents.forum
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChatEvent
|
||||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ForumEvent
|
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ForumEvent
|
||||||
|
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PrivateEvent
|
||||||
import dev.inmo.tgbotapi.types.webAppNameField
|
import dev.inmo.tgbotapi.types.webAppNameField
|
||||||
|
import kotlinx.serialization.KSerializer
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||||
|
import kotlinx.serialization.encoding.Decoder
|
||||||
|
import kotlinx.serialization.encoding.Encoder
|
||||||
|
|
||||||
@Serializable
|
@Serializable(WriteAccessAllowed.Companion::class)
|
||||||
data class WriteAccessAllowed(
|
sealed interface WriteAccessAllowed : PrivateEvent, ForumEvent {
|
||||||
@SerialName(webAppNameField)
|
val webAppName: String?
|
||||||
val webAppName: String? = null
|
get() = null
|
||||||
) : ForumEvent
|
val fromRequest: Boolean
|
||||||
|
get() = false
|
||||||
|
val fromAttachmentMenu: Boolean
|
||||||
|
get() = false
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
object Other : WriteAccessAllowed
|
||||||
|
@Serializable
|
||||||
|
data class FromWebAppLink(
|
||||||
|
override val webAppName: String
|
||||||
|
) : WriteAccessAllowed
|
||||||
|
@Serializable
|
||||||
|
object FromRequest : WriteAccessAllowed {
|
||||||
|
override val fromRequest: Boolean
|
||||||
|
get() = true
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
object FromAttachmentMenu : WriteAccessAllowed {
|
||||||
|
override val fromAttachmentMenu: Boolean
|
||||||
|
get() = true
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
private class WriteAccessAllowedRaw(
|
||||||
|
val web_app_name: String? = null,
|
||||||
|
val from_request: Boolean = false,
|
||||||
|
val from_attachment_menu: Boolean = false
|
||||||
|
)
|
||||||
|
|
||||||
|
companion object : KSerializer<WriteAccessAllowed> {
|
||||||
|
override val descriptor: SerialDescriptor
|
||||||
|
get() = WriteAccessAllowedRaw.serializer().descriptor
|
||||||
|
|
||||||
|
override fun deserialize(decoder: Decoder): WriteAccessAllowed {
|
||||||
|
val raw = WriteAccessAllowedRaw.serializer().deserialize(decoder)
|
||||||
|
|
||||||
|
return when {
|
||||||
|
raw.web_app_name != null -> FromWebAppLink(raw.web_app_name)
|
||||||
|
raw.from_request -> FromRequest
|
||||||
|
raw.from_attachment_menu -> Other
|
||||||
|
else -> Other
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun serialize(encoder: Encoder, value: WriteAccessAllowed) {
|
||||||
|
val raw = when (value) {
|
||||||
|
FromAttachmentMenu -> WriteAccessAllowedRaw(from_attachment_menu = true)
|
||||||
|
FromRequest -> WriteAccessAllowedRaw(from_request = true)
|
||||||
|
Other -> WriteAccessAllowedRaw()
|
||||||
|
is FromWebAppLink -> WriteAccessAllowedRaw(web_app_name = value.webAppName)
|
||||||
|
}
|
||||||
|
WriteAccessAllowedRaw.serializer().serialize(encoder, raw)
|
||||||
|
}
|
||||||
|
|
||||||
|
operator fun invoke(webAppName: String?): WriteAccessAllowed = webAppName ?.let(::FromWebAppLink) ?: Other
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import dev.inmo.tgbotapi.types.payments.SuccessfulPayment
|
|||||||
import dev.inmo.tgbotapi.types.polls.Poll
|
import dev.inmo.tgbotapi.types.polls.Poll
|
||||||
import dev.inmo.tgbotapi.types.request.ChatShared
|
import dev.inmo.tgbotapi.types.request.ChatShared
|
||||||
import dev.inmo.tgbotapi.types.request.UserShared
|
import dev.inmo.tgbotapi.types.request.UserShared
|
||||||
|
import dev.inmo.tgbotapi.types.stories.Story
|
||||||
import dev.inmo.tgbotapi.types.venue.Venue
|
import dev.inmo.tgbotapi.types.venue.Venue
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
@@ -65,6 +66,7 @@ internal data class RawMessage(
|
|||||||
private val caption: String? = null,
|
private val caption: String? = null,
|
||||||
private val caption_entities: RawMessageEntities? = null,
|
private val caption_entities: RawMessageEntities? = null,
|
||||||
private val has_media_spoiler: Boolean? = null,
|
private val has_media_spoiler: Boolean? = null,
|
||||||
|
private val story: Story? = null,
|
||||||
private val audio: AudioFile? = null,
|
private val audio: AudioFile? = null,
|
||||||
private val document: DocumentFile? = null,
|
private val document: DocumentFile? = null,
|
||||||
private val animation: AnimationFile? = null,
|
private val animation: AnimationFile? = null,
|
||||||
@@ -134,6 +136,11 @@ internal data class RawMessage(
|
|||||||
} ?: emptyList()
|
} ?: emptyList()
|
||||||
|
|
||||||
when {
|
when {
|
||||||
|
story != null -> StoryContent(
|
||||||
|
chat,
|
||||||
|
messageId,
|
||||||
|
story
|
||||||
|
)
|
||||||
text != null -> TextContent(text, (entities ?: emptyList()).asTextSources(text))
|
text != null -> TextContent(text, (entities ?: emptyList()).asTextSources(text))
|
||||||
audio != null -> AudioContent(
|
audio != null -> AudioContent(
|
||||||
audio,
|
audio,
|
||||||
|
|||||||
@@ -18,6 +18,30 @@ internal data class RawMessageEntity(
|
|||||||
internal val range by lazy {
|
internal val range by lazy {
|
||||||
offset until (offset + length)
|
offset until (offset + length)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val priority by lazy {
|
||||||
|
when (type) {
|
||||||
|
// Types with potential subsources should have priority
|
||||||
|
"mention" -> 0
|
||||||
|
"hashtag" -> 0
|
||||||
|
"cashtag" -> 0
|
||||||
|
"email" -> 0
|
||||||
|
"phone_number" -> 0
|
||||||
|
"bold" -> 0
|
||||||
|
"italic" -> 0
|
||||||
|
"text_mention" -> 0
|
||||||
|
"strikethrough" -> 0
|
||||||
|
"underline" -> 0
|
||||||
|
"spoiler" -> 0
|
||||||
|
"custom_emoji" -> 0
|
||||||
|
"bot_command" -> 1
|
||||||
|
"url" -> 1
|
||||||
|
"code" -> 1
|
||||||
|
"pre" -> 1
|
||||||
|
"text_link" -> 1
|
||||||
|
else -> 1
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun RawMessageEntity.asTextSource(
|
internal fun RawMessageEntity.asTextSource(
|
||||||
@@ -85,7 +109,10 @@ private fun createTextSources(
|
|||||||
originalFullString: String,
|
originalFullString: String,
|
||||||
entities: RawMessageEntities
|
entities: RawMessageEntities
|
||||||
): List<Pair<Int, TextSource>> {
|
): List<Pair<Int, TextSource>> {
|
||||||
val mutableEntities = entities.toMutableList().apply { sortBy { it.offset } }
|
val mutableEntities = entities.toMutableList().apply {
|
||||||
|
sortBy { it.priority } // sorting to fix potential issues in source sorting of entities
|
||||||
|
sortBy { it.offset }
|
||||||
|
}
|
||||||
val resultList = mutableListOf<Pair<Int, TextSource>>()
|
val resultList = mutableListOf<Pair<Int, TextSource>>()
|
||||||
|
|
||||||
while (mutableEntities.isNotEmpty()) {
|
while (mutableEntities.isNotEmpty()) {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import kotlinx.serialization.descriptors.*
|
|||||||
import kotlinx.serialization.encoding.Decoder
|
import kotlinx.serialization.encoding.Decoder
|
||||||
import kotlinx.serialization.encoding.Encoder
|
import kotlinx.serialization.encoding.Encoder
|
||||||
|
|
||||||
@ClassCastsIncluded
|
@ClassCastsIncluded(excludeRegex = ".*Impl")
|
||||||
interface Message : WithChat {
|
interface Message : WithChat {
|
||||||
val messageId: MessageId
|
val messageId: MessageId
|
||||||
val date: DateTime
|
val date: DateTime
|
||||||
|
|||||||
@@ -13,8 +13,10 @@ import dev.inmo.tgbotapi.types.media.TelegramMedia
|
|||||||
import dev.inmo.tgbotapi.types.message.abstracts.*
|
import dev.inmo.tgbotapi.types.message.abstracts.*
|
||||||
import dev.inmo.tgbotapi.types.threadId
|
import dev.inmo.tgbotapi.types.threadId
|
||||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.modules.*
|
import kotlinx.serialization.modules.*
|
||||||
|
|
||||||
|
@Serializable
|
||||||
sealed interface MessageContent: ResendableContent {
|
sealed interface MessageContent: ResendableContent {
|
||||||
companion object {
|
companion object {
|
||||||
@RiskFeature("This serialization module can be changed in near releases")
|
@RiskFeature("This serialization module can be changed in near releases")
|
||||||
@@ -49,6 +51,7 @@ sealed interface MessageContent: ResendableContent {
|
|||||||
subclass(AnimationContent::class)
|
subclass(AnimationContent::class)
|
||||||
subclass(StickerContent::class)
|
subclass(StickerContent::class)
|
||||||
subclass(InvoiceContent::class)
|
subclass(InvoiceContent::class)
|
||||||
|
subclass(StoryContent::class)
|
||||||
|
|
||||||
additionalBuilder()
|
additionalBuilder()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ sealed interface LocationContent : MessageContent {
|
|||||||
/**
|
/**
|
||||||
* [KSerializer] for [LocationContent]
|
* [KSerializer] for [LocationContent]
|
||||||
*/
|
*/
|
||||||
@Serializer(LocationContent::class)
|
|
||||||
object LocationContentSerializer : KSerializer<LocationContent> {
|
object LocationContentSerializer : KSerializer<LocationContent> {
|
||||||
override val descriptor: SerialDescriptor = buildClassSerialDescriptor("LocationContent") {
|
override val descriptor: SerialDescriptor = buildClassSerialDescriptor("LocationContent") {
|
||||||
element(LocationContent::location.name, LocationSerializer.descriptor)
|
element(LocationContent::location.name, LocationSerializer.descriptor)
|
||||||
@@ -85,7 +84,6 @@ object LocationContentSerializer : KSerializer<LocationContent> {
|
|||||||
encodeSerializableElement(descriptor, 0, LocationSerializer, value.location)
|
encodeSerializableElement(descriptor, 0, LocationSerializer, value.location)
|
||||||
}.endStructure(descriptor)
|
}.endStructure(descriptor)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -94,7 +92,7 @@ object LocationContentSerializer : KSerializer<LocationContent> {
|
|||||||
*
|
*
|
||||||
* @see dev.inmo.tgbotapi.extensions.behaviour_builder.utils.followLocation
|
* @see dev.inmo.tgbotapi.extensions.behaviour_builder.utils.followLocation
|
||||||
*/
|
*/
|
||||||
@Serializable(LocationContentSerializer::class)
|
@Serializable
|
||||||
data class LiveLocationContent(
|
data class LiveLocationContent(
|
||||||
override val location: LiveLocation
|
override val location: LiveLocation
|
||||||
) : LocationContent {
|
) : LocationContent {
|
||||||
@@ -127,7 +125,7 @@ data class LiveLocationContent(
|
|||||||
* Just a [LocationContent] with [StaticLocation] [location]. It could be [LiveLocationContent] in previous time in case
|
* Just a [LocationContent] with [StaticLocation] [location]. It could be [LiveLocationContent] in previous time in case
|
||||||
* when somebody has sent [LiveLocation] in chat and then stop to broadcast location
|
* when somebody has sent [LiveLocation] in chat and then stop to broadcast location
|
||||||
*/
|
*/
|
||||||
@Serializable(LocationContentSerializer::class)
|
@Serializable
|
||||||
data class StaticLocationContent(
|
data class StaticLocationContent(
|
||||||
override val location: StaticLocation
|
override val location: StaticLocation
|
||||||
) : LocationContent {
|
) : LocationContent {
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package dev.inmo.tgbotapi.types.message.content
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.requests.ForwardMessage
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
|
import dev.inmo.tgbotapi.types.MessageId
|
||||||
|
import dev.inmo.tgbotapi.types.MessageThreadId
|
||||||
|
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||||
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
|
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||||
|
import dev.inmo.tgbotapi.types.stories.Story
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class StoryContent(
|
||||||
|
private val chat: Chat,
|
||||||
|
private val messageId: MessageId,
|
||||||
|
val story: Story
|
||||||
|
) : MessageContent {
|
||||||
|
override fun createResend(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
messageThreadId: MessageThreadId?,
|
||||||
|
disableNotification: Boolean,
|
||||||
|
protectContent: Boolean,
|
||||||
|
replyToMessageId: MessageId?,
|
||||||
|
allowSendingWithoutReply: Boolean?,
|
||||||
|
replyMarkup: KeyboardMarkup?
|
||||||
|
): Request<out Message> {
|
||||||
|
return ForwardMessage(
|
||||||
|
chat.id,
|
||||||
|
toChatId = chatId,
|
||||||
|
messageId = messageId,
|
||||||
|
threadId = messageThreadId,
|
||||||
|
disableNotification = disableNotification,
|
||||||
|
protectContent = protectContent
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@ typealias DiceMessage = CommonMessage<DiceContent>
|
|||||||
typealias ContactMessage = CommonMessage<ContactContent>
|
typealias ContactMessage = CommonMessage<ContactContent>
|
||||||
typealias PollMessage = CommonMessage<PollContent>
|
typealias PollMessage = CommonMessage<PollContent>
|
||||||
typealias TextMessage = CommonMessage<TextContent>
|
typealias TextMessage = CommonMessage<TextContent>
|
||||||
|
typealias StoryMessage = CommonMessage<StoryContent>
|
||||||
|
|
||||||
typealias LocationMessage = CommonMessage<LocationContent>
|
typealias LocationMessage = CommonMessage<LocationContent>
|
||||||
typealias LiveLocationMessage = CommonMessage<LiveLocationContent>
|
typealias LiveLocationMessage = CommonMessage<LiveLocationContent>
|
||||||
|
|||||||
@@ -2,19 +2,95 @@ package dev.inmo.tgbotapi.types.polls
|
|||||||
|
|
||||||
import dev.inmo.tgbotapi.abstracts.FromUser
|
import dev.inmo.tgbotapi.abstracts.FromUser
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import dev.inmo.tgbotapi.types.chat.ChannelChat
|
||||||
|
import dev.inmo.tgbotapi.types.chat.CommonBot
|
||||||
import dev.inmo.tgbotapi.types.chat.User
|
import dev.inmo.tgbotapi.types.chat.User
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||||
|
import kotlinx.serialization.encoding.Decoder
|
||||||
|
import kotlinx.serialization.encoding.Encoder
|
||||||
|
|
||||||
@Serializable
|
@Serializable(PollAnswer.Companion::class)
|
||||||
data class PollAnswer(
|
sealed interface PollAnswer: FromUser {
|
||||||
@SerialName(pollIdField)
|
val pollId: PollIdentifier
|
||||||
val pollId: PollIdentifier,
|
override val user: User
|
||||||
@SerialName(userField)
|
|
||||||
override val user: User,
|
|
||||||
@SerialName(optionIdsField)
|
|
||||||
val chosen: List<Int>
|
val chosen: List<Int>
|
||||||
) : FromUser {
|
|
||||||
@Transient
|
@Transient
|
||||||
override val from: User
|
override val from: User
|
||||||
get() = user
|
get() = user
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class Public(
|
||||||
|
@SerialName(pollIdField)
|
||||||
|
override val pollId: PollIdentifier,
|
||||||
|
@SerialName(userField)
|
||||||
|
override val user: User,
|
||||||
|
@SerialName(optionIdsField)
|
||||||
|
override val chosen: List<Int>,
|
||||||
|
) : PollAnswer
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class Anonymous(
|
||||||
|
@SerialName(pollIdField)
|
||||||
|
override val pollId: PollIdentifier,
|
||||||
|
@SerialName(voterChatField)
|
||||||
|
val voterChat: ChannelChat,
|
||||||
|
@SerialName(optionIdsField)
|
||||||
|
override val chosen: List<Int>
|
||||||
|
) : PollAnswer {
|
||||||
|
@SerialName(userField)
|
||||||
|
override val user: User = defaultUser
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
val defaultUser = CommonBot(
|
||||||
|
UserId(136817688L),
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
Username("@Channel_Bot")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object : KSerializer<PollAnswer> {
|
||||||
|
@Serializable
|
||||||
|
private data class PollAnswerSurrogate(
|
||||||
|
@SerialName(pollIdField)
|
||||||
|
val pollId: PollIdentifier,
|
||||||
|
@SerialName(optionIdsField)
|
||||||
|
val chosen: List<Int>,
|
||||||
|
@SerialName(userField)
|
||||||
|
val user: User = Anonymous.defaultUser,
|
||||||
|
@SerialName(voterChatField)
|
||||||
|
val voterChat: ChannelChat? = null
|
||||||
|
)
|
||||||
|
operator fun invoke(
|
||||||
|
pollId: PollIdentifier,
|
||||||
|
user: User,
|
||||||
|
chosen: List<Int>,
|
||||||
|
) = Public(pollId, user, chosen)
|
||||||
|
|
||||||
|
override val descriptor: SerialDescriptor
|
||||||
|
get() = PollAnswerSurrogate.serializer().descriptor
|
||||||
|
|
||||||
|
override fun deserialize(decoder: Decoder): PollAnswer {
|
||||||
|
val surrogate = PollAnswerSurrogate.serializer().deserialize(decoder)
|
||||||
|
return if (surrogate.voterChat != null) {
|
||||||
|
Anonymous(surrogate.pollId, surrogate.voterChat, surrogate.chosen)
|
||||||
|
} else {
|
||||||
|
Public(surrogate.pollId, surrogate.user, surrogate.chosen)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun serialize(encoder: Encoder, value: PollAnswer) {
|
||||||
|
PollAnswerSurrogate.serializer().serialize(
|
||||||
|
encoder,
|
||||||
|
PollAnswerSurrogate(
|
||||||
|
value.pollId,
|
||||||
|
value.chosen,
|
||||||
|
value.user,
|
||||||
|
(value as? Anonymous) ?.voterChat
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,9 @@ import kotlin.random.Random
|
|||||||
@Serializable
|
@Serializable
|
||||||
@JvmInline
|
@JvmInline
|
||||||
value class RequestId(
|
value class RequestId(
|
||||||
val int: Int
|
val uShort: UShort
|
||||||
) {
|
) {
|
||||||
|
constructor(int: Int) : this(int.toUShort())
|
||||||
companion object {
|
companion object {
|
||||||
fun random() = RequestId(Random.nextInt())
|
fun random() = RequestId(Random.nextInt())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package dev.inmo.tgbotapi.types.stories
|
||||||
|
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
class Story
|
||||||
@@ -67,20 +67,19 @@ internal data class RawUpdate constructor(
|
|||||||
chat_join_request != null -> ChatJoinRequestUpdate(updateId, chat_join_request)
|
chat_join_request != null -> ChatJoinRequestUpdate(updateId, chat_join_request)
|
||||||
else -> UnknownUpdate(
|
else -> UnknownUpdate(
|
||||||
updateId,
|
updateId,
|
||||||
raw.toString(),
|
|
||||||
raw
|
raw
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} catch (e: Error) {
|
} catch (e: NotImplementedError) {
|
||||||
when (e) {
|
UnknownUpdate(
|
||||||
is SerializationException,
|
updateId,
|
||||||
is NotImplementedError -> UnknownUpdate(
|
raw
|
||||||
updateId,
|
)
|
||||||
raw.toString(),
|
} catch (e: SerializationException) {
|
||||||
raw
|
UnknownUpdate(
|
||||||
)
|
updateId,
|
||||||
else -> throw e
|
raw
|
||||||
}
|
)
|
||||||
}.also {
|
}.also {
|
||||||
initedUpdate = it
|
initedUpdate = it
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.types.update.abstracts
|
|||||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||||
import dev.inmo.tgbotapi.types.UpdateIdentifier
|
import dev.inmo.tgbotapi.types.UpdateIdentifier
|
||||||
import dev.inmo.tgbotapi.types.update.RawUpdate
|
import dev.inmo.tgbotapi.types.update.RawUpdate
|
||||||
|
import dev.inmo.tgbotapi.types.updateIdField
|
||||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||||
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
|
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
@@ -10,6 +11,9 @@ import kotlinx.serialization.descriptors.SerialDescriptor
|
|||||||
import kotlinx.serialization.encoding.Decoder
|
import kotlinx.serialization.encoding.Decoder
|
||||||
import kotlinx.serialization.encoding.Encoder
|
import kotlinx.serialization.encoding.Encoder
|
||||||
import kotlinx.serialization.json.JsonElement
|
import kotlinx.serialization.json.JsonElement
|
||||||
|
import kotlinx.serialization.json.JsonObject
|
||||||
|
import kotlinx.serialization.json.jsonPrimitive
|
||||||
|
import kotlinx.serialization.json.longOrNull
|
||||||
|
|
||||||
@ClassCastsIncluded
|
@ClassCastsIncluded
|
||||||
interface Update {
|
interface Update {
|
||||||
@@ -19,9 +23,12 @@ interface Update {
|
|||||||
|
|
||||||
data class UnknownUpdate(
|
data class UnknownUpdate(
|
||||||
override val updateId: UpdateIdentifier,
|
override val updateId: UpdateIdentifier,
|
||||||
override val data: String,
|
override val data: JsonElement,
|
||||||
|
val throwable: Throwable? = null
|
||||||
|
) : Update {
|
||||||
val rawJson: JsonElement
|
val rawJson: JsonElement
|
||||||
) : Update
|
get() = data
|
||||||
|
}
|
||||||
|
|
||||||
@RiskFeature
|
@RiskFeature
|
||||||
object UpdateSerializerWithoutSerialization : KSerializer<Update> {
|
object UpdateSerializerWithoutSerialization : KSerializer<Update> {
|
||||||
@@ -44,11 +51,19 @@ object UpdateDeserializationStrategy : DeserializationStrategy<Update> {
|
|||||||
|
|
||||||
override fun deserialize(decoder: Decoder): Update {
|
override fun deserialize(decoder: Decoder): Update {
|
||||||
val asJson = JsonElement.serializer().deserialize(decoder)
|
val asJson = JsonElement.serializer().deserialize(decoder)
|
||||||
return nonstrictJsonFormat.decodeFromJsonElement(
|
return runCatching {
|
||||||
RawUpdate.serializer(),
|
nonstrictJsonFormat.decodeFromJsonElement(
|
||||||
asJson
|
RawUpdate.serializer(),
|
||||||
).asUpdate(
|
asJson
|
||||||
asJson
|
).asUpdate(
|
||||||
)
|
asJson
|
||||||
|
)
|
||||||
|
}.getOrElse {
|
||||||
|
UnknownUpdate(
|
||||||
|
(asJson as? JsonObject) ?.get(updateIdField) ?.jsonPrimitive ?.longOrNull ?: -1L,
|
||||||
|
asJson,
|
||||||
|
it
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
package dev.inmo.tgbotapi.utils.internal
|
package dev.inmo.tgbotapi.utils.internal
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||||
|
|
||||||
@Target(AnnotationTarget.CLASS)
|
@Target(AnnotationTarget.CLASS)
|
||||||
@Retention(AnnotationRetention.SOURCE)
|
@Retention(AnnotationRetention.SOURCE)
|
||||||
internal annotation class ClassCastsIncluded
|
@RiskFeature("It is internal API in tgbotapi.core and should not be used outside")
|
||||||
|
annotation class ClassCastsIncluded(val typesRegex: String = "", val excludeRegex: String = "")
|
||||||
|
|
||||||
|
@Target(AnnotationTarget.CLASS)
|
||||||
|
@Retention(AnnotationRetention.SOURCE)
|
||||||
|
@RiskFeature("It is internal API in tgbotapi.core and should not be used outside")
|
||||||
|
annotation class ClassCastsExcluded
|
||||||
|
|||||||
@@ -9,4 +9,5 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation libs.kotlin.poet
|
implementation libs.kotlin.poet
|
||||||
implementation libs.ksp
|
implementation libs.ksp
|
||||||
|
implementation project(":tgbotapi.core")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,21 @@
|
|||||||
package dev.inmo.tgbotapi.ksp.processor
|
package dev.inmo.tgbotapi.ksp.processor
|
||||||
|
|
||||||
|
import com.google.devtools.ksp.KspExperimental
|
||||||
import com.google.devtools.ksp.getAllSuperTypes
|
import com.google.devtools.ksp.getAllSuperTypes
|
||||||
|
import com.google.devtools.ksp.getAnnotationsByType
|
||||||
|
import com.google.devtools.ksp.isAnnotationPresent
|
||||||
import com.google.devtools.ksp.processing.*
|
import com.google.devtools.ksp.processing.*
|
||||||
import com.google.devtools.ksp.symbol.KSAnnotated
|
import com.google.devtools.ksp.symbol.KSAnnotated
|
||||||
import com.google.devtools.ksp.symbol.KSClassDeclaration
|
import com.google.devtools.ksp.symbol.KSClassDeclaration
|
||||||
import com.squareup.kotlinpoet.AnnotationSpec
|
import com.squareup.kotlinpoet.AnnotationSpec
|
||||||
|
import com.squareup.kotlinpoet.ClassName
|
||||||
import com.squareup.kotlinpoet.FileSpec
|
import com.squareup.kotlinpoet.FileSpec
|
||||||
|
import com.squareup.kotlinpoet.asClassName
|
||||||
|
import com.squareup.kotlinpoet.ksp.toClassName
|
||||||
import com.squareup.kotlinpoet.ksp.writeTo
|
import com.squareup.kotlinpoet.ksp.writeTo
|
||||||
|
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||||
|
import dev.inmo.tgbotapi.utils.internal.ClassCastsExcluded
|
||||||
|
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class TelegramBotAPISymbolProcessor(
|
class TelegramBotAPISymbolProcessor(
|
||||||
@@ -15,24 +24,51 @@ class TelegramBotAPISymbolProcessor(
|
|||||||
private val outputFile: String = "Output",
|
private val outputFile: String = "Output",
|
||||||
private val outputFolder: String? = null
|
private val outputFolder: String? = null
|
||||||
) : SymbolProcessor {
|
) : SymbolProcessor {
|
||||||
|
private val classCastsIncludedClassName = ClassCastsIncluded::class.asClassName()
|
||||||
|
@OptIn(KspExperimental::class, RiskFeature::class)
|
||||||
override fun process(resolver: Resolver): List<KSAnnotated> {
|
override fun process(resolver: Resolver): List<KSAnnotated> {
|
||||||
val classes = resolver.getSymbolsWithAnnotation("dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded").filterIsInstance<KSClassDeclaration>()
|
val classes = resolver.getSymbolsWithAnnotation(classCastsIncludedClassName.canonicalName).filterIsInstance<KSClassDeclaration>()
|
||||||
|
val classesRegexes: Map<KSClassDeclaration, Pair<Regex?, Regex?>> = classes.mapNotNull {
|
||||||
|
it to (it.getAnnotationsByType(ClassCastsIncluded::class).firstNotNullOfOrNull {
|
||||||
|
it.typesRegex.takeIf { it.isNotEmpty() } ?.let(::Regex) to it.excludeRegex.takeIf { it.isNotEmpty() } ?.let(::Regex)
|
||||||
|
} ?: return@mapNotNull null)
|
||||||
|
}.toMap()
|
||||||
val classesSubtypes = mutableMapOf<KSClassDeclaration, MutableSet<KSClassDeclaration>>()
|
val classesSubtypes = mutableMapOf<KSClassDeclaration, MutableSet<KSClassDeclaration>>()
|
||||||
|
|
||||||
resolver.getAllFiles().forEach {
|
resolver.getAllFiles().forEach {
|
||||||
it.declarations.forEach { potentialSubtype ->
|
it.declarations.forEach { potentialSubtype ->
|
||||||
if (potentialSubtype is KSClassDeclaration) {
|
if (
|
||||||
|
potentialSubtype is KSClassDeclaration
|
||||||
|
&& potentialSubtype.isAnnotationPresent(ClassCastsExcluded::class).not()
|
||||||
|
) {
|
||||||
val allSupertypes = potentialSubtype.getAllSuperTypes().map { it.declaration }
|
val allSupertypes = potentialSubtype.getAllSuperTypes().map { it.declaration }
|
||||||
classes.forEach {
|
|
||||||
if (it in allSupertypes) {
|
for (currentClass in classes) {
|
||||||
classesSubtypes.getOrPut(it) { mutableSetOf() }.add(potentialSubtype)
|
val regexes = classesRegexes[currentClass]
|
||||||
|
val simpleName = potentialSubtype.simpleName.getShortName()
|
||||||
|
when {
|
||||||
|
currentClass !in allSupertypes
|
||||||
|
|| regexes ?.first ?.matches(simpleName) == false
|
||||||
|
|| regexes ?.second ?.matches(simpleName) == true -> continue
|
||||||
|
else -> {
|
||||||
|
classesSubtypes.getOrPut(currentClass) { mutableSetOf() }.add(potentialSubtype)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fun fillWithSealeds(source: KSClassDeclaration, current: KSClassDeclaration = source) {
|
fun fillWithSealeds(source: KSClassDeclaration, current: KSClassDeclaration = source) {
|
||||||
|
val regexes = classesRegexes[source]
|
||||||
current.getSealedSubclasses().forEach {
|
current.getSealedSubclasses().forEach {
|
||||||
|
val simpleName = it.simpleName.getShortName()
|
||||||
|
if (
|
||||||
|
regexes ?.first ?.matches(simpleName) == false
|
||||||
|
|| regexes ?.second ?.matches(simpleName) == true
|
||||||
|
|| it.isAnnotationPresent(ClassCastsExcluded::class)
|
||||||
|
) {
|
||||||
|
return@forEach
|
||||||
|
}
|
||||||
classesSubtypes.getOrPut(source) { mutableSetOf() }.add(it)
|
classesSubtypes.getOrPut(source) { mutableSetOf() }.add(it)
|
||||||
fillWithSealeds(source, it)
|
fillWithSealeds(source, it)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,25 +28,11 @@ import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.BaseChosenInline
|
|||||||
import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.ChosenInlineResult
|
import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.ChosenInlineResult
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.LocationChosenInlineResult
|
import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.LocationChosenInlineResult
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultArticle
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultArticle
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultAudioCachedImpl
|
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultAudioImpl
|
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultContact
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultContact
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultDocumentCachedImpl
|
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultDocumentImpl
|
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultGame
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultGame
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultGifCachedImpl
|
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultGifImpl
|
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultLocation
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultLocation
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultMpeg4GifCachedImpl
|
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultMpeg4GifImpl
|
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultPhotoCachedImpl
|
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultPhotoImpl
|
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultStickerCached
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultStickerCached
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVenue
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVenue
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVideoCachedImpl
|
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVideoImpl
|
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVoiceCachedImpl
|
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVoiceImpl
|
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.DescribedInlineQueryResult
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.DescribedInlineQueryResult
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.FileInlineQueryResult
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.FileInlineQueryResult
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult
|
||||||
@@ -124,50 +110,37 @@ import dev.inmo.tgbotapi.types.buttons.ReplyKeyboardRemove
|
|||||||
import dev.inmo.tgbotapi.types.chat.AbleToAddInAttachmentMenuChat
|
import dev.inmo.tgbotapi.types.chat.AbleToAddInAttachmentMenuChat
|
||||||
import dev.inmo.tgbotapi.types.chat.Bot
|
import dev.inmo.tgbotapi.types.chat.Bot
|
||||||
import dev.inmo.tgbotapi.types.chat.ChannelChat
|
import dev.inmo.tgbotapi.types.chat.ChannelChat
|
||||||
import dev.inmo.tgbotapi.types.chat.ChannelChatImpl
|
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
import dev.inmo.tgbotapi.types.chat.ChatJoinRequest
|
import dev.inmo.tgbotapi.types.chat.ChatJoinRequest
|
||||||
import dev.inmo.tgbotapi.types.chat.CommonBot
|
import dev.inmo.tgbotapi.types.chat.CommonBot
|
||||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
import dev.inmo.tgbotapi.types.chat.CommonUser
|
||||||
import dev.inmo.tgbotapi.types.chat.ExtendedBot
|
import dev.inmo.tgbotapi.types.chat.ExtendedBot
|
||||||
import dev.inmo.tgbotapi.types.chat.ExtendedChannelChat
|
import dev.inmo.tgbotapi.types.chat.ExtendedChannelChat
|
||||||
import dev.inmo.tgbotapi.types.chat.ExtendedChannelChatImpl
|
|
||||||
import dev.inmo.tgbotapi.types.chat.ExtendedChat
|
import dev.inmo.tgbotapi.types.chat.ExtendedChat
|
||||||
import dev.inmo.tgbotapi.types.chat.ExtendedChatWithUsername
|
import dev.inmo.tgbotapi.types.chat.ExtendedChatWithUsername
|
||||||
import dev.inmo.tgbotapi.types.chat.ExtendedForumChat
|
import dev.inmo.tgbotapi.types.chat.ExtendedForumChat
|
||||||
import dev.inmo.tgbotapi.types.chat.ExtendedForumChatImpl
|
|
||||||
import dev.inmo.tgbotapi.types.chat.ExtendedGroupChat
|
import dev.inmo.tgbotapi.types.chat.ExtendedGroupChat
|
||||||
import dev.inmo.tgbotapi.types.chat.ExtendedGroupChatImpl
|
|
||||||
import dev.inmo.tgbotapi.types.chat.ExtendedPrivateChat
|
import dev.inmo.tgbotapi.types.chat.ExtendedPrivateChat
|
||||||
import dev.inmo.tgbotapi.types.chat.ExtendedPrivateChatImpl
|
|
||||||
import dev.inmo.tgbotapi.types.chat.ExtendedPublicChat
|
import dev.inmo.tgbotapi.types.chat.ExtendedPublicChat
|
||||||
import dev.inmo.tgbotapi.types.chat.ExtendedSupergroupChat
|
import dev.inmo.tgbotapi.types.chat.ExtendedSupergroupChat
|
||||||
import dev.inmo.tgbotapi.types.chat.ExtendedSupergroupChatImpl
|
|
||||||
import dev.inmo.tgbotapi.types.chat.ForumChat
|
import dev.inmo.tgbotapi.types.chat.ForumChat
|
||||||
import dev.inmo.tgbotapi.types.chat.ForumChatImpl
|
|
||||||
import dev.inmo.tgbotapi.types.chat.GroupChat
|
import dev.inmo.tgbotapi.types.chat.GroupChat
|
||||||
import dev.inmo.tgbotapi.types.chat.GroupChatImpl
|
|
||||||
import dev.inmo.tgbotapi.types.chat.PossiblyPremiumChat
|
import dev.inmo.tgbotapi.types.chat.PossiblyPremiumChat
|
||||||
import dev.inmo.tgbotapi.types.chat.PrivateChat
|
import dev.inmo.tgbotapi.types.chat.PrivateChat
|
||||||
import dev.inmo.tgbotapi.types.chat.PrivateChatImpl
|
|
||||||
import dev.inmo.tgbotapi.types.chat.PublicChat
|
import dev.inmo.tgbotapi.types.chat.PublicChat
|
||||||
import dev.inmo.tgbotapi.types.chat.SuperPublicChat
|
import dev.inmo.tgbotapi.types.chat.SuperPublicChat
|
||||||
import dev.inmo.tgbotapi.types.chat.SupergroupChat
|
import dev.inmo.tgbotapi.types.chat.SupergroupChat
|
||||||
import dev.inmo.tgbotapi.types.chat.SupergroupChatImpl
|
|
||||||
import dev.inmo.tgbotapi.types.chat.UnknownChatType
|
import dev.inmo.tgbotapi.types.chat.UnknownChatType
|
||||||
import dev.inmo.tgbotapi.types.chat.UnknownExtendedChat
|
import dev.inmo.tgbotapi.types.chat.UnknownExtendedChat
|
||||||
import dev.inmo.tgbotapi.types.chat.User
|
import dev.inmo.tgbotapi.types.chat.User
|
||||||
import dev.inmo.tgbotapi.types.chat.UsernameChat
|
import dev.inmo.tgbotapi.types.chat.UsernameChat
|
||||||
import dev.inmo.tgbotapi.types.chat.member.AdministratorChatMember
|
import dev.inmo.tgbotapi.types.chat.member.AdministratorChatMember
|
||||||
import dev.inmo.tgbotapi.types.chat.member.AdministratorChatMemberImpl
|
|
||||||
import dev.inmo.tgbotapi.types.chat.member.BannedChatMember
|
import dev.inmo.tgbotapi.types.chat.member.BannedChatMember
|
||||||
import dev.inmo.tgbotapi.types.chat.member.ChatMember
|
import dev.inmo.tgbotapi.types.chat.member.ChatMember
|
||||||
import dev.inmo.tgbotapi.types.chat.member.ChatMemberUpdated
|
import dev.inmo.tgbotapi.types.chat.member.ChatMemberUpdated
|
||||||
import dev.inmo.tgbotapi.types.chat.member.KickedChatMember
|
import dev.inmo.tgbotapi.types.chat.member.KickedChatMember
|
||||||
import dev.inmo.tgbotapi.types.chat.member.LeftChatMember
|
import dev.inmo.tgbotapi.types.chat.member.LeftChatMember
|
||||||
import dev.inmo.tgbotapi.types.chat.member.LeftChatMemberImpl
|
|
||||||
import dev.inmo.tgbotapi.types.chat.member.MemberChatMember
|
import dev.inmo.tgbotapi.types.chat.member.MemberChatMember
|
||||||
import dev.inmo.tgbotapi.types.chat.member.MemberChatMemberImpl
|
|
||||||
import dev.inmo.tgbotapi.types.chat.member.OwnerChatMember
|
import dev.inmo.tgbotapi.types.chat.member.OwnerChatMember
|
||||||
import dev.inmo.tgbotapi.types.chat.member.RestrictedChatMember
|
import dev.inmo.tgbotapi.types.chat.member.RestrictedChatMember
|
||||||
import dev.inmo.tgbotapi.types.chat.member.SpecialRightsChatMember
|
import dev.inmo.tgbotapi.types.chat.member.SpecialRightsChatMember
|
||||||
@@ -228,9 +201,6 @@ import dev.inmo.tgbotapi.types.media.TelegramMediaVideo
|
|||||||
import dev.inmo.tgbotapi.types.media.ThumbedTelegramMedia
|
import dev.inmo.tgbotapi.types.media.ThumbedTelegramMedia
|
||||||
import dev.inmo.tgbotapi.types.media.TitledTelegramMedia
|
import dev.inmo.tgbotapi.types.media.TitledTelegramMedia
|
||||||
import dev.inmo.tgbotapi.types.media.VisualMediaGroupMemberTelegramMedia
|
import dev.inmo.tgbotapi.types.media.VisualMediaGroupMemberTelegramMedia
|
||||||
import dev.inmo.tgbotapi.types.message.AnonymousForumContentMessageImpl
|
|
||||||
import dev.inmo.tgbotapi.types.message.AnonymousGroupContentMessageImpl
|
|
||||||
import dev.inmo.tgbotapi.types.message.ChannelContentMessageImpl
|
|
||||||
import dev.inmo.tgbotapi.types.message.ChannelEventMessage
|
import dev.inmo.tgbotapi.types.message.ChannelEventMessage
|
||||||
import dev.inmo.tgbotapi.types.message.ChatEvents.ChannelChatCreated
|
import dev.inmo.tgbotapi.types.message.ChatEvents.ChannelChatCreated
|
||||||
import dev.inmo.tgbotapi.types.message.ChatEvents.DeleteChatPhoto
|
import dev.inmo.tgbotapi.types.message.ChatEvents.DeleteChatPhoto
|
||||||
@@ -266,17 +236,11 @@ import dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatEnded
|
|||||||
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatParticipantsInvited
|
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatParticipantsInvited
|
||||||
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatScheduled
|
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatScheduled
|
||||||
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatStarted
|
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatStarted
|
||||||
import dev.inmo.tgbotapi.types.message.CommonForumContentMessageImpl
|
|
||||||
import dev.inmo.tgbotapi.types.message.CommonGroupContentMessageImpl
|
|
||||||
import dev.inmo.tgbotapi.types.message.CommonGroupEventMessage
|
import dev.inmo.tgbotapi.types.message.CommonGroupEventMessage
|
||||||
import dev.inmo.tgbotapi.types.message.CommonSupergroupEventMessage
|
import dev.inmo.tgbotapi.types.message.CommonSupergroupEventMessage
|
||||||
import dev.inmo.tgbotapi.types.message.ConnectedFromChannelGroupContentMessageImpl
|
|
||||||
import dev.inmo.tgbotapi.types.message.ForwardInfo
|
import dev.inmo.tgbotapi.types.message.ForwardInfo
|
||||||
import dev.inmo.tgbotapi.types.message.FromChannelForumContentMessageImpl
|
|
||||||
import dev.inmo.tgbotapi.types.message.PassportMessage
|
import dev.inmo.tgbotapi.types.message.PassportMessage
|
||||||
import dev.inmo.tgbotapi.types.message.PrivateContentMessageImpl
|
|
||||||
import dev.inmo.tgbotapi.types.message.PrivateEventMessage
|
import dev.inmo.tgbotapi.types.message.PrivateEventMessage
|
||||||
import dev.inmo.tgbotapi.types.message.UnconnectedFromChannelGroupContentMessageImpl
|
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.AnonymousForumContentMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.AnonymousForumContentMessage
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.AnonymousGroupContentMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.AnonymousGroupContentMessage
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.ChannelContentMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.ChannelContentMessage
|
||||||
@@ -328,6 +292,7 @@ import dev.inmo.tgbotapi.types.message.content.ResendableContent
|
|||||||
import dev.inmo.tgbotapi.types.message.content.SpoilerableMediaContent
|
import dev.inmo.tgbotapi.types.message.content.SpoilerableMediaContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.StaticLocationContent
|
import dev.inmo.tgbotapi.types.message.content.StaticLocationContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.StickerContent
|
import dev.inmo.tgbotapi.types.message.content.StickerContent
|
||||||
|
import dev.inmo.tgbotapi.types.message.content.StoryContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.TextContent
|
import dev.inmo.tgbotapi.types.message.content.TextContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.TextedContent
|
import dev.inmo.tgbotapi.types.message.content.TextedContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.TextedMediaContent
|
import dev.inmo.tgbotapi.types.message.content.TextedMediaContent
|
||||||
@@ -635,16 +600,6 @@ public inline fun WithUser.administratorChatMemberOrThrow(): AdministratorChatMe
|
|||||||
public inline fun <T> WithUser.ifAdministratorChatMember(block: (AdministratorChatMember) -> T): T?
|
public inline fun <T> WithUser.ifAdministratorChatMember(block: (AdministratorChatMember) -> T): T?
|
||||||
= administratorChatMemberOrNull() ?.let(block)
|
= administratorChatMemberOrNull() ?.let(block)
|
||||||
|
|
||||||
public inline fun WithUser.administratorChatMemberImplOrNull(): AdministratorChatMemberImpl? = this
|
|
||||||
as? dev.inmo.tgbotapi.types.chat.member.AdministratorChatMemberImpl
|
|
||||||
|
|
||||||
public inline fun WithUser.administratorChatMemberImplOrThrow(): AdministratorChatMemberImpl = this
|
|
||||||
as dev.inmo.tgbotapi.types.chat.member.AdministratorChatMemberImpl
|
|
||||||
|
|
||||||
public inline fun <T>
|
|
||||||
WithUser.ifAdministratorChatMemberImpl(block: (AdministratorChatMemberImpl) -> T): T? =
|
|
||||||
administratorChatMemberImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun WithUser.bannedChatMemberOrNull(): BannedChatMember? = this as?
|
public inline fun WithUser.bannedChatMemberOrNull(): BannedChatMember? = this as?
|
||||||
dev.inmo.tgbotapi.types.chat.member.BannedChatMember
|
dev.inmo.tgbotapi.types.chat.member.BannedChatMember
|
||||||
|
|
||||||
@@ -690,15 +645,6 @@ public inline fun WithUser.leftChatMemberOrThrow(): LeftChatMember = this as
|
|||||||
public inline fun <T> WithUser.ifLeftChatMember(block: (LeftChatMember) -> T): T? =
|
public inline fun <T> WithUser.ifLeftChatMember(block: (LeftChatMember) -> T): T? =
|
||||||
leftChatMemberOrNull() ?.let(block)
|
leftChatMemberOrNull() ?.let(block)
|
||||||
|
|
||||||
public inline fun WithUser.leftChatMemberImplOrNull(): LeftChatMemberImpl? = this as?
|
|
||||||
dev.inmo.tgbotapi.types.chat.member.LeftChatMemberImpl
|
|
||||||
|
|
||||||
public inline fun WithUser.leftChatMemberImplOrThrow(): LeftChatMemberImpl = this as
|
|
||||||
dev.inmo.tgbotapi.types.chat.member.LeftChatMemberImpl
|
|
||||||
|
|
||||||
public inline fun <T> WithUser.ifLeftChatMemberImpl(block: (LeftChatMemberImpl) -> T): T? =
|
|
||||||
leftChatMemberImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun WithUser.memberChatMemberOrNull(): MemberChatMember? = this as?
|
public inline fun WithUser.memberChatMemberOrNull(): MemberChatMember? = this as?
|
||||||
dev.inmo.tgbotapi.types.chat.member.MemberChatMember
|
dev.inmo.tgbotapi.types.chat.member.MemberChatMember
|
||||||
|
|
||||||
@@ -708,15 +654,6 @@ public inline fun WithUser.memberChatMemberOrThrow(): MemberChatMember = this as
|
|||||||
public inline fun <T> WithUser.ifMemberChatMember(block: (MemberChatMember) -> T): T? =
|
public inline fun <T> WithUser.ifMemberChatMember(block: (MemberChatMember) -> T): T? =
|
||||||
memberChatMemberOrNull() ?.let(block)
|
memberChatMemberOrNull() ?.let(block)
|
||||||
|
|
||||||
public inline fun WithUser.memberChatMemberImplOrNull(): MemberChatMemberImpl? = this as?
|
|
||||||
dev.inmo.tgbotapi.types.chat.member.MemberChatMemberImpl
|
|
||||||
|
|
||||||
public inline fun WithUser.memberChatMemberImplOrThrow(): MemberChatMemberImpl = this as
|
|
||||||
dev.inmo.tgbotapi.types.chat.member.MemberChatMemberImpl
|
|
||||||
|
|
||||||
public inline fun <T> WithUser.ifMemberChatMemberImpl(block: (MemberChatMemberImpl) -> T): T? =
|
|
||||||
memberChatMemberImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun WithUser.ownerChatMemberOrNull(): OwnerChatMember? = this as?
|
public inline fun WithUser.ownerChatMemberOrNull(): OwnerChatMember? = this as?
|
||||||
dev.inmo.tgbotapi.types.chat.member.OwnerChatMember
|
dev.inmo.tgbotapi.types.chat.member.OwnerChatMember
|
||||||
|
|
||||||
@@ -777,30 +714,6 @@ public inline fun <T>
|
|||||||
WithUser.ifCommonSupergroupEventMessage(block: (CommonSupergroupEventMessage<SupergroupEvent>) -> T):
|
WithUser.ifCommonSupergroupEventMessage(block: (CommonSupergroupEventMessage<SupergroupEvent>) -> T):
|
||||||
T? = commonSupergroupEventMessageOrNull() ?.let(block)
|
T? = commonSupergroupEventMessageOrNull() ?.let(block)
|
||||||
|
|
||||||
public inline fun WithUser.commonGroupContentMessageImplOrNull():
|
|
||||||
CommonGroupContentMessageImpl<MessageContent>? = this as?
|
|
||||||
dev.inmo.tgbotapi.types.message.CommonGroupContentMessageImpl<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
|
||||||
|
|
||||||
public inline fun WithUser.commonGroupContentMessageImplOrThrow():
|
|
||||||
CommonGroupContentMessageImpl<MessageContent> = this as
|
|
||||||
dev.inmo.tgbotapi.types.message.CommonGroupContentMessageImpl<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
|
||||||
|
|
||||||
public inline fun <T>
|
|
||||||
WithUser.ifCommonGroupContentMessageImpl(block: (CommonGroupContentMessageImpl<MessageContent>) -> T):
|
|
||||||
T? = commonGroupContentMessageImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun WithUser.commonForumContentMessageImplOrNull():
|
|
||||||
CommonForumContentMessageImpl<MessageContent>? = this as?
|
|
||||||
dev.inmo.tgbotapi.types.message.CommonForumContentMessageImpl<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
|
||||||
|
|
||||||
public inline fun WithUser.commonForumContentMessageImplOrThrow():
|
|
||||||
CommonForumContentMessageImpl<MessageContent> = this as
|
|
||||||
dev.inmo.tgbotapi.types.message.CommonForumContentMessageImpl<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
|
||||||
|
|
||||||
public inline fun <T>
|
|
||||||
WithUser.ifCommonForumContentMessageImpl(block: (CommonForumContentMessageImpl<MessageContent>) -> T):
|
|
||||||
T? = commonForumContentMessageImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun WithUser.passportMessageOrNull(): PassportMessage? = this as?
|
public inline fun WithUser.passportMessageOrNull(): PassportMessage? = this as?
|
||||||
dev.inmo.tgbotapi.types.message.PassportMessage
|
dev.inmo.tgbotapi.types.message.PassportMessage
|
||||||
|
|
||||||
@@ -810,18 +723,6 @@ public inline fun WithUser.passportMessageOrThrow(): PassportMessage = this as
|
|||||||
public inline fun <T> WithUser.ifPassportMessage(block: (PassportMessage) -> T): T? =
|
public inline fun <T> WithUser.ifPassportMessage(block: (PassportMessage) -> T): T? =
|
||||||
passportMessageOrNull() ?.let(block)
|
passportMessageOrNull() ?.let(block)
|
||||||
|
|
||||||
public inline fun WithUser.privateContentMessageImplOrNull():
|
|
||||||
PrivateContentMessageImpl<MessageContent>? = this as?
|
|
||||||
dev.inmo.tgbotapi.types.message.PrivateContentMessageImpl<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
|
||||||
|
|
||||||
public inline fun WithUser.privateContentMessageImplOrThrow():
|
|
||||||
PrivateContentMessageImpl<MessageContent> = this as
|
|
||||||
dev.inmo.tgbotapi.types.message.PrivateContentMessageImpl<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
|
||||||
|
|
||||||
public inline fun <T>
|
|
||||||
WithUser.ifPrivateContentMessageImpl(block: (PrivateContentMessageImpl<MessageContent>) -> T):
|
|
||||||
T? = privateContentMessageImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun WithUser.fromUserMessageOrNull(): FromUserMessage? = this as?
|
public inline fun WithUser.fromUserMessageOrNull(): FromUserMessage? = this as?
|
||||||
dev.inmo.tgbotapi.types.message.abstracts.FromUserMessage
|
dev.inmo.tgbotapi.types.message.abstracts.FromUserMessage
|
||||||
|
|
||||||
@@ -1127,28 +1028,6 @@ public inline fun <T>
|
|||||||
InlineQueryResult.ifInlineQueryResultArticle(block: (InlineQueryResultArticle) -> T): T? =
|
InlineQueryResult.ifInlineQueryResultArticle(block: (InlineQueryResultArticle) -> T): T? =
|
||||||
inlineQueryResultArticleOrNull() ?.let(block)
|
inlineQueryResultArticleOrNull() ?.let(block)
|
||||||
|
|
||||||
public inline fun InlineQueryResult.inlineQueryResultAudioCachedImplOrNull():
|
|
||||||
InlineQueryResultAudioCachedImpl? = this as?
|
|
||||||
dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultAudioCachedImpl
|
|
||||||
|
|
||||||
public inline fun InlineQueryResult.inlineQueryResultAudioCachedImplOrThrow():
|
|
||||||
InlineQueryResultAudioCachedImpl = this as
|
|
||||||
dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultAudioCachedImpl
|
|
||||||
|
|
||||||
public inline fun <T>
|
|
||||||
InlineQueryResult.ifInlineQueryResultAudioCachedImpl(block: (InlineQueryResultAudioCachedImpl) -> T):
|
|
||||||
T? = inlineQueryResultAudioCachedImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun InlineQueryResult.inlineQueryResultAudioImplOrNull(): InlineQueryResultAudioImpl?
|
|
||||||
= this as? dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultAudioImpl
|
|
||||||
|
|
||||||
public inline fun InlineQueryResult.inlineQueryResultAudioImplOrThrow(): InlineQueryResultAudioImpl
|
|
||||||
= this as dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultAudioImpl
|
|
||||||
|
|
||||||
public inline fun <T>
|
|
||||||
InlineQueryResult.ifInlineQueryResultAudioImpl(block: (InlineQueryResultAudioImpl) -> T): T? =
|
|
||||||
inlineQueryResultAudioImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun InlineQueryResult.inlineQueryResultContactOrNull(): InlineQueryResultContact? =
|
public inline fun InlineQueryResult.inlineQueryResultContactOrNull(): InlineQueryResultContact? =
|
||||||
this as? dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultContact
|
this as? dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultContact
|
||||||
|
|
||||||
@@ -1159,30 +1038,6 @@ public inline fun <T>
|
|||||||
InlineQueryResult.ifInlineQueryResultContact(block: (InlineQueryResultContact) -> T): T? =
|
InlineQueryResult.ifInlineQueryResultContact(block: (InlineQueryResultContact) -> T): T? =
|
||||||
inlineQueryResultContactOrNull() ?.let(block)
|
inlineQueryResultContactOrNull() ?.let(block)
|
||||||
|
|
||||||
public inline fun InlineQueryResult.inlineQueryResultDocumentCachedImplOrNull():
|
|
||||||
InlineQueryResultDocumentCachedImpl? = this as?
|
|
||||||
dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultDocumentCachedImpl
|
|
||||||
|
|
||||||
public inline fun InlineQueryResult.inlineQueryResultDocumentCachedImplOrThrow():
|
|
||||||
InlineQueryResultDocumentCachedImpl = this as
|
|
||||||
dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultDocumentCachedImpl
|
|
||||||
|
|
||||||
public inline fun <T>
|
|
||||||
InlineQueryResult.ifInlineQueryResultDocumentCachedImpl(block: (InlineQueryResultDocumentCachedImpl) -> T):
|
|
||||||
T? = inlineQueryResultDocumentCachedImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun InlineQueryResult.inlineQueryResultDocumentImplOrNull():
|
|
||||||
InlineQueryResultDocumentImpl? = this as?
|
|
||||||
dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultDocumentImpl
|
|
||||||
|
|
||||||
public inline fun InlineQueryResult.inlineQueryResultDocumentImplOrThrow():
|
|
||||||
InlineQueryResultDocumentImpl = this as
|
|
||||||
dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultDocumentImpl
|
|
||||||
|
|
||||||
public inline fun <T>
|
|
||||||
InlineQueryResult.ifInlineQueryResultDocumentImpl(block: (InlineQueryResultDocumentImpl) -> T):
|
|
||||||
T? = inlineQueryResultDocumentImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun InlineQueryResult.inlineQueryResultGameOrNull(): InlineQueryResultGame? = this as?
|
public inline fun InlineQueryResult.inlineQueryResultGameOrNull(): InlineQueryResultGame? = this as?
|
||||||
dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultGame
|
dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultGame
|
||||||
|
|
||||||
@@ -1193,28 +1048,6 @@ public inline fun <T>
|
|||||||
InlineQueryResult.ifInlineQueryResultGame(block: (InlineQueryResultGame) -> T): T? =
|
InlineQueryResult.ifInlineQueryResultGame(block: (InlineQueryResultGame) -> T): T? =
|
||||||
inlineQueryResultGameOrNull() ?.let(block)
|
inlineQueryResultGameOrNull() ?.let(block)
|
||||||
|
|
||||||
public inline fun InlineQueryResult.inlineQueryResultGifCachedImplOrNull():
|
|
||||||
InlineQueryResultGifCachedImpl? = this as?
|
|
||||||
dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultGifCachedImpl
|
|
||||||
|
|
||||||
public inline fun InlineQueryResult.inlineQueryResultGifCachedImplOrThrow():
|
|
||||||
InlineQueryResultGifCachedImpl = this as
|
|
||||||
dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultGifCachedImpl
|
|
||||||
|
|
||||||
public inline fun <T>
|
|
||||||
InlineQueryResult.ifInlineQueryResultGifCachedImpl(block: (InlineQueryResultGifCachedImpl) -> T):
|
|
||||||
T? = inlineQueryResultGifCachedImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun InlineQueryResult.inlineQueryResultGifImplOrNull(): InlineQueryResultGifImpl? =
|
|
||||||
this as? dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultGifImpl
|
|
||||||
|
|
||||||
public inline fun InlineQueryResult.inlineQueryResultGifImplOrThrow(): InlineQueryResultGifImpl =
|
|
||||||
this as dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultGifImpl
|
|
||||||
|
|
||||||
public inline fun <T>
|
|
||||||
InlineQueryResult.ifInlineQueryResultGifImpl(block: (InlineQueryResultGifImpl) -> T): T? =
|
|
||||||
inlineQueryResultGifImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun InlineQueryResult.inlineQueryResultLocationOrNull(): InlineQueryResultLocation? =
|
public inline fun InlineQueryResult.inlineQueryResultLocationOrNull(): InlineQueryResultLocation? =
|
||||||
this as? dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultLocation
|
this as? dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultLocation
|
||||||
|
|
||||||
@@ -1225,52 +1058,6 @@ public inline fun <T>
|
|||||||
InlineQueryResult.ifInlineQueryResultLocation(block: (InlineQueryResultLocation) -> T): T? =
|
InlineQueryResult.ifInlineQueryResultLocation(block: (InlineQueryResultLocation) -> T): T? =
|
||||||
inlineQueryResultLocationOrNull() ?.let(block)
|
inlineQueryResultLocationOrNull() ?.let(block)
|
||||||
|
|
||||||
public inline fun InlineQueryResult.inlineQueryResultMpeg4GifCachedImplOrNull():
|
|
||||||
InlineQueryResultMpeg4GifCachedImpl? = this as?
|
|
||||||
dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultMpeg4GifCachedImpl
|
|
||||||
|
|
||||||
public inline fun InlineQueryResult.inlineQueryResultMpeg4GifCachedImplOrThrow():
|
|
||||||
InlineQueryResultMpeg4GifCachedImpl = this as
|
|
||||||
dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultMpeg4GifCachedImpl
|
|
||||||
|
|
||||||
public inline fun <T>
|
|
||||||
InlineQueryResult.ifInlineQueryResultMpeg4GifCachedImpl(block: (InlineQueryResultMpeg4GifCachedImpl) -> T):
|
|
||||||
T? = inlineQueryResultMpeg4GifCachedImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun InlineQueryResult.inlineQueryResultMpeg4GifImplOrNull():
|
|
||||||
InlineQueryResultMpeg4GifImpl? = this as?
|
|
||||||
dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultMpeg4GifImpl
|
|
||||||
|
|
||||||
public inline fun InlineQueryResult.inlineQueryResultMpeg4GifImplOrThrow():
|
|
||||||
InlineQueryResultMpeg4GifImpl = this as
|
|
||||||
dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultMpeg4GifImpl
|
|
||||||
|
|
||||||
public inline fun <T>
|
|
||||||
InlineQueryResult.ifInlineQueryResultMpeg4GifImpl(block: (InlineQueryResultMpeg4GifImpl) -> T):
|
|
||||||
T? = inlineQueryResultMpeg4GifImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun InlineQueryResult.inlineQueryResultPhotoCachedImplOrNull():
|
|
||||||
InlineQueryResultPhotoCachedImpl? = this as?
|
|
||||||
dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultPhotoCachedImpl
|
|
||||||
|
|
||||||
public inline fun InlineQueryResult.inlineQueryResultPhotoCachedImplOrThrow():
|
|
||||||
InlineQueryResultPhotoCachedImpl = this as
|
|
||||||
dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultPhotoCachedImpl
|
|
||||||
|
|
||||||
public inline fun <T>
|
|
||||||
InlineQueryResult.ifInlineQueryResultPhotoCachedImpl(block: (InlineQueryResultPhotoCachedImpl) -> T):
|
|
||||||
T? = inlineQueryResultPhotoCachedImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun InlineQueryResult.inlineQueryResultPhotoImplOrNull(): InlineQueryResultPhotoImpl?
|
|
||||||
= this as? dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultPhotoImpl
|
|
||||||
|
|
||||||
public inline fun InlineQueryResult.inlineQueryResultPhotoImplOrThrow(): InlineQueryResultPhotoImpl
|
|
||||||
= this as dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultPhotoImpl
|
|
||||||
|
|
||||||
public inline fun <T>
|
|
||||||
InlineQueryResult.ifInlineQueryResultPhotoImpl(block: (InlineQueryResultPhotoImpl) -> T): T? =
|
|
||||||
inlineQueryResultPhotoImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun InlineQueryResult.inlineQueryResultStickerCachedOrNull():
|
public inline fun InlineQueryResult.inlineQueryResultStickerCachedOrNull():
|
||||||
InlineQueryResultStickerCached? = this as?
|
InlineQueryResultStickerCached? = this as?
|
||||||
dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultStickerCached
|
dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultStickerCached
|
||||||
@@ -1293,50 +1080,6 @@ public inline fun <T>
|
|||||||
InlineQueryResult.ifInlineQueryResultVenue(block: (InlineQueryResultVenue) -> T): T? =
|
InlineQueryResult.ifInlineQueryResultVenue(block: (InlineQueryResultVenue) -> T): T? =
|
||||||
inlineQueryResultVenueOrNull() ?.let(block)
|
inlineQueryResultVenueOrNull() ?.let(block)
|
||||||
|
|
||||||
public inline fun InlineQueryResult.inlineQueryResultVideoCachedImplOrNull():
|
|
||||||
InlineQueryResultVideoCachedImpl? = this as?
|
|
||||||
dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVideoCachedImpl
|
|
||||||
|
|
||||||
public inline fun InlineQueryResult.inlineQueryResultVideoCachedImplOrThrow():
|
|
||||||
InlineQueryResultVideoCachedImpl = this as
|
|
||||||
dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVideoCachedImpl
|
|
||||||
|
|
||||||
public inline fun <T>
|
|
||||||
InlineQueryResult.ifInlineQueryResultVideoCachedImpl(block: (InlineQueryResultVideoCachedImpl) -> T):
|
|
||||||
T? = inlineQueryResultVideoCachedImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun InlineQueryResult.inlineQueryResultVideoImplOrNull(): InlineQueryResultVideoImpl?
|
|
||||||
= this as? dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVideoImpl
|
|
||||||
|
|
||||||
public inline fun InlineQueryResult.inlineQueryResultVideoImplOrThrow(): InlineQueryResultVideoImpl
|
|
||||||
= this as dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVideoImpl
|
|
||||||
|
|
||||||
public inline fun <T>
|
|
||||||
InlineQueryResult.ifInlineQueryResultVideoImpl(block: (InlineQueryResultVideoImpl) -> T): T? =
|
|
||||||
inlineQueryResultVideoImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun InlineQueryResult.inlineQueryResultVoiceCachedImplOrNull():
|
|
||||||
InlineQueryResultVoiceCachedImpl? = this as?
|
|
||||||
dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVoiceCachedImpl
|
|
||||||
|
|
||||||
public inline fun InlineQueryResult.inlineQueryResultVoiceCachedImplOrThrow():
|
|
||||||
InlineQueryResultVoiceCachedImpl = this as
|
|
||||||
dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVoiceCachedImpl
|
|
||||||
|
|
||||||
public inline fun <T>
|
|
||||||
InlineQueryResult.ifInlineQueryResultVoiceCachedImpl(block: (InlineQueryResultVoiceCachedImpl) -> T):
|
|
||||||
T? = inlineQueryResultVoiceCachedImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun InlineQueryResult.inlineQueryResultVoiceImplOrNull(): InlineQueryResultVoiceImpl?
|
|
||||||
= this as? dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVoiceImpl
|
|
||||||
|
|
||||||
public inline fun InlineQueryResult.inlineQueryResultVoiceImplOrThrow(): InlineQueryResultVoiceImpl
|
|
||||||
= this as dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVoiceImpl
|
|
||||||
|
|
||||||
public inline fun <T>
|
|
||||||
InlineQueryResult.ifInlineQueryResultVoiceImpl(block: (InlineQueryResultVoiceImpl) -> T): T? =
|
|
||||||
inlineQueryResultVoiceImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun InlineQueryResult.describedInlineQueryResultOrNull(): DescribedInlineQueryResult?
|
public inline fun InlineQueryResult.describedInlineQueryResultOrNull(): DescribedInlineQueryResult?
|
||||||
= this as?
|
= this as?
|
||||||
dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.DescribedInlineQueryResult
|
dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.DescribedInlineQueryResult
|
||||||
@@ -2130,51 +1873,6 @@ public inline fun <T>
|
|||||||
Chat.ifAbleToAddInAttachmentMenuChat(block: (AbleToAddInAttachmentMenuChat) -> T): T? =
|
Chat.ifAbleToAddInAttachmentMenuChat(block: (AbleToAddInAttachmentMenuChat) -> T): T? =
|
||||||
ableToAddInAttachmentMenuChatOrNull() ?.let(block)
|
ableToAddInAttachmentMenuChatOrNull() ?.let(block)
|
||||||
|
|
||||||
public inline fun Chat.extendedChannelChatImplOrNull(): ExtendedChannelChatImpl? = this as?
|
|
||||||
dev.inmo.tgbotapi.types.chat.ExtendedChannelChatImpl
|
|
||||||
|
|
||||||
public inline fun Chat.extendedChannelChatImplOrThrow(): ExtendedChannelChatImpl = this as
|
|
||||||
dev.inmo.tgbotapi.types.chat.ExtendedChannelChatImpl
|
|
||||||
|
|
||||||
public inline fun <T> Chat.ifExtendedChannelChatImpl(block: (ExtendedChannelChatImpl) -> T): T? =
|
|
||||||
extendedChannelChatImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun Chat.extendedGroupChatImplOrNull(): ExtendedGroupChatImpl? = this as?
|
|
||||||
dev.inmo.tgbotapi.types.chat.ExtendedGroupChatImpl
|
|
||||||
|
|
||||||
public inline fun Chat.extendedGroupChatImplOrThrow(): ExtendedGroupChatImpl = this as
|
|
||||||
dev.inmo.tgbotapi.types.chat.ExtendedGroupChatImpl
|
|
||||||
|
|
||||||
public inline fun <T> Chat.ifExtendedGroupChatImpl(block: (ExtendedGroupChatImpl) -> T): T? =
|
|
||||||
extendedGroupChatImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun Chat.extendedPrivateChatImplOrNull(): ExtendedPrivateChatImpl? = this as?
|
|
||||||
dev.inmo.tgbotapi.types.chat.ExtendedPrivateChatImpl
|
|
||||||
|
|
||||||
public inline fun Chat.extendedPrivateChatImplOrThrow(): ExtendedPrivateChatImpl = this as
|
|
||||||
dev.inmo.tgbotapi.types.chat.ExtendedPrivateChatImpl
|
|
||||||
|
|
||||||
public inline fun <T> Chat.ifExtendedPrivateChatImpl(block: (ExtendedPrivateChatImpl) -> T): T? =
|
|
||||||
extendedPrivateChatImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun Chat.extendedSupergroupChatImplOrNull(): ExtendedSupergroupChatImpl? = this as?
|
|
||||||
dev.inmo.tgbotapi.types.chat.ExtendedSupergroupChatImpl
|
|
||||||
|
|
||||||
public inline fun Chat.extendedSupergroupChatImplOrThrow(): ExtendedSupergroupChatImpl = this as
|
|
||||||
dev.inmo.tgbotapi.types.chat.ExtendedSupergroupChatImpl
|
|
||||||
|
|
||||||
public inline fun <T> Chat.ifExtendedSupergroupChatImpl(block: (ExtendedSupergroupChatImpl) -> T):
|
|
||||||
T? = extendedSupergroupChatImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun Chat.extendedForumChatImplOrNull(): ExtendedForumChatImpl? = this as?
|
|
||||||
dev.inmo.tgbotapi.types.chat.ExtendedForumChatImpl
|
|
||||||
|
|
||||||
public inline fun Chat.extendedForumChatImplOrThrow(): ExtendedForumChatImpl = this as
|
|
||||||
dev.inmo.tgbotapi.types.chat.ExtendedForumChatImpl
|
|
||||||
|
|
||||||
public inline fun <T> Chat.ifExtendedForumChatImpl(block: (ExtendedForumChatImpl) -> T): T? =
|
|
||||||
extendedForumChatImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun Chat.extendedBotOrNull(): ExtendedBot? = this as?
|
public inline fun Chat.extendedBotOrNull(): ExtendedBot? = this as?
|
||||||
dev.inmo.tgbotapi.types.chat.ExtendedBot
|
dev.inmo.tgbotapi.types.chat.ExtendedBot
|
||||||
|
|
||||||
@@ -2265,51 +1963,6 @@ public inline fun Chat.extendedChatWithUsernameOrThrow(): ExtendedChatWithUserna
|
|||||||
public inline fun <T> Chat.ifExtendedChatWithUsername(block: (ExtendedChatWithUsername) -> T): T? =
|
public inline fun <T> Chat.ifExtendedChatWithUsername(block: (ExtendedChatWithUsername) -> T): T? =
|
||||||
extendedChatWithUsernameOrNull() ?.let(block)
|
extendedChatWithUsernameOrNull() ?.let(block)
|
||||||
|
|
||||||
public inline fun Chat.groupChatImplOrNull(): GroupChatImpl? = this as?
|
|
||||||
dev.inmo.tgbotapi.types.chat.GroupChatImpl
|
|
||||||
|
|
||||||
public inline fun Chat.groupChatImplOrThrow(): GroupChatImpl = this as
|
|
||||||
dev.inmo.tgbotapi.types.chat.GroupChatImpl
|
|
||||||
|
|
||||||
public inline fun <T> Chat.ifGroupChatImpl(block: (GroupChatImpl) -> T): T? = groupChatImplOrNull()
|
|
||||||
?.let(block)
|
|
||||||
|
|
||||||
public inline fun Chat.privateChatImplOrNull(): PrivateChatImpl? = this as?
|
|
||||||
dev.inmo.tgbotapi.types.chat.PrivateChatImpl
|
|
||||||
|
|
||||||
public inline fun Chat.privateChatImplOrThrow(): PrivateChatImpl = this as
|
|
||||||
dev.inmo.tgbotapi.types.chat.PrivateChatImpl
|
|
||||||
|
|
||||||
public inline fun <T> Chat.ifPrivateChatImpl(block: (PrivateChatImpl) -> T): T? =
|
|
||||||
privateChatImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun Chat.supergroupChatImplOrNull(): SupergroupChatImpl? = this as?
|
|
||||||
dev.inmo.tgbotapi.types.chat.SupergroupChatImpl
|
|
||||||
|
|
||||||
public inline fun Chat.supergroupChatImplOrThrow(): SupergroupChatImpl = this as
|
|
||||||
dev.inmo.tgbotapi.types.chat.SupergroupChatImpl
|
|
||||||
|
|
||||||
public inline fun <T> Chat.ifSupergroupChatImpl(block: (SupergroupChatImpl) -> T): T? =
|
|
||||||
supergroupChatImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun Chat.forumChatImplOrNull(): ForumChatImpl? = this as?
|
|
||||||
dev.inmo.tgbotapi.types.chat.ForumChatImpl
|
|
||||||
|
|
||||||
public inline fun Chat.forumChatImplOrThrow(): ForumChatImpl = this as
|
|
||||||
dev.inmo.tgbotapi.types.chat.ForumChatImpl
|
|
||||||
|
|
||||||
public inline fun <T> Chat.ifForumChatImpl(block: (ForumChatImpl) -> T): T? = forumChatImplOrNull()
|
|
||||||
?.let(block)
|
|
||||||
|
|
||||||
public inline fun Chat.channelChatImplOrNull(): ChannelChatImpl? = this as?
|
|
||||||
dev.inmo.tgbotapi.types.chat.ChannelChatImpl
|
|
||||||
|
|
||||||
public inline fun Chat.channelChatImplOrThrow(): ChannelChatImpl = this as
|
|
||||||
dev.inmo.tgbotapi.types.chat.ChannelChatImpl
|
|
||||||
|
|
||||||
public inline fun <T> Chat.ifChannelChatImpl(block: (ChannelChatImpl) -> T): T? =
|
|
||||||
channelChatImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun Chat.userOrNull(): User? = this as? dev.inmo.tgbotapi.types.chat.User
|
public inline fun Chat.userOrNull(): User? = this as? dev.inmo.tgbotapi.types.chat.User
|
||||||
|
|
||||||
public inline fun Chat.userOrThrow(): User = this as dev.inmo.tgbotapi.types.chat.User
|
public inline fun Chat.userOrThrow(): User = this as dev.inmo.tgbotapi.types.chat.User
|
||||||
@@ -3240,18 +2893,6 @@ public inline fun <T>
|
|||||||
ForwardInfo.ifSentByChannel(block: (ForwardInfo.PublicChat.SentByChannel) -> T): T? =
|
ForwardInfo.ifSentByChannel(block: (ForwardInfo.PublicChat.SentByChannel) -> T): T? =
|
||||||
sentByChannelOrNull() ?.let(block)
|
sentByChannelOrNull() ?.let(block)
|
||||||
|
|
||||||
public inline fun Message.channelContentMessageImplOrNull():
|
|
||||||
ChannelContentMessageImpl<MessageContent>? = this as?
|
|
||||||
dev.inmo.tgbotapi.types.message.ChannelContentMessageImpl<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
|
||||||
|
|
||||||
public inline fun Message.channelContentMessageImplOrThrow():
|
|
||||||
ChannelContentMessageImpl<MessageContent> = this as
|
|
||||||
dev.inmo.tgbotapi.types.message.ChannelContentMessageImpl<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
|
||||||
|
|
||||||
public inline fun <T>
|
|
||||||
Message.ifChannelContentMessageImpl(block: (ChannelContentMessageImpl<MessageContent>) -> T): T?
|
|
||||||
= channelContentMessageImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun Message.channelEventMessageOrNull(): ChannelEventMessage<ChannelEvent>? = this as?
|
public inline fun Message.channelEventMessageOrNull(): ChannelEventMessage<ChannelEvent>? = this as?
|
||||||
dev.inmo.tgbotapi.types.message.ChannelEventMessage<dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChannelEvent>
|
dev.inmo.tgbotapi.types.message.ChannelEventMessage<dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChannelEvent>
|
||||||
|
|
||||||
@@ -3286,90 +2927,6 @@ public inline fun <T>
|
|||||||
Message.ifCommonSupergroupEventMessage(block: (CommonSupergroupEventMessage<SupergroupEvent>) -> T):
|
Message.ifCommonSupergroupEventMessage(block: (CommonSupergroupEventMessage<SupergroupEvent>) -> T):
|
||||||
T? = commonSupergroupEventMessageOrNull() ?.let(block)
|
T? = commonSupergroupEventMessageOrNull() ?.let(block)
|
||||||
|
|
||||||
public inline fun Message.connectedFromChannelGroupContentMessageImplOrNull():
|
|
||||||
ConnectedFromChannelGroupContentMessageImpl<MessageContent>? = this as?
|
|
||||||
dev.inmo.tgbotapi.types.message.ConnectedFromChannelGroupContentMessageImpl<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
|
||||||
|
|
||||||
public inline fun Message.connectedFromChannelGroupContentMessageImplOrThrow():
|
|
||||||
ConnectedFromChannelGroupContentMessageImpl<MessageContent> = this as
|
|
||||||
dev.inmo.tgbotapi.types.message.ConnectedFromChannelGroupContentMessageImpl<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
|
||||||
|
|
||||||
public inline fun <T>
|
|
||||||
Message.ifConnectedFromChannelGroupContentMessageImpl(block: (ConnectedFromChannelGroupContentMessageImpl<MessageContent>) -> T):
|
|
||||||
T? = connectedFromChannelGroupContentMessageImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun Message.unconnectedFromChannelGroupContentMessageImplOrNull():
|
|
||||||
UnconnectedFromChannelGroupContentMessageImpl<MessageContent>? = this as?
|
|
||||||
dev.inmo.tgbotapi.types.message.UnconnectedFromChannelGroupContentMessageImpl<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
|
||||||
|
|
||||||
public inline fun Message.unconnectedFromChannelGroupContentMessageImplOrThrow():
|
|
||||||
UnconnectedFromChannelGroupContentMessageImpl<MessageContent> = this as
|
|
||||||
dev.inmo.tgbotapi.types.message.UnconnectedFromChannelGroupContentMessageImpl<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
|
||||||
|
|
||||||
public inline fun <T>
|
|
||||||
Message.ifUnconnectedFromChannelGroupContentMessageImpl(block: (UnconnectedFromChannelGroupContentMessageImpl<MessageContent>) -> T):
|
|
||||||
T? = unconnectedFromChannelGroupContentMessageImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun Message.anonymousGroupContentMessageImplOrNull():
|
|
||||||
AnonymousGroupContentMessageImpl<MessageContent>? = this as?
|
|
||||||
dev.inmo.tgbotapi.types.message.AnonymousGroupContentMessageImpl<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
|
||||||
|
|
||||||
public inline fun Message.anonymousGroupContentMessageImplOrThrow():
|
|
||||||
AnonymousGroupContentMessageImpl<MessageContent> = this as
|
|
||||||
dev.inmo.tgbotapi.types.message.AnonymousGroupContentMessageImpl<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
|
||||||
|
|
||||||
public inline fun <T>
|
|
||||||
Message.ifAnonymousGroupContentMessageImpl(block: (AnonymousGroupContentMessageImpl<MessageContent>) -> T):
|
|
||||||
T? = anonymousGroupContentMessageImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun Message.commonGroupContentMessageImplOrNull():
|
|
||||||
CommonGroupContentMessageImpl<MessageContent>? = this as?
|
|
||||||
dev.inmo.tgbotapi.types.message.CommonGroupContentMessageImpl<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
|
||||||
|
|
||||||
public inline fun Message.commonGroupContentMessageImplOrThrow():
|
|
||||||
CommonGroupContentMessageImpl<MessageContent> = this as
|
|
||||||
dev.inmo.tgbotapi.types.message.CommonGroupContentMessageImpl<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
|
||||||
|
|
||||||
public inline fun <T>
|
|
||||||
Message.ifCommonGroupContentMessageImpl(block: (CommonGroupContentMessageImpl<MessageContent>) -> T):
|
|
||||||
T? = commonGroupContentMessageImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun Message.fromChannelForumContentMessageImplOrNull():
|
|
||||||
FromChannelForumContentMessageImpl<MessageContent>? = this as?
|
|
||||||
dev.inmo.tgbotapi.types.message.FromChannelForumContentMessageImpl<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
|
||||||
|
|
||||||
public inline fun Message.fromChannelForumContentMessageImplOrThrow():
|
|
||||||
FromChannelForumContentMessageImpl<MessageContent> = this as
|
|
||||||
dev.inmo.tgbotapi.types.message.FromChannelForumContentMessageImpl<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
|
||||||
|
|
||||||
public inline fun <T>
|
|
||||||
Message.ifFromChannelForumContentMessageImpl(block: (FromChannelForumContentMessageImpl<MessageContent>) -> T):
|
|
||||||
T? = fromChannelForumContentMessageImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun Message.anonymousForumContentMessageImplOrNull():
|
|
||||||
AnonymousForumContentMessageImpl<MessageContent>? = this as?
|
|
||||||
dev.inmo.tgbotapi.types.message.AnonymousForumContentMessageImpl<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
|
||||||
|
|
||||||
public inline fun Message.anonymousForumContentMessageImplOrThrow():
|
|
||||||
AnonymousForumContentMessageImpl<MessageContent> = this as
|
|
||||||
dev.inmo.tgbotapi.types.message.AnonymousForumContentMessageImpl<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
|
||||||
|
|
||||||
public inline fun <T>
|
|
||||||
Message.ifAnonymousForumContentMessageImpl(block: (AnonymousForumContentMessageImpl<MessageContent>) -> T):
|
|
||||||
T? = anonymousForumContentMessageImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun Message.commonForumContentMessageImplOrNull():
|
|
||||||
CommonForumContentMessageImpl<MessageContent>? = this as?
|
|
||||||
dev.inmo.tgbotapi.types.message.CommonForumContentMessageImpl<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
|
||||||
|
|
||||||
public inline fun Message.commonForumContentMessageImplOrThrow():
|
|
||||||
CommonForumContentMessageImpl<MessageContent> = this as
|
|
||||||
dev.inmo.tgbotapi.types.message.CommonForumContentMessageImpl<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
|
||||||
|
|
||||||
public inline fun <T>
|
|
||||||
Message.ifCommonForumContentMessageImpl(block: (CommonForumContentMessageImpl<MessageContent>) -> T):
|
|
||||||
T? = commonForumContentMessageImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun Message.passportMessageOrNull(): PassportMessage? = this as?
|
public inline fun Message.passportMessageOrNull(): PassportMessage? = this as?
|
||||||
dev.inmo.tgbotapi.types.message.PassportMessage
|
dev.inmo.tgbotapi.types.message.PassportMessage
|
||||||
|
|
||||||
@@ -3379,18 +2936,6 @@ public inline fun Message.passportMessageOrThrow(): PassportMessage = this as
|
|||||||
public inline fun <T> Message.ifPassportMessage(block: (PassportMessage) -> T): T? =
|
public inline fun <T> Message.ifPassportMessage(block: (PassportMessage) -> T): T? =
|
||||||
passportMessageOrNull() ?.let(block)
|
passportMessageOrNull() ?.let(block)
|
||||||
|
|
||||||
public inline fun Message.privateContentMessageImplOrNull():
|
|
||||||
PrivateContentMessageImpl<MessageContent>? = this as?
|
|
||||||
dev.inmo.tgbotapi.types.message.PrivateContentMessageImpl<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
|
||||||
|
|
||||||
public inline fun Message.privateContentMessageImplOrThrow():
|
|
||||||
PrivateContentMessageImpl<MessageContent> = this as
|
|
||||||
dev.inmo.tgbotapi.types.message.PrivateContentMessageImpl<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
|
||||||
|
|
||||||
public inline fun <T>
|
|
||||||
Message.ifPrivateContentMessageImpl(block: (PrivateContentMessageImpl<MessageContent>) -> T): T?
|
|
||||||
= privateContentMessageImplOrNull() ?.let(block)
|
|
||||||
|
|
||||||
public inline fun Message.privateEventMessageOrNull(): PrivateEventMessage<PrivateEvent>? = this as?
|
public inline fun Message.privateEventMessageOrNull(): PrivateEventMessage<PrivateEvent>? = this as?
|
||||||
dev.inmo.tgbotapi.types.message.PrivateEventMessage<dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PrivateEvent>
|
dev.inmo.tgbotapi.types.message.PrivateEventMessage<dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PrivateEvent>
|
||||||
|
|
||||||
@@ -3936,6 +3481,15 @@ public inline fun ResendableContent.stickerContentOrThrow(): StickerContent = th
|
|||||||
public inline fun <T> ResendableContent.ifStickerContent(block: (StickerContent) -> T): T? =
|
public inline fun <T> ResendableContent.ifStickerContent(block: (StickerContent) -> T): T? =
|
||||||
stickerContentOrNull() ?.let(block)
|
stickerContentOrNull() ?.let(block)
|
||||||
|
|
||||||
|
public inline fun ResendableContent.storyContentOrNull(): StoryContent? = this as?
|
||||||
|
dev.inmo.tgbotapi.types.message.content.StoryContent
|
||||||
|
|
||||||
|
public inline fun ResendableContent.storyContentOrThrow(): StoryContent = this as
|
||||||
|
dev.inmo.tgbotapi.types.message.content.StoryContent
|
||||||
|
|
||||||
|
public inline fun <T> ResendableContent.ifStoryContent(block: (StoryContent) -> T): T? =
|
||||||
|
storyContentOrNull() ?.let(block)
|
||||||
|
|
||||||
public inline fun ResendableContent.textContentOrNull(): TextContent? = this as?
|
public inline fun ResendableContent.textContentOrNull(): TextContent? = this as?
|
||||||
dev.inmo.tgbotapi.types.message.content.TextContent
|
dev.inmo.tgbotapi.types.message.content.TextContent
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ fun Flow<ContentMessage<*>>.onlyPhotoContentMessages() = withContentType<PhotoCo
|
|||||||
fun Flow<ContentMessage<*>>.onlyPollContentMessages() = withContentType<PollContent>()
|
fun Flow<ContentMessage<*>>.onlyPollContentMessages() = withContentType<PollContent>()
|
||||||
fun Flow<ContentMessage<*>>.onlyStickerContentMessages() = withContentType<StickerContent>()
|
fun Flow<ContentMessage<*>>.onlyStickerContentMessages() = withContentType<StickerContent>()
|
||||||
fun Flow<ContentMessage<*>>.onlyTextContentMessages() = withContentType<TextContent>()
|
fun Flow<ContentMessage<*>>.onlyTextContentMessages() = withContentType<TextContent>()
|
||||||
|
fun Flow<ContentMessage<*>>.onlyStoryContentMessages() = withContentType<StoryContent>()
|
||||||
fun Flow<ContentMessage<*>>.onlyVenueContentMessages() = withContentType<VenueContent>()
|
fun Flow<ContentMessage<*>>.onlyVenueContentMessages() = withContentType<VenueContent>()
|
||||||
fun Flow<ContentMessage<*>>.onlyVideoContentMessages() = withContentType<VideoContent>()
|
fun Flow<ContentMessage<*>>.onlyVideoContentMessages() = withContentType<VideoContent>()
|
||||||
fun Flow<ContentMessage<*>>.onlyVideoNoteContentMessages() = withContentType<VideoNoteContent>()
|
fun Flow<ContentMessage<*>>.onlyVideoNoteContentMessages() = withContentType<VideoNoteContent>()
|
||||||
|
|||||||
@@ -3,17 +3,60 @@ package dev.inmo.tgbotapi.extensions.utils.extensions
|
|||||||
import dev.inmo.tgbotapi.abstracts.FromUser
|
import dev.inmo.tgbotapi.abstracts.FromUser
|
||||||
import dev.inmo.tgbotapi.abstracts.WithUser
|
import dev.inmo.tgbotapi.abstracts.WithUser
|
||||||
import dev.inmo.tgbotapi.extensions.utils.asUser
|
import dev.inmo.tgbotapi.extensions.utils.asUser
|
||||||
|
import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.BaseChosenInlineResult
|
||||||
|
import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.ChosenInlineResult
|
||||||
|
import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.LocationChosenInlineResult
|
||||||
|
import dev.inmo.tgbotapi.types.InlineQueries.query.BaseInlineQuery
|
||||||
|
import dev.inmo.tgbotapi.types.InlineQueries.query.LocationInlineQuery
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
import dev.inmo.tgbotapi.types.chat.User
|
import dev.inmo.tgbotapi.types.chat.User
|
||||||
import dev.inmo.tgbotapi.types.update.ChatJoinRequestUpdate
|
import dev.inmo.tgbotapi.types.queries.callback.*
|
||||||
|
import dev.inmo.tgbotapi.types.update.*
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.BaseMessageUpdate
|
import dev.inmo.tgbotapi.types.update.abstracts.BaseMessageUpdate
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
import dev.inmo.tgbotapi.utils.PreviewFeature
|
import dev.inmo.tgbotapi.utils.PreviewFeature
|
||||||
|
|
||||||
|
fun CallbackQuery.sourceChat() = when (this) {
|
||||||
|
is InlineMessageIdDataCallbackQuery -> null
|
||||||
|
is MessageDataCallbackQuery -> message.chat
|
||||||
|
is InlineMessageIdGameShortNameCallbackQuery -> null
|
||||||
|
is MessageGameShortNameCallbackQuery -> message.chat
|
||||||
|
is UnknownCallbackQueryType -> null
|
||||||
|
}
|
||||||
|
|
||||||
@PreviewFeature
|
@PreviewFeature
|
||||||
fun Update.sourceChat(): Chat? = when (this) {
|
fun Update.sourceChatWithConverters(
|
||||||
is BaseMessageUpdate -> data.chat
|
baseMessageUpdateConverter: (BaseMessageUpdate) -> Chat? = { it.data.chat },
|
||||||
is ChatJoinRequestUpdate -> data.chat
|
chatJoinRequestUpdateConverter: (ChatJoinRequestUpdate) -> Chat? = { it.data.chat },
|
||||||
|
shippingQueryUpdateConverter: (ShippingQueryUpdate) -> Chat? = { null },
|
||||||
|
pollAnswerUpdateConverter: (PollAnswerUpdate) -> Chat? = { null },
|
||||||
|
preCheckoutQueryUpdateConverter: (PreCheckoutQueryUpdate) -> Chat? = { it.data.from },
|
||||||
|
callbackQueryUpdateConverter: (CallbackQueryUpdate) -> Chat? = { it.data.sourceChat() },
|
||||||
|
chosenInlineResultUpdateConverter: (ChosenInlineResultUpdate) -> Chat? = { null },
|
||||||
|
inlineQueryUpdateConverter: (InlineQueryUpdate) -> Chat? = { null },
|
||||||
|
pollUpdateConverter: (PollUpdate) -> Chat? = { null },
|
||||||
|
channelPostUpdateConverter: (ChannelPostUpdate) -> Chat? = { it.data.chat },
|
||||||
|
messageUpdateConverter: (MessageUpdate) -> Chat? = { it.data.chat },
|
||||||
|
editChannelPostUpdateConverter: (EditChannelPostUpdate) -> Chat? = { it.data.chat },
|
||||||
|
editMessageUpdateConverter: (EditMessageUpdate) -> Chat? = { it.data.chat },
|
||||||
|
myChatMemberUpdatedUpdateConverter: (MyChatMemberUpdatedUpdate) -> Chat? = { it.data.chat },
|
||||||
|
commonChatMemberUpdatedUpdateConverter: (CommonChatMemberUpdatedUpdate) -> Chat? = { it.data.chat }
|
||||||
|
): Chat? = when (this) {
|
||||||
|
is BaseMessageUpdate -> baseMessageUpdateConverter(this)
|
||||||
|
is ChatJoinRequestUpdate -> chatJoinRequestUpdateConverter(this)
|
||||||
|
is ShippingQueryUpdate -> shippingQueryUpdateConverter(this)
|
||||||
|
is PollAnswerUpdate -> pollAnswerUpdateConverter(this)
|
||||||
|
is PreCheckoutQueryUpdate -> preCheckoutQueryUpdateConverter(this)
|
||||||
|
is CallbackQueryUpdate -> callbackQueryUpdateConverter(this)
|
||||||
|
is ChosenInlineResultUpdate -> chosenInlineResultUpdateConverter(this)
|
||||||
|
is InlineQueryUpdate -> inlineQueryUpdateConverter(this)
|
||||||
|
is PollUpdate -> pollUpdateConverter(this)
|
||||||
|
is ChannelPostUpdate -> channelPostUpdateConverter(this)
|
||||||
|
is MessageUpdate -> messageUpdateConverter(this)
|
||||||
|
is EditChannelPostUpdate -> editChannelPostUpdateConverter(this)
|
||||||
|
is EditMessageUpdate -> editMessageUpdateConverter(this)
|
||||||
|
is MyChatMemberUpdatedUpdate -> myChatMemberUpdatedUpdateConverter(this)
|
||||||
|
is CommonChatMemberUpdatedUpdate -> commonChatMemberUpdatedUpdateConverter(this)
|
||||||
else -> {
|
else -> {
|
||||||
when (val data = data) {
|
when (val data = data) {
|
||||||
is FromUser -> data.from
|
is FromUser -> data.from
|
||||||
@@ -23,6 +66,9 @@ fun Update.sourceChat(): Chat? = when (this) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PreviewFeature
|
||||||
|
fun Update.sourceChat(): Chat? = sourceChatWithConverters()
|
||||||
|
|
||||||
@PreviewFeature
|
@PreviewFeature
|
||||||
fun Update.sourceUser(): User? = when (val data = data) {
|
fun Update.sourceUser(): User? = when (val data = data) {
|
||||||
is FromUser -> data.from
|
is FromUser -> data.from
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import io.ktor.http.encodeURLQueryComponent
|
|||||||
|
|
||||||
|
|
||||||
fun makeUsernameLink(username: String, threadId: MessageThreadId? = null) = "$internalLinkBeginning/$username${threadId ?.let { "/$it" } ?: ""}"
|
fun makeUsernameLink(username: String, threadId: MessageThreadId? = null) = "$internalLinkBeginning/$username${threadId ?.let { "/$it" } ?: ""}"
|
||||||
|
fun makeInternalTgUsernameLink(username: String) = "${internalTgAppLinksBeginning}resolve?domain=$username"
|
||||||
fun makeUserLink(userId: UserId) = userId.userLink
|
fun makeUserLink(userId: UserId) = userId.userLink
|
||||||
fun makeChatLink(identifier: Identifier, threadId: MessageThreadId? = null) = identifier.toString().replace(
|
fun makeChatLink(identifier: Identifier, threadId: MessageThreadId? = null) = identifier.toString().replace(
|
||||||
linkIdRedundantPartRegex,
|
linkIdRedundantPartRegex,
|
||||||
@@ -16,6 +17,7 @@ fun makeChatLink(identifier: Identifier, threadId: MessageThreadId? = null) = id
|
|||||||
"$internalLinkBeginning/c/$bareId${threadId ?.let { "/$it" } ?: ""}"
|
"$internalLinkBeginning/c/$bareId${threadId ?.let { "/$it" } ?: ""}"
|
||||||
}
|
}
|
||||||
fun makeUsernameDeepLinkPrefix(username: String) = "${makeUsernameLink(username)}?start="
|
fun makeUsernameDeepLinkPrefix(username: String) = "${makeUsernameLink(username)}?start="
|
||||||
|
fun makeInternalTgUsernameDeepLinkPrefix(username: String) = "${makeInternalTgUsernameLink(username)}&start="
|
||||||
fun makeUsernameStartattachPrefix(username: String) = "$internalLinkBeginning/$username?startattach"
|
fun makeUsernameStartattachPrefix(username: String) = "$internalLinkBeginning/$username?startattach"
|
||||||
fun makeUsernameStartattachLink(username: String, data: String? = null) = "${makeUsernameStartattachPrefix(username)}${data?.let { "=$it" } ?: ""}"
|
fun makeUsernameStartattachLink(username: String, data: String? = null) = "${makeUsernameStartattachPrefix(username)}${data?.let { "=$it" } ?: ""}"
|
||||||
inline val Username.usernameLink
|
inline val Username.usernameLink
|
||||||
@@ -30,6 +32,9 @@ inline val Username.startattachPrefix
|
|||||||
get() = makeUsernameStartattachPrefix(usernameWithoutAt)
|
get() = makeUsernameStartattachPrefix(usernameWithoutAt)
|
||||||
inline fun makeLink(username: Username, threadId: MessageThreadId? = null) = username.link(threadId)
|
inline fun makeLink(username: Username, threadId: MessageThreadId? = null) = username.link(threadId)
|
||||||
inline fun makeTelegramDeepLink(username: String, startParameter: String) = "${makeUsernameDeepLinkPrefix(username)}$startParameter".encodeURLQueryComponent()
|
inline fun makeTelegramDeepLink(username: String, startParameter: String) = "${makeUsernameDeepLinkPrefix(username)}$startParameter".encodeURLQueryComponent()
|
||||||
|
inline fun makeInternalTgDeepLink(username: String, startParameter: String) = "${makeInternalTgUsernameDeepLinkPrefix(username)}$startParameter".encodeURLQueryComponent()
|
||||||
|
inline fun makeInternalTgDeepLink(username: Username, startParameter: String) =
|
||||||
|
makeInternalTgDeepLink(username.usernameWithoutAt, startParameter)
|
||||||
inline fun makeTelegramStartattach(username: String, data: String? = null) = makeUsernameStartattachLink(username, data)
|
inline fun makeTelegramStartattach(username: String, data: String? = null) = makeUsernameStartattachLink(username, data)
|
||||||
inline fun makeDeepLink(username: Username, startParameter: String) = makeTelegramDeepLink(username.usernameWithoutAt, startParameter)
|
inline fun makeDeepLink(username: Username, startParameter: String) = makeTelegramDeepLink(username.usernameWithoutAt, startParameter)
|
||||||
inline fun makeTelegramDeepLink(username: Username, startParameter: String) = makeDeepLink(username, startParameter)
|
inline fun makeTelegramDeepLink(username: Username, startParameter: String) = makeDeepLink(username, startParameter)
|
||||||
|
|||||||
@@ -120,6 +120,11 @@ fun FlowsUpdatesFilter.textMessages(
|
|||||||
scopeToIncludeChannels: CoroutineScope? = null
|
scopeToIncludeChannels: CoroutineScope? = null
|
||||||
) = filterContentMessages<TextContent>(scopeToIncludeChannels)
|
) = filterContentMessages<TextContent>(scopeToIncludeChannels)
|
||||||
|
|
||||||
|
fun Flow<BaseSentMessageUpdate>.storyMessages() = filterContentMessages<StoryContent>()
|
||||||
|
fun FlowsUpdatesFilter.storyMessages(
|
||||||
|
scopeToIncludeChannels: CoroutineScope? = null
|
||||||
|
) = filterContentMessages<StoryContent>(scopeToIncludeChannels)
|
||||||
|
|
||||||
fun Flow<BaseSentMessageUpdate>.venueMessages() = filterContentMessages<VenueContent>()
|
fun Flow<BaseSentMessageUpdate>.venueMessages() = filterContentMessages<VenueContent>()
|
||||||
fun FlowsUpdatesFilter.venueMessages(
|
fun FlowsUpdatesFilter.venueMessages(
|
||||||
scopeToIncludeChannels: CoroutineScope? = null
|
scopeToIncludeChannels: CoroutineScope? = null
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package dev.inmo.tgbotapi.extensions.utils.types.buttons
|
|||||||
import dev.inmo.tgbotapi.types.buttons.*
|
import dev.inmo.tgbotapi.types.buttons.*
|
||||||
import dev.inmo.tgbotapi.types.buttons.reply.requestChatReplyButton
|
import dev.inmo.tgbotapi.types.buttons.reply.requestChatReplyButton
|
||||||
import dev.inmo.tgbotapi.types.buttons.reply.requestUserReplyButton
|
import dev.inmo.tgbotapi.types.buttons.reply.requestUserReplyButton
|
||||||
import dev.inmo.tgbotapi.types.chat.member.ChatAdministratorRights
|
import dev.inmo.tgbotapi.types.chat.member.ChatCommonAdministratorRights
|
||||||
import dev.inmo.tgbotapi.types.request.RequestId
|
import dev.inmo.tgbotapi.types.request.RequestId
|
||||||
import dev.inmo.tgbotapi.types.webapps.WebAppInfo
|
import dev.inmo.tgbotapi.types.webapps.WebAppInfo
|
||||||
import dev.inmo.tgbotapi.utils.*
|
import dev.inmo.tgbotapi.utils.*
|
||||||
@@ -220,8 +220,8 @@ inline fun ReplyKeyboardRowBuilder.requestChatButton(
|
|||||||
isForum: Boolean? = null,
|
isForum: Boolean? = null,
|
||||||
isPublic: Boolean? = null,
|
isPublic: Boolean? = null,
|
||||||
isOwnedBy: Boolean? = null,
|
isOwnedBy: Boolean? = null,
|
||||||
userRightsInChat: ChatAdministratorRights? = null,
|
userRightsInChat: ChatCommonAdministratorRights? = null,
|
||||||
botRightsInChat: ChatAdministratorRights? = null,
|
botRightsInChat: ChatCommonAdministratorRights? = null,
|
||||||
botIsMember: Boolean? = null
|
botIsMember: Boolean? = null
|
||||||
) = requestChatButton(
|
) = requestChatButton(
|
||||||
text,
|
text,
|
||||||
@@ -248,8 +248,8 @@ inline fun ReplyKeyboardRowBuilder.requestChannelButton(
|
|||||||
requestId: RequestId,
|
requestId: RequestId,
|
||||||
isPublic: Boolean? = null,
|
isPublic: Boolean? = null,
|
||||||
isOwnedBy: Boolean? = null,
|
isOwnedBy: Boolean? = null,
|
||||||
userRightsInChat: ChatAdministratorRights? = null,
|
userRightsInChat: ChatCommonAdministratorRights? = null,
|
||||||
botRightsInChat: ChatAdministratorRights? = null,
|
botRightsInChat: ChatCommonAdministratorRights? = null,
|
||||||
botIsMember: Boolean? = null
|
botIsMember: Boolean? = null
|
||||||
) = requestChatButton(
|
) = requestChatButton(
|
||||||
text,
|
text,
|
||||||
@@ -275,8 +275,8 @@ inline fun ReplyKeyboardRowBuilder.requestGroupButton(
|
|||||||
isForum: Boolean? = null,
|
isForum: Boolean? = null,
|
||||||
isPublic: Boolean? = null,
|
isPublic: Boolean? = null,
|
||||||
isOwnedBy: Boolean? = null,
|
isOwnedBy: Boolean? = null,
|
||||||
userRightsInChat: ChatAdministratorRights? = null,
|
userRightsInChat: ChatCommonAdministratorRights? = null,
|
||||||
botRightsInChat: ChatAdministratorRights? = null,
|
botRightsInChat: ChatCommonAdministratorRights? = null,
|
||||||
botIsMember: Boolean? = null
|
botIsMember: Boolean? = null
|
||||||
) = requestChatButton(
|
) = requestChatButton(
|
||||||
text,
|
text,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import dev.inmo.tgbotapi.utils.extensions.asMediaGroupMessage
|
|||||||
* @see [Update.lastUpdateIdentifier]
|
* @see [Update.lastUpdateIdentifier]
|
||||||
*/
|
*/
|
||||||
fun List<Update>.lastUpdateIdentifier(): UpdateIdentifier? {
|
fun List<Update>.lastUpdateIdentifier(): UpdateIdentifier? {
|
||||||
return maxByOrNull { it.updateId } ?.updateId
|
return maxByOrNull { it.updateId } ?.updateId ?.takeIf { it > -1 }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.bot.TelegramBot
|
|||||||
import dev.inmo.tgbotapi.bot.exceptions.*
|
import dev.inmo.tgbotapi.bot.exceptions.*
|
||||||
import dev.inmo.tgbotapi.extensions.utils.updates.convertWithMediaGroupUpdates
|
import dev.inmo.tgbotapi.extensions.utils.updates.convertWithMediaGroupUpdates
|
||||||
import dev.inmo.tgbotapi.requests.GetUpdates
|
import dev.inmo.tgbotapi.requests.GetUpdates
|
||||||
|
import dev.inmo.tgbotapi.requests.GetUpdatesRaw
|
||||||
import dev.inmo.tgbotapi.requests.webhook.DeleteWebhook
|
import dev.inmo.tgbotapi.requests.webhook.DeleteWebhook
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||||
@@ -91,7 +92,9 @@ fun TelegramBot.longPollingFlow(
|
|||||||
for (update in updates) {
|
for (update in updates) {
|
||||||
send(update)
|
send(update)
|
||||||
|
|
||||||
lastUpdateIdentifier = update.updateId
|
if (update.updateId > -1) {
|
||||||
|
lastUpdateIdentifier = update.updateId
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}.onFailure {
|
}.onFailure {
|
||||||
cancel(it as? CancellationException ?: return@onFailure)
|
cancel(it as? CancellationException ?: return@onFailure)
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ sealed interface Color {
|
|||||||
value class BackgroundColor(override val value: String) : Color
|
value class BackgroundColor(override val value: String) : Color
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
value class Hex(override val value: String) : Color
|
value class Hex(override val value: String) : Color {
|
||||||
|
constructor(r: UByte, g: UByte, b: UByte) : this("#${r.toString(16).padStart(2, '0')}${g.toString(16).padStart(2, '0')}${b.toString(16).padStart(2, '0')}")
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val BackgroundColor = BackgroundColor("bg_color")
|
val BackgroundColor = BackgroundColor("bg_color")
|
||||||
|
|||||||
@@ -8,3 +8,5 @@ typealias InvoiceClosedEventHandler = WebApp.(InvoiceClosedInfo) -> Unit
|
|||||||
typealias PopupClosedEventHandler = WebApp.(String?) -> Unit
|
typealias PopupClosedEventHandler = WebApp.(String?) -> Unit
|
||||||
typealias QRTextReceivedEventHandler = WebApp.(String) -> Boolean
|
typealias QRTextReceivedEventHandler = WebApp.(String) -> Boolean
|
||||||
typealias TextReceivedEventHandler = WebApp.(String) -> Unit
|
typealias TextReceivedEventHandler = WebApp.(String) -> Unit
|
||||||
|
typealias WriteAccessRequestedHandler = WebApp.(Boolean) -> Unit
|
||||||
|
typealias ContactRequestedHandler = WebApp.(Boolean) -> Unit
|
||||||
|
|||||||
@@ -10,4 +10,6 @@ sealed class EventType(val typeName: String) {
|
|||||||
object PopupClosed : EventType("popupClosed")
|
object PopupClosed : EventType("popupClosed")
|
||||||
object QRTextReceived : EventType("qrTextReceived")
|
object QRTextReceived : EventType("qrTextReceived")
|
||||||
object ClipboardTextReceived : EventType("clipboardTextReceived")
|
object ClipboardTextReceived : EventType("clipboardTextReceived")
|
||||||
|
object WriteAccessRequested : EventType("writeAccessRequested")
|
||||||
|
object ContactRequested : EventType("contactRequested")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package dev.inmo.tgbotapi.webapps
|
||||||
|
|
||||||
|
external interface RequestStatus {
|
||||||
|
val status: String
|
||||||
|
}
|
||||||
|
|
||||||
|
inline val RequestStatus.isCancelled: Boolean
|
||||||
|
get() = status == "cancelled"
|
||||||
|
|
||||||
|
inline val RequestStatus.isAllowed: Boolean
|
||||||
|
get() = status == "allowed"
|
||||||
|
|
||||||
|
inline val RequestStatus.isSent: Boolean
|
||||||
|
get() = status == "sent"
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
package dev.inmo.tgbotapi.webapps
|
package dev.inmo.tgbotapi.webapps
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
||||||
|
import dev.inmo.tgbotapi.webapps.cloud.CloudStorage
|
||||||
import dev.inmo.tgbotapi.webapps.haptic.HapticFeedback
|
import dev.inmo.tgbotapi.webapps.haptic.HapticFeedback
|
||||||
import dev.inmo.tgbotapi.webapps.invoice.InvoiceClosedInfo
|
import dev.inmo.tgbotapi.webapps.invoice.InvoiceClosedInfo
|
||||||
import dev.inmo.tgbotapi.webapps.popup.*
|
import dev.inmo.tgbotapi.webapps.popup.*
|
||||||
|
import kotlin.js.Json
|
||||||
|
|
||||||
external class WebApp {
|
external class WebApp {
|
||||||
val version: String
|
val version: String
|
||||||
@@ -15,6 +17,7 @@ external class WebApp {
|
|||||||
|
|
||||||
val headerColor: HEXColor?
|
val headerColor: HEXColor?
|
||||||
fun setHeaderColor(color: Color.BackgroundColor)
|
fun setHeaderColor(color: Color.BackgroundColor)
|
||||||
|
fun setHeaderColor(color: Color.Hex)
|
||||||
val backgroundColor: HEXColor?
|
val backgroundColor: HEXColor?
|
||||||
fun setBackgroundColor(color: Color.Hex)
|
fun setBackgroundColor(color: Color.Hex)
|
||||||
fun setBackgroundColor(color: Color.BackgroundColor)
|
fun setBackgroundColor(color: Color.BackgroundColor)
|
||||||
@@ -48,6 +51,9 @@ external class WebApp {
|
|||||||
@JsName("HapticFeedback")
|
@JsName("HapticFeedback")
|
||||||
val hapticFeedback: HapticFeedback
|
val hapticFeedback: HapticFeedback
|
||||||
|
|
||||||
|
@JsName("CloudStorage")
|
||||||
|
val cloudStorage: CloudStorage
|
||||||
|
|
||||||
internal fun onEvent(type: String, callback: () -> Unit)
|
internal fun onEvent(type: String, callback: () -> Unit)
|
||||||
@JsName("onEvent")
|
@JsName("onEvent")
|
||||||
internal fun onEventWithViewportChangedData(type: String, callback: (ViewportChangedData) -> Unit)
|
internal fun onEventWithViewportChangedData(type: String, callback: (ViewportChangedData) -> Unit)
|
||||||
@@ -59,6 +65,10 @@ external class WebApp {
|
|||||||
internal fun onEventWithQRTextInfo(type: String, callback: (String) -> Boolean)
|
internal fun onEventWithQRTextInfo(type: String, callback: (String) -> Boolean)
|
||||||
@JsName("onEvent")
|
@JsName("onEvent")
|
||||||
internal fun onEventWithTextInfo(type: String, callback: (String) -> Unit)
|
internal fun onEventWithTextInfo(type: String, callback: (String) -> Unit)
|
||||||
|
@JsName("onEvent")
|
||||||
|
internal fun onEventWithWriteAccessRequested(type: String, callback: (RequestStatus) -> Unit)
|
||||||
|
@JsName("onEvent")
|
||||||
|
internal fun onEventWithContactRequested(type: String, callback: (RequestStatus) -> Unit)
|
||||||
|
|
||||||
fun offEvent(type: String, callback: () -> Unit)
|
fun offEvent(type: String, callback: () -> Unit)
|
||||||
@JsName("offEvent")
|
@JsName("offEvent")
|
||||||
@@ -76,6 +86,9 @@ external class WebApp {
|
|||||||
fun openLink(url: String)
|
fun openLink(url: String)
|
||||||
fun openTelegramLink(url: String)
|
fun openTelegramLink(url: String)
|
||||||
fun openInvoice(url: String, callback: (InvoiceClosedInfo) -> Unit = definedExternally)
|
fun openInvoice(url: String, callback: (InvoiceClosedInfo) -> Unit = definedExternally)
|
||||||
|
|
||||||
|
fun requestWriteAccess(callback: ((Boolean) -> Unit)? = definedExternally)
|
||||||
|
fun requestContact(callback: ((Boolean) -> Unit)? = definedExternally)
|
||||||
}
|
}
|
||||||
|
|
||||||
val WebApp.colorScheme: ColorScheme
|
val WebApp.colorScheme: ColorScheme
|
||||||
@@ -157,6 +170,30 @@ fun WebApp.onEvent(type: EventType.ClipboardTextReceived, eventHandler: TextRece
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The callback which should be used in case you want to turn off events handling
|
||||||
|
*/
|
||||||
|
fun WebApp.onEvent(type: EventType.WriteAccessRequested, eventHandler: WriteAccessRequestedHandler) = { it: RequestStatus ->
|
||||||
|
eventHandler(js("this").unsafeCast<WebApp>(), it.isAllowed)
|
||||||
|
}.also {
|
||||||
|
onEventWithWriteAccessRequested(
|
||||||
|
type.typeName,
|
||||||
|
callback = it
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The callback which should be used in case you want to turn off events handling
|
||||||
|
*/
|
||||||
|
fun WebApp.onEvent(type: EventType.ContactRequested, eventHandler: ContactRequestedHandler) = { it: RequestStatus ->
|
||||||
|
eventHandler(js("this").unsafeCast<WebApp>(), it.isSent)
|
||||||
|
}.also {
|
||||||
|
onEventWithContactRequested(
|
||||||
|
type.typeName,
|
||||||
|
callback = it
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The callback which should be used in case you want to turn off events handling
|
* @return The callback which should be used in case you want to turn off events handling
|
||||||
*/
|
*/
|
||||||
@@ -193,6 +230,14 @@ fun WebApp.onQRTextReceived(eventHandler: QRTextReceivedEventHandler) = onEvent(
|
|||||||
* @return The callback which should be used in case you want to turn off events handling
|
* @return The callback which should be used in case you want to turn off events handling
|
||||||
*/
|
*/
|
||||||
fun WebApp.onClipboardTextReceived(eventHandler: TextReceivedEventHandler) = onEvent(EventType.ClipboardTextReceived, eventHandler)
|
fun WebApp.onClipboardTextReceived(eventHandler: TextReceivedEventHandler) = onEvent(EventType.ClipboardTextReceived, eventHandler)
|
||||||
|
/**
|
||||||
|
* @return The callback which should be used in case you want to turn off events handling
|
||||||
|
*/
|
||||||
|
fun WebApp.onWriteAccessRequested(eventHandler: WriteAccessRequestedHandler) = onEvent(EventType.WriteAccessRequested, eventHandler)
|
||||||
|
/**
|
||||||
|
* @return The callback which should be used in case you want to turn off events handling
|
||||||
|
*/
|
||||||
|
fun WebApp.onContactRequested(eventHandler: ContactRequestedHandler) = onEvent(EventType.ContactRequested, eventHandler)
|
||||||
|
|
||||||
fun WebApp.isInitDataSafe(botToken: String) = TelegramAPIUrlsKeeper(botToken).checkWebAppData(
|
fun WebApp.isInitDataSafe(botToken: String) = TelegramAPIUrlsKeeper(botToken).checkWebAppData(
|
||||||
initData,
|
initData,
|
||||||
|
|||||||
@@ -20,6 +20,10 @@ external interface WebAppUser {
|
|||||||
val is_premium: Boolean?
|
val is_premium: Boolean?
|
||||||
@JsName(photoUrlField)
|
@JsName(photoUrlField)
|
||||||
val photoUrl: String?
|
val photoUrl: String?
|
||||||
|
@JsName(addedToAttachmentMenuField)
|
||||||
|
val addedToAttachmentMenu: Boolean?
|
||||||
|
@JsName(allowsWriteToPMField)
|
||||||
|
val allowsWriteToPM: Boolean?
|
||||||
}
|
}
|
||||||
|
|
||||||
val WebAppUser.isPremium
|
val WebAppUser.isPremium
|
||||||
@@ -27,18 +31,18 @@ val WebAppUser.isPremium
|
|||||||
|
|
||||||
fun WebAppUser.asUser() = if (isBot == true) {
|
fun WebAppUser.asUser() = if (isBot == true) {
|
||||||
CommonBot(
|
CommonBot(
|
||||||
UserId(id),
|
id = UserId(id),
|
||||||
username ?.let(::Username) ?: error("Username is absent for bot, but must exists"),
|
firstName = firstName,
|
||||||
firstName,
|
lastName = lastName ?: "",
|
||||||
lastName ?: ""
|
username = username ?.let(::Username)
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
CommonUser(
|
CommonUser(
|
||||||
UserId(id),
|
id = UserId(id),
|
||||||
firstName,
|
firstName = firstName,
|
||||||
lastName ?: "",
|
lastName = lastName ?: "",
|
||||||
username ?.let(::Username),
|
username = username ?.let(::Username),
|
||||||
languageCode ?.let(::IetfLanguageCode),
|
ietfLanguageCode = languageCode ?.let(::IetfLanguageCode),
|
||||||
isPremium = isPremium
|
isPremium = isPremium
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,139 @@
|
|||||||
|
package dev.inmo.tgbotapi.webapps.cloud
|
||||||
|
|
||||||
|
import kotlin.js.Json
|
||||||
|
|
||||||
|
external interface CloudStorage {
|
||||||
|
fun setItem(
|
||||||
|
key: CloudStorageKey,
|
||||||
|
value: CloudStorageValue,
|
||||||
|
callback: (e: Any?, success: Boolean?) -> Unit = definedExternally
|
||||||
|
): CloudStorage
|
||||||
|
fun getItem(
|
||||||
|
key: CloudStorageKey,
|
||||||
|
callback: (e: Any?, value: CloudStorageValue?) -> Unit
|
||||||
|
): CloudStorage
|
||||||
|
fun getItems(
|
||||||
|
key: Array<CloudStorageKey>,
|
||||||
|
callback: (e: Any?, values: Array<CloudStorageValue>?) -> Unit
|
||||||
|
): CloudStorage
|
||||||
|
fun removeItem(
|
||||||
|
key: CloudStorageKey,
|
||||||
|
callback: (e: Any?, success: Boolean?) -> Unit
|
||||||
|
): CloudStorage
|
||||||
|
fun removeItems(
|
||||||
|
key: Array<CloudStorageKey>,
|
||||||
|
callback: (e: Any?, success: Boolean?) -> Unit
|
||||||
|
): CloudStorage
|
||||||
|
fun getKeys(
|
||||||
|
callback: (e: Any?, success: Array<CloudStorageKey>?) -> Unit
|
||||||
|
): CloudStorage
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun <T> resultsToResult(e: Any?, v: T?): Result<T> = when {
|
||||||
|
e != null -> Result.failure(IllegalStateException(JSON.stringify(e)))
|
||||||
|
v != null -> Result.success(v)
|
||||||
|
else -> Result.failure(IllegalStateException("Both value and e"))
|
||||||
|
}
|
||||||
|
|
||||||
|
fun CloudStorage.set(
|
||||||
|
key: String,
|
||||||
|
value: String,
|
||||||
|
callback: (result: Result<Boolean>) -> Unit = {}
|
||||||
|
) = setItem(CloudStorageKey(key), CloudStorageValue(value)) { e, v -> callback(resultsToResult(e, v)) }
|
||||||
|
|
||||||
|
fun CloudStorage.get(
|
||||||
|
key: CloudStorageKey,
|
||||||
|
callback: (result: Result<CloudStorageValue>) -> Unit
|
||||||
|
) = getItem(key) { e, v -> callback(resultsToResult(e, v)) }
|
||||||
|
|
||||||
|
fun CloudStorage.get(
|
||||||
|
key: String,
|
||||||
|
callback: (result: Result<CloudStorageValue>) -> Unit
|
||||||
|
) = get(CloudStorageKey(key), callback)
|
||||||
|
|
||||||
|
fun CloudStorage.get(
|
||||||
|
keys: Array<CloudStorageKey>,
|
||||||
|
callback: (result: Result<Array<CloudStorageValue>>) -> Unit
|
||||||
|
) = getItems(
|
||||||
|
keys
|
||||||
|
) { e, v -> callback(resultsToResult(e, v)) }
|
||||||
|
|
||||||
|
fun CloudStorage.get(
|
||||||
|
keys: Array<String>,
|
||||||
|
callback: (result: Result<Array<CloudStorageValue>>) -> Unit
|
||||||
|
) = get(
|
||||||
|
Array(keys.size) {
|
||||||
|
CloudStorageKey(keys[it])
|
||||||
|
},
|
||||||
|
callback
|
||||||
|
)
|
||||||
|
|
||||||
|
fun CloudStorage.get(
|
||||||
|
key: String,
|
||||||
|
key2: String,
|
||||||
|
vararg otherKeys: String,
|
||||||
|
callback: (result: Result<Array<CloudStorageValue>>) -> Unit
|
||||||
|
) = get(
|
||||||
|
arrayOf(key, key2) + otherKeys,
|
||||||
|
callback
|
||||||
|
)
|
||||||
|
|
||||||
|
fun CloudStorage.remove(
|
||||||
|
key: CloudStorageKey,
|
||||||
|
callback: (result: Result<Boolean>) -> Unit
|
||||||
|
) = removeItem(key) { e, v -> callback(resultsToResult(e, v)) }
|
||||||
|
|
||||||
|
fun CloudStorage.remove(
|
||||||
|
key: String,
|
||||||
|
callback: (result: Result<Boolean>) -> Unit
|
||||||
|
) = remove(CloudStorageKey(key), callback)
|
||||||
|
|
||||||
|
fun CloudStorage.remove(
|
||||||
|
keys: Array<CloudStorageKey>,
|
||||||
|
callback: (result: Result<Boolean>) -> Unit
|
||||||
|
) = removeItems(
|
||||||
|
keys
|
||||||
|
) { e, v -> callback(resultsToResult(e, v)) }
|
||||||
|
|
||||||
|
fun CloudStorage.remove(
|
||||||
|
keys: Array<String>,
|
||||||
|
callback: (result: Result<Boolean>) -> Unit
|
||||||
|
) = remove(
|
||||||
|
Array(keys.size) {
|
||||||
|
CloudStorageKey(keys[it])
|
||||||
|
},
|
||||||
|
callback
|
||||||
|
)
|
||||||
|
|
||||||
|
fun CloudStorage.remove(
|
||||||
|
key: String,
|
||||||
|
key2: String,
|
||||||
|
vararg otherKeys: String,
|
||||||
|
callback: (result: Result<Boolean>) -> Unit
|
||||||
|
) = remove(
|
||||||
|
arrayOf(key, key2) + otherKeys,
|
||||||
|
callback
|
||||||
|
)
|
||||||
|
|
||||||
|
fun CloudStorage.keys(
|
||||||
|
callback: (result: Result<Array<CloudStorageKey>>) -> Unit
|
||||||
|
) = getKeys { e, v -> callback(resultsToResult(e, v)) }
|
||||||
|
|
||||||
|
fun CloudStorage.getAll(callback: (result: Result<Map<CloudStorageKey, CloudStorageValue>>) -> Unit) = keys {
|
||||||
|
it.onSuccess { keys ->
|
||||||
|
console.log(keys)
|
||||||
|
get(keys) {
|
||||||
|
it.onSuccess { values ->
|
||||||
|
console.log(values)
|
||||||
|
val resultMap = keys.withIndex().mapNotNull { (i, it) ->
|
||||||
|
it to (values.getOrNull(i) ?: return@mapNotNull null)
|
||||||
|
}.toMap()
|
||||||
|
callback(Result.success(resultMap))
|
||||||
|
}.onFailure {
|
||||||
|
callback(Result.failure(it))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.onFailure {
|
||||||
|
callback(Result.failure(it))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package dev.inmo.tgbotapi.webapps.cloud
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.cloudStorageKeyRegex
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
value class CloudStorageKey(val key: String) {
|
||||||
|
init {
|
||||||
|
require(key.matches(cloudStorageKeyRegex)) {
|
||||||
|
"'$key' must pass $cloudStorageKeyRegex in case you wish to use it as key for cloud storage operations"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package dev.inmo.tgbotapi.webapps.cloud
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.cloudStorageKeyRegex
|
||||||
|
import dev.inmo.tgbotapi.types.cloudStorageValueRegex
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
value class CloudStorageValue(val value: String) {
|
||||||
|
init {
|
||||||
|
require(value.matches(cloudStorageValueRegex)) {
|
||||||
|
"'$value' must pass $cloudStorageValueRegex in case you wish to use it as key for cloud storage operations"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user