24 lines
829 B
PHP
24 lines
829 B
PHP
<?php
|
|
require_once('config.php');
|
|
require_once('shared.php');
|
|
|
|
if (DEBUG) botlog("\n\n\n".'[II] Scheduler starting at ' . date('Y-m-d H:i:s') . ' ====================' . "\n\n");
|
|
|
|
$dateID = date('Y-n-j G:*');
|
|
echo $dateID;
|
|
$sql = new mysqli('localhost', MYSQL_USER, MYSQL_PASSWORD, MYSQL_DB);
|
|
$query = $sql->query("SELECT MessageID,ChatID FROM ".MYSQL_TABLE." WHERE DateTime='".$dateID."'");
|
|
while ($row = $query->fetch_assoc()) {
|
|
info("Publishing message $row[MessageID]");
|
|
$bot_query = API_URL . API_TOKEN . '/forwardMessage?' .
|
|
'chat_id=' . urlencode(API_CHANNEL_ID) .
|
|
'&from_chat_id=' . urlencode($row['ChatID']) .
|
|
'&message_id=' . urlencode($row['MessageID']);
|
|
file_get_contents($bot_query);
|
|
}
|
|
// clean events <= today
|
|
|
|
$sql->query("DELETE FROM ".MYSQL_TABLE." WHERE DateTime<='".$dateID."'");
|
|
$sql->close();
|
|
?>
|