From e31dd6a0fb88e1beb46d27292c214ce20bc2eed3 Mon Sep 17 00:00:00 2001 From: Eyre_S Date: Sat, 15 Oct 2022 17:51:56 +0800 Subject: [PATCH] =?UTF-8?q?/encrypt=20=E7=8E=B0=E5=9C=A8=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E4=BA=86=E5=9B=BE=E7=89=87=20//=20=E8=AE=BE=E7=BD=AE=E7=89=88?= =?UTF-8?q?=E6=9C=AC=20CODENAME=20=E4=B8=BA=20putian?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 4 ++-- .../cono/morny/GradleProjectConfigures.java | 6 ++--- .../cono/morny/bot/command/Encryptor.java | 23 +++++++++++++++++++ 3 files changed, 28 insertions(+), 5 deletions(-) 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);