Class ChatTemplate
java.lang.Object
dev.voroby.springframework.telegram.client.templates.ChatTemplate
This class simplifies the use of
TelegramClient
for chat related objects.- Author:
- Pavel Vorobyev
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondeleteChat
(long chatId) Deletes a chat along with all messages in the corresponding chat for all chat members.getBasicGroup
(long basicGroupId) Returns information about a basic group by its identifier.getBasicGroupFullInfo
(long basicGroupId) Returns full information about a basic group by its identifier.getChat
(long chatId) Returns information about a chat by its identifier; this is an offline request if the current user is not a bot.getSupergroup
(long supergroupId) Returns information about a supergroup or a channel by its identifier.getSupergroupFullInfo
(long supergroupId) Returns full information about a supergroup or a channel by its identifier, cached for up to 1 minute.joinChat
(long chatId) Adds the current user as a new member to a chat.leaveChat
(long chatId) Removes the current user from chat members.searchChats
(String query, int limit) Searches for the specified query in the title and username of already known chats; this is an offline request.searchPublicChat
(String username) Searches a public chat by its username.searchPublicChats
(String query) Searches public chats by looking for specified query in their username and title.
-
Constructor Details
-
ChatTemplate
-
-
Method Details
-
getChat
Returns information about a chat by its identifier; this is an offline request if the current user is not a bot.- Parameters:
chatId
- Chat identifier.- Returns:
CompletableFuture<Response<TdApi.Chat>>
.
-
joinChat
Adds the current user as a new member to a chat. Private and secret chats can't be joined using this method. May return an error with a message "INVITE_REQUEST_SENT" if only a join request was created.- Parameters:
chatId
- Chat identifier.- Returns:
CompletableFuture<Response<TdApi.Ok>>
Response to action.
-
searchChats
Searches for the specified query in the title and username of already known chats; this is an offline request. Returns chats in the order seen in the main chat list.- Parameters:
query
- Query to search for.limit
- The maximum number of chats to be returned.- Returns:
CompletableFuture<Response<TdApi.Chats>>
.
-
searchPublicChat
Searches a public chat by its username. Currently, only private chats, supergroups and channels can be public. Returns the chat if found; otherwise, an error is returned.- Parameters:
username
- Username to be resolved.- Returns:
CompletableFuture<Response<TdApi.Chat>>
.
-
searchPublicChats
Searches public chats by looking for specified query in their username and title. Currently, only private chats, supergroups and channels can be public. Returns a meaningful number of results. Excludes private chats with contacts and chats from the chat list from the results.- Parameters:
query
- Query to search for.- Returns:
CompletableFuture<Response<TdApi.Chats>>
.
-
leaveChat
Removes the current user from chat members. Private and secret chats can't be left using this method.- Parameters:
chatId
- Chat identifier.- Returns:
CompletableFuture<Response<TdApi.Ok>>
.
-
deleteChat
Deletes a chat along with all messages in the corresponding chat for all chat members. For group chats this will release the usernames and remove all members. Use the field chat.canBeDeletedForAllUsers to find whether the method can be applied to the chat.- Parameters:
chatId
- Chat identifier.- Returns:
CompletableFuture<Response<TdApi.Ok>>
.
-
getBasicGroup
Returns information about a basic group by its identifier. This is an offline request if the current user is not a bot.- Parameters:
basicGroupId
- Basic group identifier.- Returns:
CompletableFuture<Response<TdApi.BasicGroup>>
.
-
getBasicGroupFullInfo
public CompletableFuture<Response<TdApi.BasicGroupFullInfo>> getBasicGroupFullInfo(long basicGroupId) Returns full information about a basic group by its identifier.- Parameters:
basicGroupId
- Basic group identifier.- Returns:
CompletableFuture<Response<TdApi.BasicGroupFullInfo>>
.
-
getSupergroup
Returns information about a supergroup or a channel by its identifier. This is an offline request if the current user is not a bot.- Parameters:
supergroupId
- Supergroup or channel identifier.- Returns:
CompletableFuture<Response<TdApi.Supergroup>>
.
-
getSupergroupFullInfo
public CompletableFuture<Response<TdApi.SupergroupFullInfo>> getSupergroupFullInfo(long supergroupId) Returns full information about a supergroup or a channel by its identifier, cached for up to 1 minute.- Parameters:
supergroupId
- Supergroup or channel identifier.- Returns:
CompletableFuture<Response<TdApi.SupergroupFullInfo>>
.
-