ChatKtx - libtd-ktx

Kotlin Coroutines extensions for Telegram API TDLib (Telegram Database library)


libtd-ktx / kotlinx.telegram.extensions / ChatKtx

ChatKtx

interface ChatKtx : BaseKtx

Interface for access TdApi.Chat extension functions. Can be used alongside with other extension interfaces of the package. Must contain TelegramFlow instance field to access its functionality

Properties

api Instance of the TelegramFlow connecting extensions to the Telegram Clientabstract val api: TelegramFlow

Functions

addLocalMessage Suspend function, which adds a local message to a chat. The message is persistent across application restarts only if the message database is used. Returns the added message.open suspend fun Chat.addLocalMessage(senderUserId: Int, replyToMessageId: Long, disableNotification: Boolean, inputMessageContent: InputMessageContent?): Message
addMember Suspend function, which adds a new member to a chat. Members can’t be added to private or secret chats. Members will not be added until the chat state has been synchronized with the server.open suspend fun Chat.addMember(userId: Int, forwardLimit: Int): Unit
addMembers Suspend function, which adds multiple new members to a chat. Currently this option is only available for supergroups and channels. This option can’t be used to join a chat. Members can’t be added to a channel if it has more than 200 members. Members will not be added until the chat state has been synchronized with the server.open suspend fun Chat.addMembers(userIds: IntArray?): Unit
addRecentlyFound Suspend function, which adds a chat to the list of recently found chats. The chat is added to the beginning of the list. If the chat is already in the list, it will be removed from the list first.open suspend fun Chat.addRecentlyFound(): Unit
checkUsername Suspend function, which checks whether a username can be set for a chat.open suspend fun Chat.checkUsername(username: String?): CheckChatUsernameResult
close Suspend function, which informs TDLib that the chat is closed by the user. Many useful activities depend on the chat being opened or closed.open suspend fun Chat.close(): Unit
deleteHistory Suspend function, which deletes all messages in the chat. Use Chat.canBeDeletedOnlyForSelf and Chat.canBeDeletedForAllUsers fields to find whether and how the method can be applied to the chat.open suspend fun Chat.deleteHistory(removeFromChatList: Boolean, revoke: Boolean): Unit
deleteMessages Suspend function, which deletes messages.open suspend fun Chat.deleteMessages(messageIds: LongArray?, revoke: Boolean): Unit
deleteMessagesFromUser Suspend function, which deletes all messages sent by the specified user to a chat. Supported only for supergroups; requires canDeleteMessages administrator privileges.open suspend fun Chat.deleteMessagesFromUser(userId: Int): Unit
deleteReplyMarkup Suspend function, which deletes the default reply markup from a chat. Must be called after a one-time keyboard or a ForceReply reply markup has been used. UpdateChatReplyMarkup will be sent if the reply markup will be changed.open suspend fun Chat.deleteReplyMarkup(messageId: Long): Unit
editMessageCaption Suspend function, which edits the message content caption. Returns the edited message after the edit is completed on the server side.open suspend fun Chat.editMessageCaption(messageId: Long, replyMarkup: ReplyMarkup?, caption: FormattedText?): Message
editMessageLiveLocation Suspend function, which edits the message content of a live location. Messages can be edited for a limited period of time specified in the live location. Returns the edited message after the edit is completed on the server side.open suspend fun Chat.editMessageLiveLocation(messageId: Long, replyMarkup: ReplyMarkup?, location: Location? = null): Message
editMessageMedia Suspend function, which edits the content of a message with an animation, an audio, a document, a photo or a video. The media in the message can’t be replaced if the message was set to self-destruct. Media can’t be replaced by self-destructing media. Media in an album can be edited only to contain a photo or a video. Returns the edited message after the edit is completed on the server side.open suspend fun Chat.editMessageMedia(messageId: Long, replyMarkup: ReplyMarkup?, inputMessageContent: InputMessageContent?): Message
editMessageReplyMarkup Suspend function, which edits the message reply markup; for bots only. Returns the edited message after the edit is completed on the server side.open suspend fun Chat.editMessageReplyMarkup(messageId: Long, replyMarkup: ReplyMarkup?): Message
editMessageSchedulingState Suspend function, which edits the time when a scheduled message will be sent. Scheduling state of all messages in the same album or forwarded together with the message will be also changed.open suspend fun Chat.editMessageSchedulingState(messageId: Long, schedulingState: MessageSchedulingState?): Unit
editMessageText Suspend function, which edits the text of a message (or a text of a game message). Returns the edited message after the edit is completed on the server side.open suspend fun Chat.editMessageText(messageId: Long, replyMarkup: ReplyMarkup?, inputMessageContent: InputMessageContent?): Message
forwardMessages Suspend function, which forwards previously sent messages. Returns the forwarded messages in the same order as the message identifiers passed in messageIds. If a message can’t be forwarded, null will be returned instead of the message.open suspend fun Chat.forwardMessages(fromChatId: Long, messageIds: LongArray?, options: SendMessageOptions?, asAlbum: Boolean, sendCopy: Boolean, removeCaption: Boolean): Messages
generateInviteLink Suspend function, which generates a new invite link for a chat; the previously generated link is revoked. Available for basic groups, supergroups, and channels. Requires administrator privileges and canInviteUsers right.open suspend fun Chat.generateInviteLink(): ChatInviteLink
get Suspend function, which returns information about a chat by its identifier, this is an offline request if the current user is not a bot.open suspend fun Chat.get(): Chat
getAdministrators Suspend function, which returns a list of administrators of the chat with their custom titles.open suspend fun Chat.getAdministrators(): ChatAdministrators
getCallbackQueryAnswer Suspend function, which sends a callback query to a bot and returns an answer. Returns an error with code 502 if the bot fails to answer the query before the query timeout expires.open suspend fun Chat.getCallbackQueryAnswer(messageId: Long, payload: CallbackQueryPayload?): CallbackQueryAnswer
getEventLog Suspend function, which returns a list of service actions taken by chat members and administrators in the last 48 hours. Available only for supergroups and channels. Requires administrator rights. Returns results in reverse chronological order (i. e., in order of decreasing eventId).open suspend fun Chat.getEventLog(query: String?, fromEventId: Long, limit: Int, filters: ChatEventLogFilters?, userIds: IntArray?): ChatEvents
getGameHighScores Suspend function, which returns the high scores for a game and some part of the high score table in the range of the specified user; for bots only.open suspend fun Chat.getGameHighScores(messageId: Long, userId: Int): GameHighScores
getHistory Suspend function, which returns messages in a chat. The messages are returned in a reverse chronological order (i.e., in order of decreasing messageId). For optimal performance the number of returned messages is chosen by the library. This is an offline request if onlyLocal is true.open suspend fun Chat.getHistory(fromMessageId: Long, offset: Int, limit: Int, onlyLocal: Boolean): Messages
getInlineQueryResults Suspend function, which sends an inline query to a bot and returns its results. Returns an error with code 502 if the bot fails to answer the query before the query timeout expires.open suspend fun Chat.getInlineQueryResults(botUserId: Int, userLocation: Location?, query: String?, offset: String?): InlineQueryResults
getLoginUrl Suspend function, which returns an HTTP URL which can be used to automatically authorize the user on a website after clicking an inline button of type inlineKeyboardButtonTypeLoginUrl. Use the method getLoginUrlInfo to find whether a prior user confirmation is needed. If an error is returned, then the button must be handled as an ordinary URL button.open suspend fun Chat.getLoginUrl(messageId: Long, buttonId: Int, allowWriteAccess: Boolean): HttpUrl
getLoginUrlInfo Suspend function, which returns information about a button of type inlineKeyboardButtonTypeLoginUrl. The method needs to be called when the user presses the button.open suspend fun Chat.getLoginUrlInfo(messageId: Long, buttonId: Int): LoginUrlInfo
getMapThumbnailFile Suspend function, which returns information about a file with a map thumbnail in PNG format. Only map thumbnail files with size less than 1MB can be downloaded.open suspend fun Chat.getMapThumbnailFile(location: Location?, zoom: Int, width: Int, height: Int, scale: Int): File
getMember Suspend function, which returns information about a single member of a chat.open suspend fun Chat.getMember(userId: Int): ChatMember
getMessage Suspend function, which returns information about a message.open suspend fun Chat.getMessage(messageId: Long): Message
getMessageByDate Suspend function, which returns the last message sent in a chat no later than the specified date.open suspend fun Chat.getMessageByDate(date: Int): Message
getMessageCount Suspend function, which returns approximate number of messages of the specified type in the chat.open suspend fun Chat.getMessageCount(filter: SearchMessagesFilter?, returnLocal: Boolean): Count
getMessageLink Suspend function, which returns a private HTTPS link to a message in a chat. Available only for already sent messages in supergroups and channels. The link will work only for members of the chat.open suspend fun Chat.getMessageLink(messageId: Long): HttpUrl
getMessageLocally Suspend function, which returns information about a message, if it is available locally without sending network request. This is an offline request.open suspend fun Chat.getMessageLocally(messageId: Long): Message
getMessages Suspend function, which returns information about messages. If a message is not found, returns null on the corresponding position of the result.open suspend fun Chat.getMessages(messageIds: LongArray?): Messages
getPaymentForm Suspend function, which returns an invoice payment form. This method should be called when the user presses inlineKeyboardButtonBuy.open suspend fun Chat.getPaymentForm(messageId: Long): PaymentForm
getPaymentReceipt Suspend function, which returns information about a successful payment.open suspend fun Chat.getPaymentReceipt(messageId: Long): PaymentReceipt
getPinnedMessage Suspend function, which returns information about a pinned chat message.open suspend fun Chat.getPinnedMessage(): Message
getPollVoters Suspend function, which returns users voted for the specified option in a non-anonymous polls. For the optimal performance the number of returned users is chosen by the library.open suspend fun Chat.getPollVoters(messageId: Long, optionId: Int, offset: Int, limit: Int): Users
getPublicMessageLink Suspend function, which returns a public HTTPS link to a message. Available only for messages in supergroups and channels with a username.open suspend fun Chat.getPublicMessageLink(messageId: Long, forAlbum: Boolean): PublicMessageLink
getRepliedMessage Suspend function, which returns information about a message that is replied by given message.open suspend fun Chat.getRepliedMessage(messageId: Long): Message
getScheduledMessages Suspend function, which returns all scheduled messages in a chat. The messages are returned in a reverse chronological order (i.e., in order of decreasing messageId).open suspend fun Chat.getScheduledMessages(): Messages
getStatisticsUrl Suspend function, which returns an HTTP URL with the chat statistics. Currently this method can be used only for channels. Can be used only if SupergroupFullInfo.canViewStatistics == true.open suspend fun Chat.getStatisticsUrl(parameters: String?, isDark: Boolean): HttpUrl
join Suspend function, which adds current user as a new member to a chat. Private and secret chats can’t be joined using this method.open suspend fun Chat.join(): Unit
leave Suspend function, which removes current user from chat members. Private and secret chats can’t be left using this method.open suspend fun Chat.leave(): Unit
open Suspend function, which informs TDLib that the chat is opened by the user. Many useful activities depend on the chat being opened or closed (e.g., in supergroups and channels all updates are received only for opened chats).open suspend fun Chat.open(): Unit
openMessageContent Suspend function, which informs TDLib that the message content has been opened (e.g., the user has opened a photo, video, document, location or venue, or has listened to an audio file or voice note message). An updateMessageContentOpened update will be generated if something has changed.open suspend fun Chat.openMessageContent(messageId: Long): Unit
pinMessage Suspend function, which pins a message in a chat; requires canPinMessages rights.open suspend fun Chat.pinMessage(messageId: Long, disableNotification: Boolean): Unit
readAllMentions Suspend function, which marks all mentions in a chat as read.open suspend fun Chat.readAllMentions(): Unit
removeActionBar Suspend function, which removes a chat action bar without any other action.open suspend fun Chat.removeActionBar(): Unit
removeRecentlyFound Suspend function, which removes a chat from the list of recently found chats.open suspend fun Chat.removeRecentlyFound(): Unit
removeTop Suspend function, which removes a chat from the list of frequently used chats. Supported only if the chat info database is enabled.open suspend fun Chat.removeTop(category: TopChatCategory?): Unit
report Suspend function, which reports a chat to the Telegram moderators. Supported only for supergroups, channels, or private chats with bots, since other chats can’t be checked by moderators, or when the report is done from the chat action bar.open suspend fun Chat.report(reason: ChatReportReason?, messageIds: LongArray?): Unit
resendMessages Suspend function, which resends messages which failed to send. Can be called only for messages for which messageSendingStateFailed.canRetry is true and after specified in messageSendingStateFailed.retryAfter time passed. If a message is re-sent, the corresponding failed to send message is deleted. Returns the sent messages in the same order as the message identifiers passed in messageIds. If a message can’t be re-sent, null will be returned instead of the message.open suspend fun Chat.resendMessages(messageIds: LongArray?): Messages
saveApplicationLogEvent Suspend function, which saves application log event on the server. Can be called before authorization.open suspend fun Chat.saveApplicationLogEvent(type: String?, data: JsonValue?): Unit
searchMembers Suspend function, which searches for a specified query in the first name, last name and username of the members of a specified chat. Requires administrator rights in channels.open suspend fun Chat.searchMembers(query: String?, limit: Int, filter: ChatMembersFilter?): ChatMembers
searchMessages Suspend function, which searches for messages with given words in the chat. Returns the results in reverse chronological order, i.e. in order of decreasing messageId. Cannot be used in secret chats with a non-empty query (searchSecretMessages should be used instead), or without an enabled message database. For optimal performance the number of returned messages is chosen by the library.open suspend fun Chat.searchMessages(query: String?, senderUserId: Int, fromMessageId: Long, offset: Int, limit: Int, filter: SearchMessagesFilter?): Messages
searchRecentLocationMessages Suspend function, which returns information about the recent locations of chat members that were sent to the chat. Returns up to 1 location message per user.open suspend fun Chat.searchRecentLocationMessages(limit: Int): Messages
searchSecretMessages Suspend function, which searches for messages in secret chats. Returns the results in reverse chronological order. For optimal performance the number of returned messages is chosen by the library.open suspend fun Chat.searchSecretMessages(query: String?, fromSearchId: Long, limit: Int, filter: SearchMessagesFilter?): FoundMessages
sendAction Suspend function, which sends a notification about user activity in a chat.open suspend fun Chat.sendAction(action: ChatAction?): Unit
sendBotStartMessage Suspend function, which invites a bot to a chat (if it is not yet a member) and sends it the /start command. Bots can’t be invited to a private chat other than the chat with the bot. Bots can’t be invited to channels (although they can be added as admins) and secret chats. Returns the sent message.open suspend fun Chat.sendBotStartMessage(botUserId: Int, parameter: String?): Message
sendInlineQueryResultMessage Suspend function, which sends the result of an inline query as a message. Returns the sent message. Always clears a chat draft message.open suspend fun Chat.sendInlineQueryResultMessage(replyToMessageId: Long, options: SendMessageOptions?, queryId: Long, resultId: String?, hideViaBot: Boolean): Message
sendMessage Suspend function, which sends a message. Returns the sent message.open suspend fun Chat.sendMessage(replyToMessageId: Long, options: SendMessageOptions?, replyMarkup: ReplyMarkup?, inputMessageContent: InputMessageContent?): Message
sendMessageAlbum Suspend function, which sends messages grouped together into an album. Currently only photo and video messages can be grouped into an album. Returns sent messages.open suspend fun Chat.sendMessageAlbum(replyToMessageId: Long, options: SendMessageOptions?, inputMessageContents: Array<InputMessageContent>?): Messages
sendPaymentForm Suspend function, which sends a filled-out payment form to the bot for final verification.open suspend fun Chat.sendPaymentForm(messageId: Long, orderInfoId: String?, shippingOptionId: String?, credentials: InputCredentials?): PaymentResult
sendScreenshotTakenNotification Suspend function, which sends a notification about a screenshot taken in a chat. Supported only in private and secret chats.open suspend fun Chat.sendScreenshotTakenNotification(): Unit
sendSetTtlMessage Suspend function, which changes the current TTL setting (sets a new self-destruct timer) in a secret chat and sends the corresponding message.open suspend fun Chat.sendSetTtlMessage(ttl: Int): Message
setClientData Suspend function, which changes client data associated with a chat.open suspend fun Chat.setClientData(clientData: String?): Unit
setDescription Suspend function, which changes information about a chat. Available for basic groups, supergroups, and channels. Requires canChangeInfo rights.open suspend fun Chat.setDescription(description: String?): Unit
setDiscussionGroup Suspend function, which changes the discussion group of a channel chat; requires canChangeInfo rights in the channel if it is specified.open suspend fun Chat.setDiscussionGroup(discussionChatId: Long): Unit
setDraftMessage Suspend function, which changes the draft message in a chat.open suspend fun Chat.setDraftMessage(draftMessage: DraftMessage? = null): Unit
setGameScore Suspend function, which updates the game score of the specified user in the game; for bots only.open suspend fun Chat.setGameScore(messageId: Long, editMessage: Boolean, userId: Int, score: Int, force: Boolean): Message
setList Suspend function, which moves a chat to a different chat list. Current chat list of the chat must ne non-null.open suspend fun Chat.setList(chatList: ChatList?): Unit
setLocation Suspend function, which changes the location of a chat. Available only for some location-based supergroups, use supergroupFullInfo.canSetLocation to check whether the method is allowed to use.open suspend fun Chat.setLocation(location: ChatLocation?): Unit
setMemberStatus Suspend function, which changes the status of a chat member, needs appropriate privileges. This function is currently not suitable for adding new members to the chat and transferring chat ownership; instead, use addChatMember or transferChatOwnership. The chat member status will not be changed until it has been synchronized with the server.open suspend fun Chat.setMemberStatus(userId: Int, status: ChatMemberStatus?): Unit
setNotificationSettings Suspend function, which changes the notification settings of a chat. Notification settings of a chat with the current user (Saved Messages) can’t be changed.open suspend fun Chat.setNotificationSettings(notificationSettings: ChatNotificationSettings?): Unit
setPermissions Suspend function, which changes the chat members permissions. Supported only for basic groups and supergroups. Requires canRestrictMembers administrator right.open suspend fun Chat.setPermissions(permissions: ChatPermissions?): Unit
setPhoto Suspend function, which changes the photo of a chat. Supported only for basic groups, supergroups and channels. Requires canChangeInfo rights. The photo will not be changed before request to the server has been completed.open suspend fun Chat.setPhoto(photo: InputFile?): Unit
setPollAnswer Suspend function, which changes the user answer to a poll. A poll in quiz mode can be answered only once.open suspend fun Chat.setPollAnswer(messageId: Long, optionIds: IntArray?): Unit
setSlowModeDelay Suspend function, which changes the slow mode delay of a chat. Available only for supergroups; requires canRestrictMembers rights.open suspend fun Chat.setSlowModeDelay(slowModeDelay: Int): Unit
setTitle Suspend function, which changes the chat title. Supported only for basic groups, supergroups and channels. Requires canChangeInfo rights. The title will not be changed until the request to the server has been completed.open suspend fun Chat.setTitle(title: String?): Unit
stopPoll Suspend function, which stops a poll. A poll in a message can be stopped when the message has canBeEdited flag set.open suspend fun Chat.stopPoll(messageId: Long, replyMarkup: ReplyMarkup?): Unit
toggleDefaultDisableNotification Suspend function, which changes the value of the default disableNotification parameter, used when a message is sent to a chat.open suspend fun Chat.toggleDefaultDisableNotification(defaultDisableNotification: Boolean): Unit
toggleIsMarkedAsUnread Suspend function, which changes the marked as unread state of a chat.open suspend fun Chat.toggleIsMarkedAsUnread(isMarkedAsUnread: Boolean): Unit
toggleIsPinned Suspend function, which changes the pinned state of a chat. You can pin up to GetOption(&quot;pinned_chat_count_max&quot;)/GetOption(&quot;pinned_archived_chat_count_max&quot;) non-secret chats and the same number of secret chats in the main/archive chat list.open suspend fun Chat.toggleIsPinned(isPinned: Boolean): Unit
transferOwnership Suspend function, which changes the owner of a chat. The current user must be a current owner of the chat. Use the method canTransferOwnership to check whether the ownership can be transferred from the current session. Available only for supergroups and channel chats.open suspend fun Chat.transferOwnership(userId: Int, password: String?): Unit
unpinMessage Suspend function, which removes the pinned message from a chat; requires canPinMessages rights in the group or channel.open suspend fun Chat.unpinMessage(): Unit
upgradeBasicGroupToSupergroup Suspend function, which creates a new supergroup from an existing basic group and sends a corresponding messageChatUpgradeTo and messageChatUpgradeFrom; requires creator privileges. Deactivates the original basic group.open suspend fun Chat.upgradeBasicGroupToSupergroup(): Chat
validateOrderInfo Suspend function, which validates the order information provided by a user and returns the available shipping options for a flexible invoice.open suspend fun Chat.validateOrderInfo(messageId: Long, orderInfo: OrderInfo?, allowSave: Boolean): ValidatedOrderInfo
viewMessages Suspend function, which informs TDLib that messages are being viewed by the user. Many useful activities depend on whether the messages are currently being viewed or not (e.g., marking messages as read, incrementing a view counter, updating a view counter, removing deleted messages in supergroups and channels).open suspend fun Chat.viewMessages(messageIds: LongArray?, forceRead: Boolean): Unit

Inheritors

TelegramKtx Interface for access all Telegram objects extension functions. Contains 182 extensionsinterface TelegramKtx : BasicGroupKtx, CallKtx, ChatKtx, FileKtx, MessageKtx, NotificationGroupKtx, ProxyKtx, SecretChatKtx, SupergroupKtx, UserKtx, CommonKtx