generated from mirzaev/pot
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
05143b6865 | |||
accfe5a496 | |||
53f8f3871c | |||
d2c86a6222 |
@@ -5,7 +5,7 @@ Wants=network.target
|
|||||||
After=syslog.target network-online.target
|
After=syslog.target network-online.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart=sudo -u www-data /usr/bin/php /var/www/project/mirzaev/parser_from_interneturok/system/public/telegram.php
|
ExecStart=sudo -u www-data /usr/bin/php /var/www/parser_from_interneturok/mirzaev/parser_from_interneturok/system/public/telegram.php
|
||||||
PIDFile=/var/run/php/parser_from_interneturok-telegram.pid
|
PIDFile=/var/run/php/parser_from_interneturok-telegram.pid
|
||||||
RemainAfterExit=no
|
RemainAfterExit=no
|
||||||
RuntimeMaxSec=3600s
|
RuntimeMaxSec=3600s
|
||||||
|
@@ -900,16 +900,21 @@ final class interneturok extends core
|
|||||||
*/
|
*/
|
||||||
public static function amount(): int
|
public static function amount(): int
|
||||||
{
|
{
|
||||||
// Opening the interneturok accounts file
|
try {
|
||||||
$file = new spl(INTERNETUROK_ACCOUNTS_FILE, 'r');
|
// Opening the interneturok accounts file
|
||||||
|
$file = new spl(INTERNETUROK_ACCOUNTS_FILE, 'r');
|
||||||
|
|
||||||
// Move the cursor to the last row
|
// Move the cursor to the last row
|
||||||
$file->seek(PHP_INT_MAX);
|
$file->seek(PHP_INT_MAX);
|
||||||
|
|
||||||
// Initializing number of the last row
|
// Initializing number of the last row
|
||||||
$rows = $file->key();
|
$rows = $file->key();
|
||||||
|
|
||||||
// Exit (success)
|
// Exit (success)
|
||||||
return $rows;
|
return $rows;
|
||||||
|
} catch (exception $exception) {
|
||||||
|
// Exit (fail)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,9 @@ use Zanzara\Context as context,
|
|||||||
// Framework for asynchronous PHP
|
// Framework for asynchronous PHP
|
||||||
use function React\Async\await;
|
use function React\Async\await;
|
||||||
|
|
||||||
|
// Built-in libraries
|
||||||
|
use Exception as exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Telegram shcool subjects parser
|
* Telegram shcool subjects parser
|
||||||
*
|
*
|
||||||
@@ -205,26 +208,38 @@ final class parser extends core
|
|||||||
// Initializing the parser
|
// Initializing the parser
|
||||||
$parser = new interneturok();
|
$parser = new interneturok();
|
||||||
|
|
||||||
// Parsing homework files
|
try {
|
||||||
$files = $parser->parse(subject: $subject, grade: $grade, waiting: 3);
|
|
||||||
|
|
||||||
if (!empty($files)) {
|
// Parsing homework files
|
||||||
// Initialized homework files
|
$files = $parser->parse(subject: $subject, grade: $grade, waiting: 3);
|
||||||
|
|
||||||
foreach ($files as $file) {
|
if (!empty($files)) {
|
||||||
// Iterating over files in the storage
|
// Initialized homework files
|
||||||
|
|
||||||
// Sending the file
|
foreach ($files as $file) {
|
||||||
await($context->sendDocument(new file_input($file)));
|
// Iterating over files in the storage
|
||||||
|
|
||||||
|
// Sending the file
|
||||||
|
await($context->sendDocument(new file_input($file)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deleting in the telegram user buffer
|
||||||
|
$context->deleteUserDataItem(static::PROCESS);
|
||||||
|
} else {
|
||||||
|
// Not initialized homework files
|
||||||
|
|
||||||
|
// Sending the message
|
||||||
|
$context->sendMessage('❌ *Не найдены домашние задания*')
|
||||||
|
->then(function (message $message) use ($context) {
|
||||||
|
// Sended the message
|
||||||
|
|
||||||
|
// Sending the menu with subjects
|
||||||
|
commands::menu($context);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
} catch (exception $exception) {
|
||||||
// Deleting in the telegram user buffer
|
|
||||||
$context->deleteUserDataItem(static::PROCESS);
|
|
||||||
} else {
|
|
||||||
// Not initialized homework files
|
|
||||||
|
|
||||||
// Sending the message
|
// Sending the message
|
||||||
$context->sendMessage('❌ *Не найдены домашние задания')
|
$context->sendMessage('⚠️ *Произошла ошибка при обработке домашних заданий*')
|
||||||
->then(function (message $message) use ($context) {
|
->then(function (message $message) use ($context) {
|
||||||
// Sended the message
|
// Sended the message
|
||||||
|
|
||||||
|
@@ -32,9 +32,6 @@ define('VIEWS', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'view
|
|||||||
// Initializing path to the directory of settings
|
// Initializing path to the directory of settings
|
||||||
define('SETTINGS', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'settings');
|
define('SETTINGS', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'settings');
|
||||||
|
|
||||||
// Initializing system settings
|
|
||||||
require SETTINGS . DIRECTORY_SEPARATOR . 'system.php';
|
|
||||||
|
|
||||||
// Initializing path to the directory of the storage
|
// Initializing path to the directory of the storage
|
||||||
define('STORAGE', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'storage');
|
define('STORAGE', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'storage');
|
||||||
|
|
||||||
|
@@ -5,5 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
return [
|
return [
|
||||||
1053489457 // Arsen Mirzaev Tatyano-Muradovich @redloser
|
1053489457, // Arsen Mirzaev Tatyano-Muradovich @redloser
|
||||||
|
6831961323, // @IU_K1LLER777
|
||||||
|
1142807069 // @kysakapro
|
||||||
];
|
];
|
||||||
|
@@ -1,4 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
// Initializing default theme for the views templater
|
|
||||||
define('THEME', 'default');
|
|
Reference in New Issue
Block a user