Browse Source

Options, images WIP

master
Alexander Yakovlev 4 years ago
parent
commit
dc92a90150
  1. 17
      bot.php
  2. 2
      config.yml.example

17
bot.php

@ -35,6 +35,19 @@ function ellipse($str,$n_chars,$crop_str=' [...]')
return $buff;
}
function download($url, $outFile) {
$options = array(
CURLOPT_FILE => fopen($outFile, 'w'),
CURLOPT_TIMEOUT => 28800, // set this to 8 hours so we dont timeout on big files
CURLOPT_URL => $url
);
$ch = curl_init();
curl_setopt_array($ch, $options);
curl_exec($ch);
curl_close($ch);
}
$string = get_text('https://ifhub.club/rss/new/');
$service = new \Sabre\Xml\Service();
$service->elementMap = [
@ -98,10 +111,12 @@ foreach ($articles as $article) {
$mdescription .= ": $link";
/*
if ($image) {
download('https://ifhub.club'.$image, './'.basename($image));
$attachment = $mastodon->post('/media', [
'file' => $image
'file' => file_get_contents('./'.basename($image))
]);
var_dump($attachment);
unlink('./'.basename($image));
$mdescription .= $attachment->url;
}*/
$mastodon->status_post($mdescription);

2
config.yml.example

@ -1,8 +1,6 @@
DRY_RUN: true
TELEGRAM: true
MASTODON: true
MASTODON_CLIENT_ID: some-id
MASTODON_SECRET: oauth_secret
MASTODON_ACCESS_TOKEN: token
MASTODON_SERVER: https://botsin.space
MASTODON_USER: user

Loading…
Cancel
Save