From 1708965be2e0138aa4036e3b48634ead199b5e27 Mon Sep 17 00:00:00 2001 From: mirzaev Date: Sat, 8 Mar 2025 21:42:01 +0700 Subject: [PATCH] fixed file names and button listeners --- .../system/models/interneturok.php | 17 +++++++++++--- .../system/public/telegram.php | 22 +++++++++---------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/mirzaev/parser_from_interneturok/system/models/interneturok.php b/mirzaev/parser_from_interneturok/system/models/interneturok.php index 5f6a6bf..c63acb1 100644 --- a/mirzaev/parser_from_interneturok/system/models/interneturok.php +++ b/mirzaev/parser_from_interneturok/system/models/interneturok.php @@ -176,7 +176,8 @@ final class interneturok extends core if (!empty($accounts)) { // Initialized accounts - if (shuffle($accounts)) { + /* if (shuffle($accounts)) { */ + if (true) { // Shuffled accounts foreach ($accounts as $account) { @@ -243,7 +244,6 @@ final class interneturok extends core if ($homework->status === 'checked' && $homework->mark === 5) { // Homework checked and completed for a grade of 5 - // Writing into the output buffer echo "Найдено домашнее задание: $homework->item_id с оценкой $homework->mark\n"; @@ -778,8 +778,19 @@ final class interneturok extends core if ($attachment->uploader_role === 'student' && $attachment->attachable_type === 'Result::Homework') { // Found the homework attachment + // Searching for number of the attachment and the file extension + preg_match('/^(\d+).*(\.\w{3,4})$/', $attachment->attach_path, $matches); + + try { + // Initializing the name of the attachment file + $name = $matches[1] . $matches[2]; + } catch (exception $exception) { + // Initializing the name of the attachment file + $name = uniqid() . '.jpg'; + } + // Initializing path to the downloaded file - $path = $storage . DIRECTORY_SEPARATOR . $attachment->attach_path; + $path = $storage . DIRECTORY_SEPARATOR . ($name ?? uniqid() . '.jpg'); // Downloading the file $this->browser->request('GET', $attachment->attach, ['sink' => $path]); diff --git a/mirzaev/parser_from_interneturok/system/public/telegram.php b/mirzaev/parser_from_interneturok/system/public/telegram.php index 7b15d3a..fb4d612 100755 --- a/mirzaev/parser_from_interneturok/system/public/telegram.php +++ b/mirzaev/parser_from_interneturok/system/public/telegram.php @@ -80,15 +80,8 @@ for ($i = 4; $i <= 11; ++$i) { $robot->onCbQueryData(["grade_$i"], fn(context $context) => parser::grade(context: $context, grade: $i)); } -for ($i = 2; $i <= 9; ++$i) { - // Generating buttons from 2 to 9 numbers of weeks - - // Initializing numbers of weeks buttons - $robot->onCbQueryData(["week_$i"], fn(context $context) => parser::date(context: $context, week: $i)); -} - -for ($i = 11; $i <= 18; ++$i) { - // Generating buttons from 11 to 18 numbers of weeks +for ($i = 32; $i <= 38; ++$i) { + // Generating buttons from 32 to 38 numbers of weeks // Initializing numbers of weeks buttons $robot->onCbQueryData(["week_$i"], fn(context $context) => parser::date(context: $context, week: $i)); @@ -101,8 +94,15 @@ for ($i = 21; $i <= 30; ++$i) { $robot->onCbQueryData(["week_$i"], fn(context $context) => parser::date(context: $context, week: $i)); } -for ($i = 32; $i <= 38; ++$i) { - // Generating buttons from 32 to 38 numbers of weeks +for ($i = 11; $i <= 18; ++$i) { + // Generating buttons from 11 to 18 numbers of weeks + + // Initializing numbers of weeks buttons + $robot->onCbQueryData(["week_$i"], fn(context $context) => parser::date(context: $context, week: $i)); +} + +for ($i = 2; $i <= 9; ++$i) { + // Generating buttons from 2 to 9 numbers of weeks // Initializing numbers of weeks buttons $robot->onCbQueryData(["week_$i"], fn(context $context) => parser::date(context: $context, week: $i));