最初コミット
このコミットが含まれているのは:
コミット
fc3b5d6483
|
@ -0,0 +1 @@
|
|||
config.php
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
$token = ''; // authトークン
|
||||
$mess = ''; // メッセージ
|
||||
$domain = 'https://'; // インスタンスのドメイン名
|
||||
$source = '076 Pleroma Bot Engine';
|
||||
$visibility = 'public';
|
||||
?>
|
|
@ -0,0 +1,18 @@
|
|||
SHELL=/bin/sh
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
|
||||
# Example of job definition:
|
||||
# .---------------- minute (0 - 59)
|
||||
# | .------------- hour (0 - 23)
|
||||
# | | .---------- day of month (1 - 31)
|
||||
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
|
||||
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
|
||||
# | | | | |
|
||||
# * * * * * user-name command to be executed
|
||||
# 毎日9時
|
||||
0 9 * * * root php /opt/bot/post.php
|
||||
# 毎日21時
|
||||
0 21 * * * root php /opt/bot/post.php
|
||||
# 出来るだけ
|
||||
* * * * * root php /opt/bot/reply.php
|
||||
#
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
// https://tinysubversions.com/notes/mastodon-bot/
|
||||
include('config.php');
|
||||
$param = [
|
||||
'status' => $mess,
|
||||
'source' => $source,
|
||||
'visibility' => $visibility,
|
||||
'content_type' => 'text/plain'
|
||||
];
|
||||
$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;
|
||||
|
||||
return 200;
|
||||
?>
|
|
@ -0,0 +1,61 @@
|
|||
<?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;
|
||||
?>
|
新しいイシューから参照