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;
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
|
@ -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…
Reference in a new issue