mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-26 03:58:44 +00:00
chat methods now have additional usefull extensions
This commit is contained in:
parent
2eb2d25662
commit
527b718f55
@ -1,6 +1,7 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
||||
@ -18,3 +19,7 @@ data class ExportChatInviteLink(
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
suspend fun RequestsExecutor.exportChatInviteLink(
|
||||
chatId: ChatIdentifier
|
||||
) = execute(ExportChatInviteLink(chatId))
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
||||
@ -18,3 +19,7 @@ data class LeaveChat(
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
suspend fun RequestsExecutor.leaveChat(
|
||||
chatId: ChatIdentifier
|
||||
) = execute(LeaveChat(chatId))
|
||||
|
@ -1,9 +1,11 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.get
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ExtendedChatSerializer
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.extended.ExtendedChat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
||||
import kotlinx.serialization.*
|
||||
@ -19,3 +21,11 @@ data class GetChat(
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
suspend fun RequestsExecutor.getChat(
|
||||
chatId: ChatIdentifier
|
||||
) = execute(GetChat(chatId))
|
||||
|
||||
suspend fun RequestsExecutor.getChat(
|
||||
chat: Chat
|
||||
) = getChat(chat.id)
|
||||
|
@ -1,10 +1,12 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.get
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.AdministratorChatMember
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.AdministratorChatMemberSerializerWithoutDeserialization
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.ArrayListSerializer
|
||||
@ -24,3 +26,11 @@ data class GetChatAdministrators(
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
suspend fun RequestsExecutor.getChatAdministrators(
|
||||
chatId: ChatIdentifier
|
||||
) = execute(GetChatAdministrators(chatId))
|
||||
|
||||
suspend fun RequestsExecutor.getChatAdministrators(
|
||||
chat: Chat
|
||||
) = getChatAdministrators(chat.id)
|
||||
|
@ -1,8 +1,10 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.get
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.IntSerializer
|
||||
@ -18,3 +20,11 @@ data class GetChatMembersCount(
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
suspend fun RequestsExecutor.getChatMembersCount(
|
||||
chatId: ChatIdentifier
|
||||
) = execute(GetChatMembersCount(chatId))
|
||||
|
||||
suspend fun RequestsExecutor.getChatMembersCount(
|
||||
chat: Chat
|
||||
) = getChatMembersCount(chat.id)
|
||||
|
@ -1,9 +1,12 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.abstracts.ChatMemberRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.get.getChatMembersCount
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.ChatMember
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.ChatMemberDeserializationStrategy
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
@ -19,3 +22,23 @@ data class GetChatMember(
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
suspend fun RequestsExecutor.getChatMember(
|
||||
chatId: ChatIdentifier,
|
||||
userId: UserId
|
||||
) = execute(GetChatMember(chatId, userId))
|
||||
|
||||
suspend fun RequestsExecutor.getChatMember(
|
||||
chat: Chat,
|
||||
userId: UserId
|
||||
) = getChatMember(chat.id, userId)
|
||||
|
||||
suspend fun RequestsExecutor.getChatMember(
|
||||
chatId: ChatId,
|
||||
user: User
|
||||
) = getChatMember(chatId, user.id)
|
||||
|
||||
suspend fun RequestsExecutor.getChatMember(
|
||||
chat: Chat,
|
||||
user: User
|
||||
) = getChatMember(chat.id, user.id)
|
||||
|
@ -1,8 +1,10 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.UntilDate
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.abstracts.ChatMemberRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.BooleanSerializer
|
||||
|
||||
@ -21,3 +23,27 @@ data class KickChatMember(
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
suspend fun RequestsExecutor.kickChatMember(
|
||||
chatId: ChatIdentifier,
|
||||
userId: UserId,
|
||||
untilDate: TelegramDate? = null
|
||||
) = execute(KickChatMember(chatId, userId, untilDate))
|
||||
|
||||
suspend fun RequestsExecutor.kickChatMember(
|
||||
chat: Chat,
|
||||
userId: UserId,
|
||||
untilDate: TelegramDate? = null
|
||||
) = kickChatMember(chat.id, userId, untilDate)
|
||||
|
||||
suspend fun RequestsExecutor.kickChatMember(
|
||||
chatId: ChatId,
|
||||
user: User,
|
||||
untilDate: TelegramDate? = null
|
||||
) = kickChatMember(chatId, user.id, untilDate)
|
||||
|
||||
suspend fun RequestsExecutor.kickChatMember(
|
||||
chat: Chat,
|
||||
user: User,
|
||||
untilDate: TelegramDate? = null
|
||||
) = kickChatMember(chat.id, user.id, untilDate)
|
||||
|
@ -1,8 +1,10 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.UntilDate
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.abstracts.ChatMemberRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.BooleanSerializer
|
||||
|
||||
@ -37,3 +39,109 @@ data class PromoteChatMember(
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
suspend fun RequestsExecutor.promoteChatMember(
|
||||
chatId: ChatIdentifier,
|
||||
userId: UserId,
|
||||
untilDate: TelegramDate? = null,
|
||||
canChangeInfo: Boolean? = null,
|
||||
canPostMessages: Boolean? = null,
|
||||
canEditMessages: Boolean? = null,
|
||||
canDeleteMessages: Boolean? = null,
|
||||
canInviteUsers: Boolean? = null,
|
||||
canRestrictMembers: Boolean? = null,
|
||||
canPinMessages: Boolean? = null,
|
||||
canPromoteMembers: Boolean? = null
|
||||
) = execute(
|
||||
PromoteChatMember(
|
||||
chatId,
|
||||
userId,
|
||||
untilDate,
|
||||
canChangeInfo,
|
||||
canPostMessages,
|
||||
canEditMessages,
|
||||
canDeleteMessages,
|
||||
canInviteUsers,
|
||||
canRestrictMembers,
|
||||
canPinMessages,
|
||||
canPromoteMembers
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.promoteChatMember(
|
||||
chat: Chat,
|
||||
userId: UserId,
|
||||
untilDate: TelegramDate? = null,
|
||||
canChangeInfo: Boolean? = null,
|
||||
canPostMessages: Boolean? = null,
|
||||
canEditMessages: Boolean? = null,
|
||||
canDeleteMessages: Boolean? = null,
|
||||
canInviteUsers: Boolean? = null,
|
||||
canRestrictMembers: Boolean? = null,
|
||||
canPinMessages: Boolean? = null,
|
||||
canPromoteMembers: Boolean? = null
|
||||
) = promoteChatMember(
|
||||
chat.id,
|
||||
userId,
|
||||
untilDate,
|
||||
canChangeInfo,
|
||||
canPostMessages,
|
||||
canEditMessages,
|
||||
canDeleteMessages,
|
||||
canInviteUsers,
|
||||
canRestrictMembers,
|
||||
canPinMessages,
|
||||
canPromoteMembers
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.promoteChatMember(
|
||||
chatId: ChatId,
|
||||
user: User,
|
||||
untilDate: TelegramDate? = null,
|
||||
canChangeInfo: Boolean? = null,
|
||||
canPostMessages: Boolean? = null,
|
||||
canEditMessages: Boolean? = null,
|
||||
canDeleteMessages: Boolean? = null,
|
||||
canInviteUsers: Boolean? = null,
|
||||
canRestrictMembers: Boolean? = null,
|
||||
canPinMessages: Boolean? = null,
|
||||
canPromoteMembers: Boolean? = null
|
||||
) = promoteChatMember(
|
||||
chatId,
|
||||
user.id,
|
||||
untilDate,
|
||||
canChangeInfo,
|
||||
canPostMessages,
|
||||
canEditMessages,
|
||||
canDeleteMessages,
|
||||
canInviteUsers,
|
||||
canRestrictMembers,
|
||||
canPinMessages,
|
||||
canPromoteMembers
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.promoteChatMember(
|
||||
chat: Chat,
|
||||
user: User,
|
||||
untilDate: TelegramDate? = null,
|
||||
canChangeInfo: Boolean? = null,
|
||||
canPostMessages: Boolean? = null,
|
||||
canEditMessages: Boolean? = null,
|
||||
canDeleteMessages: Boolean? = null,
|
||||
canInviteUsers: Boolean? = null,
|
||||
canRestrictMembers: Boolean? = null,
|
||||
canPinMessages: Boolean? = null,
|
||||
canPromoteMembers: Boolean? = null
|
||||
) = promoteChatMember(
|
||||
chat.id,
|
||||
user.id,
|
||||
untilDate,
|
||||
canChangeInfo,
|
||||
canPostMessages,
|
||||
canEditMessages,
|
||||
canDeleteMessages,
|
||||
canInviteUsers,
|
||||
canRestrictMembers,
|
||||
canPinMessages,
|
||||
canPromoteMembers
|
||||
)
|
||||
|
@ -1,9 +1,11 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.UntilDate
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.abstracts.ChatMemberRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ChatPermissions
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.BooleanSerializer
|
||||
|
||||
@ -16,7 +18,7 @@ data class RestrictChatMember(
|
||||
@SerialName(untilDateField)
|
||||
override val untilDate: TelegramDate? = null,
|
||||
@SerialName(permissionsField)
|
||||
val permissions: ChatPermissions
|
||||
val permissions: ChatPermissions = ChatPermissions()
|
||||
) : ChatMemberRequest<Boolean>, UntilDate {
|
||||
override fun method(): String = "restrictChatMember"
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
@ -24,3 +26,32 @@ data class RestrictChatMember(
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
suspend fun RequestsExecutor.restrictChatMember(
|
||||
chatId: ChatIdentifier,
|
||||
userId: UserId,
|
||||
untilDate: TelegramDate? = null,
|
||||
permissions: ChatPermissions = ChatPermissions()
|
||||
) = execute(RestrictChatMember(chatId, userId, untilDate, permissions))
|
||||
|
||||
suspend fun RequestsExecutor.restrictChatMember(
|
||||
chat: Chat,
|
||||
userId: UserId,
|
||||
untilDate: TelegramDate? = null,
|
||||
permissions: ChatPermissions = ChatPermissions()
|
||||
) = restrictChatMember(chat.id, userId, untilDate, permissions)
|
||||
|
||||
suspend fun RequestsExecutor.restrictChatMember(
|
||||
chatId: ChatId,
|
||||
user: User,
|
||||
untilDate: TelegramDate? = null,
|
||||
permissions: ChatPermissions = ChatPermissions()
|
||||
) = restrictChatMember(chatId, user.id, untilDate, permissions)
|
||||
|
||||
suspend fun RequestsExecutor.restrictChatMember(
|
||||
chat: Chat,
|
||||
user: User,
|
||||
untilDate: TelegramDate? = null,
|
||||
permissions: ChatPermissions = ChatPermissions()
|
||||
) = restrictChatMember(chat.id, user.id, untilDate, permissions)
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.abstracts.ChatMemberRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.BooleanSerializer
|
||||
|
||||
@ -13,7 +15,7 @@ import kotlinx.serialization.internal.BooleanSerializer
|
||||
@Serializable
|
||||
data class SetChatAdministratorCustomTitle(
|
||||
@SerialName(chatIdField)
|
||||
override val chatId: ChatId,
|
||||
override val chatId: ChatIdentifier,
|
||||
@SerialName(userIdField)
|
||||
override val userId: UserId,
|
||||
@SerialName(customTitleField)
|
||||
@ -30,4 +32,28 @@ data class SetChatAdministratorCustomTitle(
|
||||
throw IllegalArgumentException("Custom title length must be in range $customTitleLength, but was ${customTitle.length}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun RequestsExecutor.setChatAdministratorCustomTitle(
|
||||
chatId: ChatId,
|
||||
userId: UserId,
|
||||
customTitle: String
|
||||
) = execute(SetChatAdministratorCustomTitle(chatId, userId, customTitle))
|
||||
|
||||
suspend fun RequestsExecutor.setChatAdministratorCustomTitle(
|
||||
chat: Chat,
|
||||
userId: UserId,
|
||||
customTitle: String
|
||||
) = setChatAdministratorCustomTitle(chat.id, userId, customTitle)
|
||||
|
||||
suspend fun RequestsExecutor.setChatAdministratorCustomTitle(
|
||||
chatId: ChatId,
|
||||
user: User,
|
||||
customTitle: String
|
||||
) = setChatAdministratorCustomTitle(chatId, user.id, customTitle)
|
||||
|
||||
suspend fun RequestsExecutor.setChatAdministratorCustomTitle(
|
||||
chat: Chat,
|
||||
user: User,
|
||||
customTitle: String
|
||||
) = setChatAdministratorCustomTitle(chat.id, user.id, customTitle)
|
@ -1,7 +1,9 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.abstracts.ChatMemberRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.BooleanSerializer
|
||||
|
||||
@ -18,3 +20,24 @@ data class UnbanChatMember(
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
suspend fun RequestsExecutor.unbanChatMember(
|
||||
chatId: ChatIdentifier,
|
||||
userId: UserId
|
||||
) = execute(UnbanChatMember(chatId, userId))
|
||||
|
||||
suspend fun RequestsExecutor.unbanChatMember(
|
||||
chat: Chat,
|
||||
userId: UserId
|
||||
) = unbanChatMember(chat.id, userId)
|
||||
|
||||
suspend fun RequestsExecutor.unbanChatMember(
|
||||
chatId: ChatId,
|
||||
user: User
|
||||
) = unbanChatMember(chatId, user.id)
|
||||
|
||||
suspend fun RequestsExecutor.unbanChatMember(
|
||||
chat: Chat,
|
||||
user: User
|
||||
) = unbanChatMember(chat.id, user.id)
|
||||
|
||||
|
@ -1,8 +1,11 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.get.GetChat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.BooleanSerializer
|
||||
@ -18,3 +21,11 @@ data class DeleteChatPhoto(
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
suspend fun RequestsExecutor.deleteChatPhoto(
|
||||
chatId: ChatIdentifier
|
||||
) = execute(DeleteChatPhoto(chatId))
|
||||
|
||||
suspend fun RequestsExecutor.deleteChatPhoto(
|
||||
chat: Chat
|
||||
) = deleteChatPhoto(chat.id)
|
||||
|
@ -1,8 +1,11 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.BooleanSerializer
|
||||
|
||||
@ -21,3 +24,27 @@ data class PinChatMessage (
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
suspend fun RequestsExecutor.pinChatMessage(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
disableNotification: Boolean = false
|
||||
) = execute(PinChatMessage(chatId, messageId, disableNotification))
|
||||
|
||||
suspend fun RequestsExecutor.pinChatMessage(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
disableNotification: Boolean = false
|
||||
) = pinChatMessage(chat.id, messageId, disableNotification)
|
||||
|
||||
suspend fun RequestsExecutor.pinChatMessage(
|
||||
chatId: ChatIdentifier,
|
||||
message: Message,
|
||||
disableNotification: Boolean = false
|
||||
) = execute(PinChatMessage(chatId, message.messageId, disableNotification))
|
||||
|
||||
suspend fun RequestsExecutor.pinChatMessage(
|
||||
chat: Chat,
|
||||
message: Message,
|
||||
disableNotification: Boolean = false
|
||||
) = pinChatMessage(chat.id, message.messageId, disableNotification)
|
||||
|
@ -1,8 +1,10 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.BooleanSerializer
|
||||
|
||||
@ -25,3 +27,13 @@ data class SetChatDescription (
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
suspend fun RequestsExecutor.setChatDescription(
|
||||
chatId: ChatIdentifier,
|
||||
description: String
|
||||
) = execute(SetChatDescription(chatId, description))
|
||||
|
||||
suspend fun RequestsExecutor.setChatDescription(
|
||||
chat: Chat,
|
||||
description: String
|
||||
) = setChatDescription(chat.id, description)
|
||||
|
@ -1,9 +1,11 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ChatPermissions
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.BooleanSerializer
|
||||
|
||||
@ -20,3 +22,13 @@ data class SetChatPermissions (
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
suspend fun RequestsExecutor.setChatPermissions(
|
||||
chatId: ChatIdentifier,
|
||||
permissions: ChatPermissions
|
||||
) = execute(SetChatPermissions(chatId, permissions))
|
||||
|
||||
suspend fun RequestsExecutor.setChatPermissions(
|
||||
chat: Chat,
|
||||
permissions: ChatPermissions
|
||||
) = setChatPermissions(chat.id, permissions)
|
||||
|
@ -1,9 +1,12 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ChatPermissions
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toJson
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.BooleanSerializer
|
||||
@ -21,3 +24,13 @@ data class SetChatPhoto (
|
||||
override val mediaMap: Map<String, MultipartFile> = mapOf(photoField to photo)
|
||||
override val paramsJson: JsonObject = toJson(serializer())
|
||||
}
|
||||
|
||||
suspend fun RequestsExecutor.setChatPermissions(
|
||||
chatId: ChatIdentifier,
|
||||
photo: MultipartFile
|
||||
) = execute(SetChatPhoto(chatId, photo))
|
||||
|
||||
suspend fun RequestsExecutor.setChatPermissions(
|
||||
chat: Chat,
|
||||
photo: MultipartFile
|
||||
) = setChatPermissions(chat.id, photo)
|
||||
|
@ -1,8 +1,11 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.BooleanSerializer
|
||||
|
||||
@ -25,3 +28,13 @@ data class SetChatTitle (
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
suspend fun RequestsExecutor.setChatTitle(
|
||||
chatId: ChatIdentifier,
|
||||
title: String
|
||||
) = execute(SetChatTitle(chatId, title))
|
||||
|
||||
suspend fun RequestsExecutor.setChatTitle(
|
||||
chat: Chat,
|
||||
title: String
|
||||
) = setChatTitle(chat.id, title)
|
||||
|
@ -1,8 +1,10 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.BooleanSerializer
|
||||
@ -18,3 +20,11 @@ data class UnpinChatMessage(
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
suspend fun RequestsExecutor.unpinChatMessage(
|
||||
chatId: ChatIdentifier
|
||||
) = execute(UnpinChatMessage(chatId))
|
||||
|
||||
suspend fun RequestsExecutor.unpinChatMessage(
|
||||
chat: Chat
|
||||
) = unpinChatMessage(chat.id)
|
||||
|
@ -1,8 +1,11 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.stickers
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify.DeleteChatPhoto
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.BooleanSerializer
|
||||
@ -18,3 +21,11 @@ data class DeleteChatStickerSet(
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
suspend fun RequestsExecutor.deleteChatStickerSet(
|
||||
chatId: ChatIdentifier
|
||||
) = execute(DeleteChatStickerSet(chatId))
|
||||
|
||||
suspend fun RequestsExecutor.deleteChatStickerSet(
|
||||
chat: Chat
|
||||
) = deleteChatStickerSet(chat.id)
|
||||
|
@ -1,8 +1,10 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.stickers
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.BooleanSerializer
|
||||
|
||||
@ -19,3 +21,13 @@ data class SetChatStickerSet(
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
suspend fun RequestsExecutor.setChatStickerSet(
|
||||
chatId: ChatIdentifier,
|
||||
stickerSetName: StickerSetName
|
||||
) = execute(SetChatStickerSet(chatId, stickerSetName))
|
||||
|
||||
suspend fun RequestsExecutor.setChatStickerSet(
|
||||
chat: Chat,
|
||||
stickerSetName: StickerSetName
|
||||
) = setChatStickerSet(chat.id, stickerSetName)
|
||||
|
Loading…
Reference in New Issue
Block a user