Skip to content

Commit

Permalink
Api Version 6.4
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenlagus committed Dec 31, 2022
1 parent 1ec2a51 commit bea63d4
Show file tree
Hide file tree
Showing 23 changed files with 626 additions and 12 deletions.
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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,20 @@ public class EditForumTopic extends BotApiMethodBoolean {
@NonNull
private Integer messageThreadId;
/**
* Topic name, 1-128 characters
* Optional.
* New topic name, 0-128 characters.
* If not specified or empty, the current name of the topic will be kept
*/
@JsonProperty(NAME_FIELD)
@NonNull
private String name;
/**
* Optional.
* Unique identifier of the custom emoji shown as the topic icon.
* Use getForumTopicIconStickers to get all allowed custom emoji identifiers
* New unique identifier of the custom emoji shown as the topic icon.
* Use getForumTopicIconStickers to get all allowed custom emoji identifiers.
* Pass an empty string to remove the icon.
* If not specified, the current icon will be kept
*/
@JsonProperty(ICONCUSTOMEMOJIID_FIELD)
@NonNull
private String iconCustomEmojiId;

@Tolerate
Expand All @@ -75,8 +77,10 @@ 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);
if (name != null && !name.isEmpty()) {
if (name.length() > 128) {
throw new TelegramApiValidationException("Name must be less than 128 characters", this);
}
}
if (messageThreadId <= 0) {
throw new TelegramApiValidationException("Message Thread Id can't be empty", this);
Expand Down
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;
}
}
}
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;
}
}
}
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;
}
}
}
Loading

0 comments on commit bea63d4

Please sign in to comment.