You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.4 KiB
42 lines
1.4 KiB
#!/usr/bin/php |
|
<?php |
|
|
|
// Special Thanks to @avocatto@pleroma.paritybit.ca for suggesting this idea! |
|
|
|
|
|
// Change these two variables for your instance! |
|
$instance = 'landofkittens.social'; // The instance you're on, minus https:// (Only tested on Pleroma) |
|
$account = '9yio7aRBggsrDkDobg'; // Your account id (this is not your username, pleroma api docs says it can be but never worked for me) |
|
|
|
echo "Getting list of followers...\r\n"; |
|
|
|
if (!in_array('--no-cache', $argv) && file_exists(".{$account}_{$instance}_followers.cache.json")) { |
|
$users = json_decode(file_get_contents(".{$account}_{$instance}_followers.cache.json")); |
|
} else { |
|
$check = true; |
|
$users = []; |
|
$max_id = ''; |
|
|
|
while ($check) { |
|
$temp = json_decode(file_get_contents("https://$instance/api/v1/accounts/$account/followers?limit=40&max_id=$max_id")); |
|
foreach ($temp as $user) { |
|
$users[] = $user->acct; |
|
$max_id = $user->id; |
|
} |
|
|
|
if (count($temp) !== 40) { |
|
$check = false; |
|
} |
|
} |
|
file_put_contents(".{$account}_{$instance}_followers.cache.json", json_encode($users)); |
|
} |
|
|
|
echo "Choosing someone...\r\n"; |
|
|
|
// If we want a unique person per day, we hit this code |
|
if (in_array('--day', $argv)) { |
|
srand(date('mdy')); |
|
} |
|
|
|
|
|
echo "=== Today is @" . $users[rand(0,count($users) - 1)] . " appreciation day! ===\r\n";
|
|
|