Skip to content

Commit

Permalink
Using multicurl can lead to reaching TG's guerylimit
Browse files Browse the repository at this point in the history
This kinda throttles it a bit if we have a lot of stuff to delete (raid hour)
  • Loading branch information
Ninjasoturi committed Aug 26, 2021
1 parent 0eb7114 commit 1f8e451
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions logic/run_cleanup.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,18 @@ function run_cleanup ($telegram = 2, $database = 2) {
WHERE raids.end_time < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$config->CLEANUP_TIME_TG.' MINUTE)
');
$cleanup_ids = [];
$tg_json = [];
cleanup_log('Telegram cleanup starting. Found ' . $rs->rowCount() . ' entries for cleanup.');
if($rs->rowCount() > 0) {
while($row = $rs->fetch()) {
if($row['skip_del_message'] == 0) {
$tg_json[] = delete_message($row['chat_id'], $row['message_id'], true);
delete_message($row['chat_id'], $row['message_id']);
cleanup_log('Deleting raid: '.$row['raid_id'].' from chat '.$row['chat_id'].' (message_id: '.$row['message_id'].')');
} else {
cleanup_log('Chat message for raid '.$row['raid_id'].' in chat '.$row['chat_id'].' is over 48 hours old. It can\'t be deleted by the bot. Skipping deletion and removing database entry.');
}
$cleanup_ids[] = $row['id'];
}
my_query('DELETE FROM cleanup WHERE id IN (' . implode(',', $cleanup_ids) . ')');
curl_json_multi_request($tg_json);
}
}
if($database == 1) {
Expand Down

0 comments on commit 1f8e451

Please sign in to comment.