forked from pokepark/PokemonRaidBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelete_raid.php
63 lines (55 loc) · 1.55 KB
/
delete_raid.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
/**
* Delete raid.
* @param $raid_id
*/
function delete_raid($raid_id)
{
// Delete telegram messages for raid.
$rs = my_query(
"
SELECT *
FROM cleanup
WHERE raid_id = '{$raid_id}'
AND chat_id <> 0
"
);
// Counter
$counter = 0;
// Delete every telegram message
while ($row = $rs->fetch()) {
// Delete telegram message.
debug_log('Deleting telegram message ' . $row['message_id'] . ' from chat ' . $row['chat_id'] . ' for raid ' . $row['raid_id']);
delete_message($row['chat_id'], $row['message_id']);
$counter = $counter + 1;
}
// Nothing to delete on telegram.
if ($counter == 0) {
debug_log('Raid with ID ' . $raid_id . ' was not found in the cleanup table! Skipping deletion of telegram messages!');
}
// Delete raid from cleanup table.
debug_log('Deleting raid ' . $raid_id . ' from the cleanup table:');
$rs_cleanup = my_query(
"
DELETE FROM cleanup
WHERE raid_id = '{$raid_id}'
"
);
// Delete raid from attendance table.
debug_log('Deleting raid ' . $raid_id . ' from the attendance table:');
$rs_attendance = my_query(
"
DELETE FROM attendance
WHERE raid_id = '{$raid_id}'
"
);
// Delete raid from raid table.
debug_log('Deleting raid ' . $raid_id . ' from the raid table:');
$rs_raid = my_query(
"
DELETE FROM raids
WHERE id = '{$raid_id}'
"
);
}
?>