mirror of
https://gitlab.com/ifiction/ifhub-telegram.git
synced 2024-10-22 22:15:31 +00:00
Options, images WIP
This commit is contained in:
parent
6337d56424
commit
dc92a90150
2 changed files with 16 additions and 3 deletions
17
bot.php
17
bot.php
|
@ -35,6 +35,19 @@ function ellipse($str,$n_chars,$crop_str=' [...]')
|
||||||
return $buff;
|
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/');
|
$string = get_text('https://ifhub.club/rss/new/');
|
||||||
$service = new \Sabre\Xml\Service();
|
$service = new \Sabre\Xml\Service();
|
||||||
$service->elementMap = [
|
$service->elementMap = [
|
||||||
|
@ -98,10 +111,12 @@ foreach ($articles as $article) {
|
||||||
$mdescription .= ": $link";
|
$mdescription .= ": $link";
|
||||||
/*
|
/*
|
||||||
if ($image) {
|
if ($image) {
|
||||||
|
download('https://ifhub.club'.$image, './'.basename($image));
|
||||||
$attachment = $mastodon->post('/media', [
|
$attachment = $mastodon->post('/media', [
|
||||||
'file' => $image
|
'file' => file_get_contents('./'.basename($image))
|
||||||
]);
|
]);
|
||||||
var_dump($attachment);
|
var_dump($attachment);
|
||||||
|
unlink('./'.basename($image));
|
||||||
$mdescription .= $attachment->url;
|
$mdescription .= $attachment->url;
|
||||||
}*/
|
}*/
|
||||||
$mastodon->status_post($mdescription);
|
$mastodon->status_post($mdescription);
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
DRY_RUN: true
|
DRY_RUN: true
|
||||||
TELEGRAM: true
|
TELEGRAM: true
|
||||||
MASTODON: true
|
MASTODON: true
|
||||||
MASTODON_CLIENT_ID: some-id
|
|
||||||
MASTODON_SECRET: oauth_secret
|
|
||||||
MASTODON_ACCESS_TOKEN: token
|
MASTODON_ACCESS_TOKEN: token
|
||||||
MASTODON_SERVER: https://botsin.space
|
MASTODON_SERVER: https://botsin.space
|
||||||
MASTODON_USER: user
|
MASTODON_USER: user
|
||||||
|
|
Loading…
Reference in a new issue