mode = $mode;
}
public function execute(): void
{
$m = $this->message->getReplyToMessage();
if (!$m) {
$this->bot->sendMessage($this->message->getChat()->getId(), "Cita una foto (nessun messaggio citato)", null, false, $this->message->getMessageId());
} else {
$p = $m->getPhoto();
if (!$p) {
$this->bot->sendMessage($this->message->getChat()->getId(), "Cita una foto (non hai citato una foto)", null, false, $this->message->getMessageId());
} else {
$biggest = $p[count($p) - 1];
$path = $this->bot->getFile($biggest->getFileId())->getFilePath();
$url = "https://api.telegram.org/file/bot" . $GLOBALS["token"] . "/" . $path;
if (!file_exists('tempImageProcessing')) {
mkdir('tempImageProcessing');
}
$io = bin2hex(random_bytes(10));
$filename = "tempImageProcessing/" . $io . ".jpg";
$ch = curl_init($url);
$fp = fopen($filename, 'wb+');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
$im = imagecreatefromjpeg($filename);
if ($this->mode == self::VERTICAL || $this->mode == self::BOTH) imageflip($im, IMG_FLIP_VERTICAL);
if ($this->mode == self::HORIZONTAL || $this->mode == self::BOTH) imageflip($im, IMG_FLIP_HORIZONTAL);
if ($this->mode == self::VERTICAL) $text = "Rovesciato in Verticale";
if ($this->mode == self::HORIZONTAL) $text = "Rovesciato in Orizzontale";
if ($this->mode == self::BOTH) $text = "Rovesciato in Orizzontale e Verticale";
imagejpeg($im, $filename);
$this->bot->sendChatAction($this->message->getChat()->getId(), "upload_photo");
$this->bot->sendPhoto(
$this->message->getChat()->getId(),
$GLOBALS["baseurl"] . "/tempImageProcessing/getter.php?photo=" . $io,
$text,
$this->message->getMessageId(),
null,
null,
"HTML"
);
}
}
}
}