mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-09-03 23:29:33 +00:00
add new type of chats ids
This commit is contained in:
@@ -160,10 +160,10 @@ inline val Message.supergroup_chat_created: Boolean
|
||||
inline val Message.channel_chat_created: Boolean
|
||||
get() = asChatEventMessage() ?.chatEvent is ChannelChatCreated
|
||||
@RiskFeature(RawFieldsUsageWarning)
|
||||
inline val Message.migrate_to_chat_id: ChatId?
|
||||
inline val Message.migrate_to_chat_id: IdChatIdentifier?
|
||||
get() = asChatEventMessage() ?.chatEvent ?.asGroupChatCreated() ?.migratedTo
|
||||
@RiskFeature(RawFieldsUsageWarning)
|
||||
inline val Message.migrate_from_chat_id: ChatId?
|
||||
inline val Message.migrate_from_chat_id: IdChatIdentifier?
|
||||
get() = asChatEventMessage() ?.chatEvent ?.let {
|
||||
it ?.asSupergroupChatCreated() ?.migratedFrom ?: it ?.asMigratedToSupergroup() ?.migratedFrom
|
||||
}
|
||||
|
@@ -200,7 +200,7 @@ infix fun String.mention(parseMode: ParseMode): String = when (parseMode) {
|
||||
is MarkdownV2 -> mentionMarkdownV2()
|
||||
}
|
||||
|
||||
infix fun Pair<String, ChatId>.mention(parseMode: ParseMode): String = when (parseMode) {
|
||||
infix fun Pair<String, IdChatIdentifier>.mention(parseMode: ParseMode): String = when (parseMode) {
|
||||
is HTML -> first.textMentionHTML(second)
|
||||
is Markdown -> first.textMentionMarkdown(second)
|
||||
is MarkdownV2 -> first.textMentionMarkdownV2(second)
|
||||
|
@@ -1,16 +1,16 @@
|
||||
package dev.inmo.tgbotapi.extensions.utils.updates
|
||||
|
||||
import dev.inmo.tgbotapi.types.ChatId
|
||||
import dev.inmo.tgbotapi.types.IdChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.BaseMessageUpdate
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.filter
|
||||
|
||||
/**
|
||||
* [Flow.filter] incoming [BaseMessageUpdate]s by their [ChatId]
|
||||
* [Flow.filter] incoming [BaseMessageUpdate]s by their [IdChatIdentifier]
|
||||
*/
|
||||
fun <T : BaseMessageUpdate> Flow<T>.filterBaseMessageUpdatesByChatId(chatId: ChatId): Flow<T> = filter { it.data.chat.id == chatId }
|
||||
fun <T : BaseMessageUpdate> Flow<T>.filterBaseMessageUpdatesByChatId(chatId: IdChatIdentifier): Flow<T> = filter { it.data.chat.id == chatId }
|
||||
/**
|
||||
* [Flow.filter] incoming [BaseMessageUpdate]s by their [ChatId] using [Chat.id] of [chat]
|
||||
* [Flow.filter] incoming [BaseMessageUpdate]s by their [IdChatIdentifier] using [Chat.id] of [chat]
|
||||
*/
|
||||
fun <T : BaseMessageUpdate> Flow<T>.filterBaseMessageUpdatesByChat(chat: Chat): Flow<T> = filterBaseMessageUpdatesByChatId(chat.id)
|
||||
|
Reference in New Issue
Block a user