プレローマ用botエンジン
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

61 行
1.6 KiB

<?php
// https://tinysubversions.com/notes/mastodon-bot/
include('config.php');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $domain.'/api/v1/timelines/home');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer '.$token]);
$get = curl_exec($ch);
$err = curl_error($ch);
curl_close($ch);
if (!$get) return 400;
$saveid = [];
foreach (json_decode($get) as $g) {
//if (is_null($g->in_reply_to_id)) continue;
if ($g->account->bot) continue;
if (in_array($g->id, $saveid)) continue;
if ($g->favourited) continue;
$param = [
'status' => $mess,
'source' => $source,
'visibility' => $visibility,
'content_type' => 'text/plain',
'in_reply_to_id' => $g->id
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $domain.'/api/v1/statuses');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer '.$token]);
$get = curl_exec($ch);
$err = curl_error($ch);
curl_close($ch);
if (!$get) return 400;
$saveid[] = $g->id;
}
foreach ($saveid as $s) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $domain.'/api/v1/statuses/'.$s.'/favourite');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer '.$token]);
$get = curl_exec($ch);
$err = curl_error($ch);
curl_close($ch);
if (!$get) return 400;
}
return 200;
?>