diff --git a/gradle.properties b/gradle.properties index dfdc9dc..3c89bfe 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,8 @@ ## Core -VERSION = 0.8.0.6 +VERSION = 0.8.0.7 -CODENAME = fuzhou +CODENAME = putian # dependencies diff --git a/src/main/java/cc/sukazyo/cono/morny/GradleProjectConfigures.java b/src/main/java/cc/sukazyo/cono/morny/GradleProjectConfigures.java index 203a4a6..d6ac208 100644 --- a/src/main/java/cc/sukazyo/cono/morny/GradleProjectConfigures.java +++ b/src/main/java/cc/sukazyo/cono/morny/GradleProjectConfigures.java @@ -4,7 +4,7 @@ package cc.sukazyo.cono.morny; * the final field that will be updated by gradle automatically. */ public class GradleProjectConfigures { - public static final String VERSION = "0.8.0.6"; - public static final String CODENAME = "fuzhou"; - public static final long COMPILE_TIMESTAMP = 1665825000740L; + public static final String VERSION = "0.8.0.7"; + public static final String CODENAME = "putian"; + public static final long COMPILE_TIMESTAMP = 1665827278036L; } diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/command/Encryptor.java b/src/main/java/cc/sukazyo/cono/morny/bot/command/Encryptor.java index 93aacca..485a562 100644 --- a/src/main/java/cc/sukazyo/cono/morny/bot/command/Encryptor.java +++ b/src/main/java/cc/sukazyo/cono/morny/bot/command/Encryptor.java @@ -6,6 +6,7 @@ import cc.sukazyo.cono.morny.util.CommonConvert; import cc.sukazyo.cono.morny.util.CommonEncrypt; import cc.sukazyo.cono.morny.util.tgapi.InputCommand; import cc.sukazyo.cono.morny.util.tgapi.formatting.MsgEscape; +import com.pengrad.telegrambot.model.PhotoSize; import com.pengrad.telegrambot.model.Update; import com.pengrad.telegrambot.model.request.ParseMode; import com.pengrad.telegrambot.request.GetFile; @@ -92,6 +93,28 @@ public class Encryptor implements ITelegramCommand { return; } dataName = event.message().replyToMessage().document().fileName(); + } else if (event.message().replyToMessage() != null && event.message().replyToMessage().photo() != null) { + inputText = false; + try { + PhotoSize originPhoto = null; + long photoSize = 0; + for (PhotoSize size : event.message().replyToMessage().photo()) if (photoSize < (long)size.width() *size.height()) { + originPhoto = size; + photoSize = (long)size.width() *size.height(); + } // found max size (original) image in available sizes + if (originPhoto==null) throw new IOException("no photo object from api."); + data = MornyCoeur.getAccount().getFileContent(MornyCoeur.extra().exec(new GetFile( + originPhoto.fileId() + )).file()); + } catch (IOException e) { + logger.warn("NetworkRequest error: TelegramFileAPI:\n\t" + e.getMessage()); + MornyCoeur.extra().exec(new SendSticker( + event.message().chat().id(), + TelegramStickers.ID_NETWORK_ERR + ).replyToMessageId(event.message().messageId())); + return; + } + dataName = "photo"+CommonConvert.byteArrayToHex(CommonEncrypt.hashMd5(String.valueOf(System.currentTimeMillis()))).substring(32-12).toUpperCase()+".png"; } else if (event.message().replyToMessage() != null && event.message().replyToMessage().text() != null) { inputText = true; data = event.message().replyToMessage().text().getBytes(CommonEncrypt.ENCRYPT_STANDARD_CHARSET);