diff --git a/TODO b/TODO index fca0bc2..0a4b2b8 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,7 @@ TODO LIST ============= + +== Short term things == * Document code Very important, since now it is far more complex @@ -9,9 +11,17 @@ ** Create a class for inline keyboard management ** Use info(), warning() and error() instead of botlog() ** Always insert "or error(... $sql->error())" when making SQL queries. +** Use curl instead of file_get_contents() because it has a better way to + manage timeout and HTTP errors -* Capabilities to send Image/Videos/Document (at the moment are blocked) +* Better way to manage Image/Videos/Document and forwarded message +* At the moment, the /list command is terrible + +* (Don't know why) inline buttons have white text, but if are present + empty buttons, the following have black text + +== Long term things == * Facebook page integration Make the bot publish info not only in mailing list and Telegram channel, but also on our Facebook page diff --git a/main.php b/main.php index d65e077..138ccfc 100644 --- a/main.php +++ b/main.php @@ -103,10 +103,21 @@ if (isset ($row->callback_query)) { $IDdelete = $mc->get($chatID.MC_DELETE_SCHEDULED_ID) or error("No ID to delete"); $sql->query("DELETE FROM ".MYSQL_TABLE." WHERE ID=$IDdelete") or error("Can't make the query, SQL error ".$sql->error); - $sql->close(); - editMessageText($chatID, $inlineID, "Rimosso correttamente"); - die(); + $numbers = $sql->query("SELECT COUNT(*) FROM ".MYSQL_TABLE); + $numbers = $numbers->fetch_array()[0]; + info("Number of pages: $numbers"); + $offset = $mc->get($chatID.MC_LIST_NUMBER); + + if ($numbers == 0) { + editMessageText($chatID, $inlineID, "Non ce n'è più"); + $sql->close(); + die(); + } + elseif ($offset > 0) { + $offset--; + } + //~ die(); break; case '>': $sql = new mysqli('localhost', MYSQL_USER, MYSQL_PASSWORD, MYSQL_DB); diff --git a/schedule.php b/schedule.php index 972a2d9..ae37aa4 100644 --- a/schedule.php +++ b/schedule.php @@ -27,7 +27,8 @@ while ($row = $query->fetch_assoc()) { "&parse_mode=".urlencode("Markdown"); file_get_contents($bot_query); * */ - forwardMessage(API_CHANNEL_ID, $row['ChatID'], $row['MessageID']); + forwardMessage(API_CHANNEL_ID, $row['ChatID'], $row['MessageID']) or + error("Scheduler couldn't forward the message. I'll try next hour"); } diff --git a/shared.php b/shared.php index 8642efd..d1903ba 100644 --- a/shared.php +++ b/shared.php @@ -12,6 +12,7 @@ // Unrecoverable error, program must be terminated function error($message) { if (DEBUG) botlog("[EE] $message\n"); + if (DEBUG) botlog('[II] BOT request (cruently) ended at ' . date('Y-m-d H:i:s') . ' ====================' . "\n"); die(); }