Remove code for tweeting

This commit is contained in:
Steffen Lange 2024-12-12 14:12:22 +01:00
parent 172a97c482
commit b9659dbd50
3 changed files with 0 additions and 59 deletions

View file

@ -1,50 +0,0 @@
#!/usr/bin/php
<?php
require('twitter-php/src/twitter.class.php');
require('PatchObject.php');
require('Database.php');
require('TwitterKey.php');
use DG\Twitter\Twitter;
function timestamp() {
$f = fopen(__DIR__ . '/timestamp-twitter.dat', 'a+');
flock($f, LOCK_EX);
$t = fgets($f);
ftruncate($f, 0);
fwrite($f, time());
fflush($f);
flock($f, LOCK_UN);
fclose($f);
return intval($t);
}
$db = new Database(__DIR__ . '/db.json');
if (!$db->load()) {
exit(1);
}
$last = timestamp();
$twitter = new Twitter($TwitterConsumerKey, $TwitterConsumerSecret, $TwitterAccessToken, $TwitterAccessTokenSecret);
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;
try {
$twitter->send($s);
} catch (DG\Twitter\Exception $e) {
fwrite(STDERR, 'ERROR: ' . $e->getMessage() . PHP_EOL);
}
}
}
?>

View file

@ -1,8 +0,0 @@
<?php
$TwitterConsumerKey = '';
$TwitterConsumerSecret = '';
$TwitterAccessToken = '';
$TwitterAccessTokenSecret = '';
?>

View file

@ -6,6 +6,5 @@ SITEDIR="/var/www/virtual/steffen/patchbot.de"
"$SCRIPTDIR/PatchCollector.php" || exit 1 "$SCRIPTDIR/PatchCollector.php" || exit 1
"$SCRIPTDIR/PatchViewer.php" > "$SITEDIR/index.html" "$SCRIPTDIR/PatchViewer.php" > "$SITEDIR/index.html"
"$SCRIPTDIR/PatchFeeder.php" > "$SITEDIR/rss.xml" "$SCRIPTDIR/PatchFeeder.php" > "$SITEDIR/rss.xml"
#[ -e "$SCRIPTDIR/TwitterKey.php" ] && "$SCRIPTDIR/PatchTwitter.php"
[ -e "$SCRIPTDIR/MastodonKey.php" ] && "$SCRIPTDIR/PatchMastodon.php" [ -e "$SCRIPTDIR/MastodonKey.php" ] && "$SCRIPTDIR/PatchMastodon.php"