forked from rubenlagus/TelegramBots
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4db7532
commit 1e040be
Showing
55 changed files
with
1,062 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
...-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/CloseForumTopic.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package org.telegram.telegrambots.meta.api.methods.forum; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.NonNull; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
import lombok.experimental.Tolerate; | ||
import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethodBoolean; | ||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; | ||
|
||
/** | ||
* @author Ruben Bermudez | ||
* @version 6.3 | ||
* Use this method to close an open topic in a forum supergroup chat. | ||
* The bot must be an administrator in the chat for this to work and must have | ||
* the can_manage_topics administrator rights, unless it is the creator of the topic. | ||
* | ||
* Returns True on success. | ||
*/ | ||
@EqualsAndHashCode(callSuper = false) | ||
@Getter | ||
@Setter | ||
@ToString | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
public class CloseForumTopic extends BotApiMethodBoolean { | ||
public static final String PATH = "closeForumTopic"; | ||
|
||
private static final String CHATID_FIELD = "chat_id"; | ||
private static final String MESSAGETHREADID_FIELD = "message_thread_id"; | ||
|
||
/** | ||
* Unique identifier for the target chat or username | ||
* of the target supergroup (in the format @supergroupusername) | ||
*/ | ||
@JsonProperty(CHATID_FIELD) | ||
@NonNull | ||
private String chatId; | ||
/** | ||
* Unique identifier for the target message thread of the forum topic | ||
*/ | ||
@JsonProperty(MESSAGETHREADID_FIELD) | ||
@NonNull | ||
private Integer messageThreadId; | ||
|
||
@Tolerate | ||
public void setChatId(@NonNull Long chatId) { | ||
this.chatId = chatId.toString(); | ||
} | ||
|
||
@Override | ||
public void validate() throws TelegramApiValidationException { | ||
if (chatId.isEmpty()) { | ||
throw new TelegramApiValidationException("ChatId can't be empty", this); | ||
} | ||
if (messageThreadId <= 0) { | ||
throw new TelegramApiValidationException("Message Thread Id can't be empty", this); | ||
} | ||
} | ||
|
||
@Override | ||
public String getMethod() { | ||
return PATH; | ||
} | ||
|
||
public static class CloseForumTopicBuilder { | ||
|
||
@Tolerate | ||
public CloseForumTopicBuilder chatId(@NonNull Long chatId) { | ||
this.chatId = chatId.toString(); | ||
return this; | ||
} | ||
} | ||
} |
Oops, something went wrong.