Skip to content

Commit

Permalink
Release 7.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
aNNiMON committed Feb 17, 2024
1 parent 054917c commit c245c16
Show file tree
Hide file tree
Showing 15 changed files with 539 additions and 225 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Enhanced Java telegram bots runner built on top of the [Telegram Bots](https://g
- Add gradle dependency:

```groovy
implementation 'com.annimon:tgbots-module:6.9.0'
implementation 'com.annimon:tgbots-module:7.1.0'
```

- Implement `BotModule` interface:
Expand Down
4 changes: 2 additions & 2 deletions module/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group 'com.annimon'
version '6.9.0-SNAPSHOT'
version '7.1.0-SNAPSHOT'
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")

java {
Expand All @@ -24,7 +24,7 @@ ext.junit5Version = '5.10.2'
ext.jaxbVersion = '2.3.1'

dependencies {
api "org.telegram:telegrambots:6.9.7.0"
api "org.telegram:telegrambots:6.9.7.1"
api 'com.google.guava:guava:33.0.0-jre'
api "com.squareup.retrofit2:retrofit:$retrofitVersion"
api "com.squareup.retrofit2:converter-jackson:$retrofitVersion"
Expand Down
421 changes: 233 additions & 188 deletions module/src/main/java/com/annimon/tgbotsmodule/api/methods/Methods.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,33 @@ public PromoteChatMemberMethod setCanManageTopics(Boolean canManageTopics) {
return this;
}

public Boolean canPostStories() {
return method.getCanPostStories();
}

public PromoteChatMemberMethod setCanPostStories(Boolean canPostStories) {
method.setCanPostStories(canPostStories);
return this;
}

public Boolean canEditStories() {
return method.getCanEditStories();
}

public PromoteChatMemberMethod setCanEditStories(Boolean canEditStories) {
method.setCanEditStories(canEditStories);
return this;
}

public Boolean canDeleteStories() {
return method.getCanDeleteStories();
}

public PromoteChatMemberMethod setCanDeleteStories(Boolean canDeleteStories) {
method.setCanDeleteStories(canDeleteStories);
return this;
}

public Boolean isAnonymous() {
return method.getIsAnonymous();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@ public class GetMyNameMethod implements Method<BotName> {
private final GetMyName method;

public GetMyNameMethod() {
this(new GetMyName() {
@Override
public String getMethod() {
return "getMyName"; // TODO: remove when will be fixed in telegrambots
}
});
this(new GetMyName());
}

public GetMyNameMethod(@NotNull GetMyName method) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.annimon.tgbotsmodule.api.methods.interfaces.InlineKeyboardMarkupMethod;
import com.annimon.tgbotsmodule.api.methods.interfaces.ProtectedContentMethod;
import com.annimon.tgbotsmodule.api.methods.interfaces.SendableMessageMethod;
import com.annimon.tgbotsmodule.api.methods.send.SendGameMethod;
import com.annimon.tgbotsmodule.services.CommonAbsSender;
import java.util.List;
import java.util.function.Consumer;
Expand Down Expand Up @@ -317,12 +316,12 @@ public SendInvoiceMethod setSendPhoneNumberToProvider(Boolean sendPhoneNumberToP

@Override
public ReplyParameters getReplyParameters() {
return null; // method.getReplyParameters(); TODO fix after ruben
return method.getReplyParameters();
}

@Override
public SendInvoiceMethod setReplyParameters(@NotNull ReplyParameters replyParameters) {
// method.setReplyParameters(replyParameters);
method.setReplyParameters(replyParameters);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,13 @@
import org.telegram.telegrambots.meta.api.methods.reactions.SetMessageReaction;
import org.telegram.telegrambots.meta.api.objects.reactions.ReactionType;
import org.telegram.telegrambots.meta.exceptions.TelegramApiException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;

public class SetMessageReactionMethod implements ChatMessageMethod<SetMessageReactionMethod, Boolean> {

private final SetMessageReaction method;

public SetMessageReactionMethod() {
this(new SetMessageReaction() {
@Override
public void validate() throws TelegramApiValidationException {
if (getChatId().isEmpty()) {
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
}
// Ruben's lib 6.9.7.0 has invalid reaction type validation
// TODO Remove overridden method in the next update
}
});
this(new SetMessageReaction());
}

public SetMessageReactionMethod(@NotNull SetMessageReaction method) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.annimon.tgbotsmodule.api.methods.stickers;

import com.annimon.tgbotsmodule.api.methods.interfaces.Method;
import com.annimon.tgbotsmodule.services.CommonAbsSender;
import java.util.function.Consumer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.telegram.telegrambots.meta.api.methods.stickers.DeleteStickerSet;
import org.telegram.telegrambots.meta.exceptions.TelegramApiException;

public class DeleteStickerSetMethod implements Method<Boolean> {

private final DeleteStickerSet method;

public DeleteStickerSetMethod() {
this(new DeleteStickerSet());
}

public DeleteStickerSetMethod(@NotNull DeleteStickerSet method) {
this.method = method;
}

public String getName() {
return method.getName();
}

public DeleteStickerSetMethod setName(@NotNull String name) {
method.setName(name);
return this;
}

@Override
public Boolean call(@NotNull CommonAbsSender sender) {
return sender.call(method);
}

@Override
public void callAsync(@NotNull CommonAbsSender sender,
@Nullable Consumer<? super Boolean> responseConsumer,
@Nullable Consumer<TelegramApiException> apiExceptionConsumer,
@Nullable Consumer<Exception> exceptionConsumer) {
sender.callAsync(method, responseConsumer, apiExceptionConsumer, exceptionConsumer);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.annimon.tgbotsmodule.api.methods.stickers;

import com.annimon.tgbotsmodule.api.methods.interfaces.Method;
import com.annimon.tgbotsmodule.services.CommonAbsSender;
import java.util.List;
import java.util.function.Consumer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.telegram.telegrambots.meta.api.methods.stickers.SetStickerEmojiList;
import org.telegram.telegrambots.meta.exceptions.TelegramApiException;

public class SetStickerEmojiListMethod implements Method<Boolean> {

private final SetStickerEmojiList method;

public SetStickerEmojiListMethod() {
this(new SetStickerEmojiList());
}

public SetStickerEmojiListMethod(@NotNull SetStickerEmojiList method) {
this.method = method;
}

public List<String> getEmojiList() {
return method.getEmojiList();
}

public SetStickerEmojiListMethod setEmoji(@NotNull String emoji) {
return setEmojiList(List.of(emoji));
}

public SetStickerEmojiListMethod setEmojiList(@NotNull List<String> emojiList) {
method.setEmojiList(emojiList);
return this;
}

@Override
public Boolean call(@NotNull CommonAbsSender sender) {
return sender.call(method);
}

@Override
public void callAsync(@NotNull CommonAbsSender sender,
@Nullable Consumer<? super Boolean> responseConsumer,
@Nullable Consumer<TelegramApiException> apiExceptionConsumer,
@Nullable Consumer<Exception> exceptionConsumer) {
sender.callAsync(method, responseConsumer, apiExceptionConsumer, exceptionConsumer);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package com.annimon.tgbotsmodule.api.methods.stickers;

import com.annimon.tgbotsmodule.api.methods.interfaces.Method;
import com.annimon.tgbotsmodule.services.CommonAbsSender;
import java.util.List;
import java.util.function.Consumer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.telegram.telegrambots.meta.api.methods.stickers.SetStickerKeywords;
import org.telegram.telegrambots.meta.exceptions.TelegramApiException;

public class SetStickerKeywordsMethod implements Method<Boolean> {

private final SetStickerKeywords method;

public SetStickerKeywordsMethod() {
this(new SetStickerKeywords());
}

public SetStickerKeywordsMethod(@NotNull SetStickerKeywords method) {
this.method = method;
}

public String getSticker() {
return method.getSticker();
}

public SetStickerKeywordsMethod setSticker(@NotNull String sticker) {
method.setSticker(sticker);
return this;
}

public List<String> getKeywords() {
return method.getKeywords();
}

public SetStickerKeywordsMethod setKeyword(@NotNull String keyword) {
return setKeywords(List.of(keyword));
}

public SetStickerKeywordsMethod setKeywords(@NotNull List<String> keywords) {
method.setKeywords(keywords);
return this;
}

@Override
public Boolean call(@NotNull CommonAbsSender sender) {
return sender.call(method);
}

@Override
public void callAsync(@NotNull CommonAbsSender sender,
@Nullable Consumer<? super Boolean> responseConsumer,
@Nullable Consumer<TelegramApiException> apiExceptionConsumer,
@Nullable Consumer<Exception> exceptionConsumer) {
sender.callAsync(method, responseConsumer, apiExceptionConsumer, exceptionConsumer);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.annimon.tgbotsmodule.api.methods.stickers;

import com.annimon.tgbotsmodule.api.methods.interfaces.Method;
import com.annimon.tgbotsmodule.services.CommonAbsSender;
import java.util.function.Consumer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.telegram.telegrambots.meta.api.methods.stickers.SetStickerMaskPosition;
import org.telegram.telegrambots.meta.api.objects.stickers.MaskPosition;
import org.telegram.telegrambots.meta.exceptions.TelegramApiException;

public class SetStickerMaskPositionMethod implements Method<Boolean> {

private final SetStickerMaskPosition method;

public SetStickerMaskPositionMethod() {
this(new SetStickerMaskPosition());
}

public SetStickerMaskPositionMethod(@NotNull SetStickerMaskPosition method) {
this.method = method;
}

public String getSticker() {
return method.getSticker();
}

public SetStickerMaskPositionMethod setSticker(@NotNull String sticker) {
method.setSticker(sticker);
return this;
}

public MaskPosition getMaskPosition() {
return method.getMaskPosition();
}

public SetStickerMaskPositionMethod setMaskPosition(@NotNull MaskPosition maskPosition) {
method.setMaskPosition(maskPosition);
return this;
}

@Override
public Boolean call(@NotNull CommonAbsSender sender) {
return sender.call(method);
}

@Override
public void callAsync(@NotNull CommonAbsSender sender,
@Nullable Consumer<? super Boolean> responseConsumer,
@Nullable Consumer<TelegramApiException> apiExceptionConsumer,
@Nullable Consumer<Exception> exceptionConsumer) {
sender.callAsync(method, responseConsumer, apiExceptionConsumer, exceptionConsumer);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
import java.util.function.Consumer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.telegram.telegrambots.meta.api.methods.stickers.SetStickerSetThumb;
import org.telegram.telegrambots.meta.api.methods.stickers.SetStickerSetThumbnail;
import org.telegram.telegrambots.meta.api.objects.InputFile;
import org.telegram.telegrambots.meta.exceptions.TelegramApiException;

public class SetStickerSetThumbMethod implements
UserMethod<SetStickerSetThumbMethod, Boolean>,
InputFileMethod<SetStickerSetThumbMethod, Boolean> {
public class SetStickerSetThumbnailMethod implements
UserMethod<SetStickerSetThumbnailMethod, Boolean>,
InputFileMethod<SetStickerSetThumbnailMethod, Boolean> {

private final SetStickerSetThumb method;
private final SetStickerSetThumbnail method;

public SetStickerSetThumbMethod() {
this(new SetStickerSetThumb());
public SetStickerSetThumbnailMethod() {
this(new SetStickerSetThumbnail());
}

public SetStickerSetThumbMethod(@NotNull SetStickerSetThumb method) {
public SetStickerSetThumbnailMethod(@NotNull SetStickerSetThumbnail method) {
this.method = method;
}

Expand All @@ -30,19 +30,19 @@ public Long getUserId() {
}

@Override
public SetStickerSetThumbMethod setUserId(@NotNull Long userId) {
public SetStickerSetThumbnailMethod setUserId(@NotNull Long userId) {
method.setUserId(userId);
return this;
}

@Override
public InputFile getFile() {
return method.getThumb();
return method.getThumbnail();
}

@Override
public SetStickerSetThumbMethod setFile(@NotNull InputFile file) {
method.setThumb(file);
public SetStickerSetThumbnailMethod setFile(@NotNull InputFile file) {
method.setThumbnail(file);
return this;
}

Expand Down
Loading

0 comments on commit c245c16

Please sign in to comment.