From e58b1112807fdd085168dd55b1b39bc08e0ed8cc Mon Sep 17 00:00:00 2001 From: Steffen Lange Date: Sat, 30 Apr 2022 01:06:06 +0200 Subject: [PATCH] Add Mastodon toot exporter --- MastodonKey.php.example | 5 +++++ PatchMastodon.php | 45 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 MastodonKey.php.example create mode 100755 PatchMastodon.php diff --git a/MastodonKey.php.example b/MastodonKey.php.example new file mode 100644 index 0000000..1af45a3 --- /dev/null +++ b/MastodonKey.php.example @@ -0,0 +1,5 @@ + diff --git a/PatchMastodon.php b/PatchMastodon.php new file mode 100755 index 0000000..f632708 --- /dev/null +++ b/PatchMastodon.php @@ -0,0 +1,45 @@ +#!/usr/bin/php +load()) { + exit(1); +} + +$last = timestamp(); + +$mastodon = new MastodonAPI($MastodonAccessToken, 'https://botsin.space'); + +for ($i = 0; $i < $db->count(); $i++) { + $patch = $db->get($i); + if ($last < $patch->getTimestamp()) { + $s = $patch->getVendor() . ' released #' . $patch->getProduct(); + if (!empty($patch->getBranch())) + $s .= ' ' . $patch->getBranch(); + $s .= ' version ' . $patch->getVersion() . '.'; + $len = strlen($s) + 24; // + space + wrapped URL + $s .= ' ' . $patch->getURL(); + echo $patch->getId() . ': ' . $len . PHP_EOL; + $dat = ['status' => $s]; + $mastodon->postStatus($dat); + } +} + +?>