-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
1ec2a51
commit bea63d4
Showing
23 changed files
with
626 additions
and
12 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
...rc/main/java/org/telegram/telegrambots/meta/api/methods/forum/CloseGeneralForumTopic.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,69 @@ | ||
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.4 | ||
* Use this method to close an open 'General' 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. | ||
* | ||
* Returns True on success. | ||
*/ | ||
@EqualsAndHashCode(callSuper = false) | ||
@Getter | ||
@Setter | ||
@ToString | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
public class CloseGeneralForumTopic extends BotApiMethodBoolean { | ||
public static final String PATH = "closeGeneralForumTopic"; | ||
|
||
private static final String CHATID_FIELD = "chat_id"; | ||
|
||
/** | ||
* Unique identifier for the target chat or username | ||
* of the target supergroup (in the format @supergroupusername) | ||
*/ | ||
@JsonProperty(CHATID_FIELD) | ||
@NonNull | ||
private String chatId; | ||
|
||
@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); | ||
} | ||
} | ||
|
||
@Override | ||
public String getMethod() { | ||
return PATH; | ||
} | ||
|
||
public static class CloseGeneralForumTopicBuilder { | ||
|
||
@Tolerate | ||
public CloseGeneralForumTopicBuilder chatId(@NonNull Long chatId) { | ||
this.chatId = chatId.toString(); | ||
return this; | ||
} | ||
} | ||
} |
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
...src/main/java/org/telegram/telegrambots/meta/api/methods/forum/EditGeneralForumTopic.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.4 | ||
* Use this method to edit the name of the 'General' topic in a forum supergroup chat. | ||
* The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights. | ||
* | ||
* Returns True on success. | ||
*/ | ||
@EqualsAndHashCode(callSuper = false) | ||
@Getter | ||
@Setter | ||
@ToString | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
public class EditGeneralForumTopic extends BotApiMethodBoolean { | ||
public static final String PATH = "editGeneralForumTopic"; | ||
|
||
private static final String CHATID_FIELD = "chat_id"; | ||
private static final String NAME_FIELD = "name"; | ||
|
||
/** | ||
* Unique identifier for the target chat or username | ||
* of the target supergroup (in the format @supergroupusername) | ||
*/ | ||
@JsonProperty(CHATID_FIELD) | ||
@NonNull | ||
private String chatId; | ||
/** | ||
* Optional. | ||
* New topic name, 1-128 characters | ||
*/ | ||
@JsonProperty(NAME_FIELD) | ||
@NonNull | ||
private String name; | ||
|
||
@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 (name.isEmpty() || name.length() > 128) { | ||
throw new TelegramApiValidationException("Name must be between 1 and 128 characters", this); | ||
} | ||
} | ||
|
||
@Override | ||
public String getMethod() { | ||
return PATH; | ||
} | ||
|
||
public static class EditGeneralForumTopicBuilder { | ||
|
||
@Tolerate | ||
public EditGeneralForumTopicBuilder chatId(@NonNull Long chatId) { | ||
this.chatId = chatId.toString(); | ||
return this; | ||
} | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
...src/main/java/org/telegram/telegrambots/meta/api/methods/forum/HideGeneralForumTopic.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,70 @@ | ||
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.4 | ||
* Use this method to hide the 'General' 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. | ||
* The topic will be automatically closed if it was open. | ||
* | ||
* Returns True on success. | ||
*/ | ||
@EqualsAndHashCode(callSuper = false) | ||
@Getter | ||
@Setter | ||
@ToString | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
public class HideGeneralForumTopic extends BotApiMethodBoolean { | ||
public static final String PATH = "hideGeneralForumTopic"; | ||
|
||
private static final String CHATID_FIELD = "chat_id"; | ||
|
||
/** | ||
* Unique identifier for the target chat or username | ||
* of the target supergroup (in the format @supergroupusername) | ||
*/ | ||
@JsonProperty(CHATID_FIELD) | ||
@NonNull | ||
private String chatId; | ||
|
||
@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); | ||
} | ||
} | ||
|
||
@Override | ||
public String getMethod() { | ||
return PATH; | ||
} | ||
|
||
public static class HideGeneralForumTopicBuilder { | ||
|
||
@Tolerate | ||
public HideGeneralForumTopicBuilder chatId(@NonNull Long chatId) { | ||
this.chatId = chatId.toString(); | ||
return this; | ||
} | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
...c/main/java/org/telegram/telegrambots/meta/api/methods/forum/ReopenGeneralForumTopic.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,70 @@ | ||
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.4 | ||
* Use this method to reopen a closed 'General' 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. | ||
* The topic will be automatically unhidden if it was hidden. | ||
* | ||
* Returns True on success. | ||
*/ | ||
@EqualsAndHashCode(callSuper = false) | ||
@Getter | ||
@Setter | ||
@ToString | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
public class ReopenGeneralForumTopic extends BotApiMethodBoolean { | ||
public static final String PATH = "reopenGeneralForumTopic"; | ||
|
||
private static final String CHATID_FIELD = "chat_id"; | ||
|
||
/** | ||
* Unique identifier for the target chat or username | ||
* of the target supergroup (in the format @supergroupusername) | ||
*/ | ||
@JsonProperty(CHATID_FIELD) | ||
@NonNull | ||
private String chatId; | ||
|
||
@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); | ||
} | ||
} | ||
|
||
@Override | ||
public String getMethod() { | ||
return PATH; | ||
} | ||
|
||
public static class ReopenGeneralForumTopicBuilder { | ||
|
||
@Tolerate | ||
public ReopenGeneralForumTopicBuilder chatId(@NonNull Long chatId) { | ||
this.chatId = chatId.toString(); | ||
return this; | ||
} | ||
} | ||
} |
Oops, something went wrong.