Merge branch 'aNNiMON-timeperiod-improvements' into dev
This commit is contained in:
commit
e746a99188
@ -1,5 +1,6 @@
|
|||||||
package org.telegram.telegrambots.meta.api.methods.groupadministration;
|
package org.telegram.telegrambots.meta.api.methods.groupadministration;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
|
|
||||||
@ -9,6 +10,9 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
|||||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
@ -81,11 +85,25 @@ public class KickChatMember extends BotApiMethod<Boolean> {
|
|||||||
return untilDate;
|
return untilDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public KickChatMember setUntilDate(Integer untilDate) {
|
public KickChatMember setUntilDate(Integer untilDateInSeconds) {
|
||||||
this.untilDate = untilDate;
|
this.untilDate = untilDateInSeconds;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public KickChatMember setUntilDate(Instant instant) {
|
||||||
|
return setUntilDate((int) instant.getEpochSecond());
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public KickChatMember setUntilDate(ZonedDateTime date) {
|
||||||
|
return setUntilDate(date.toInstant());
|
||||||
|
}
|
||||||
|
|
||||||
|
public KickChatMember forTimePeriod(Duration duration) {
|
||||||
|
return setUntilDate(Instant.now().plusMillis(duration.toMillis()));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMethod() {
|
public String getMethod() {
|
||||||
return PATH;
|
return PATH;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.telegram.telegrambots.meta.api.methods.groupadministration;
|
package org.telegram.telegrambots.meta.api.methods.groupadministration;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||||
@ -8,6 +9,9 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
|||||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
@ -89,11 +93,25 @@ public class RestrictChatMember extends BotApiMethod<Boolean> {
|
|||||||
return untilDate;
|
return untilDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RestrictChatMember setUntilDate(Integer untilDate) {
|
public RestrictChatMember setUntilDate(Integer untilDateInSeconds) {
|
||||||
this.untilDate = untilDate;
|
this.untilDate = untilDateInSeconds;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public RestrictChatMember setUntilDate(Instant instant) {
|
||||||
|
return setUntilDate((int) instant.getEpochSecond());
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public RestrictChatMember setUntilDate(ZonedDateTime date) {
|
||||||
|
return setUntilDate(date.toInstant());
|
||||||
|
}
|
||||||
|
|
||||||
|
public RestrictChatMember forTimePeriod(Duration duration) {
|
||||||
|
return setUntilDate(Instant.now().plusMillis(duration.toMillis()));
|
||||||
|
}
|
||||||
|
|
||||||
public Boolean getCanSendMessages() {
|
public Boolean getCanSendMessages() {
|
||||||
return canSendMessages;
|
return canSendMessages;
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
|
|
||||||
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
|
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @author Ruben Bermudez
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
@ -77,6 +79,13 @@ public class ChatMember implements BotApiObject {
|
|||||||
return untilDate;
|
return untilDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Instant getUntilDateAsInstant() {
|
||||||
|
if (untilDate == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return Instant.ofEpochSecond(untilDate);
|
||||||
|
}
|
||||||
|
|
||||||
public Boolean getCanBeEdited() {
|
public Boolean getCanBeEdited() {
|
||||||
return canBeEdited;
|
return canBeEdited;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user