try to use a different API wrapper
Some checks failed
/ test (push) Has been cancelled

This commit is contained in:
Aleksandr Yakovlev 2024-10-20 11:54:24 +06:00
parent 065d07675e
commit 63bef85ff9
No known key found for this signature in database
GPG key ID: 8269E24B4008E32A
3 changed files with 185 additions and 971 deletions

16
bot.php
View file

@ -1,8 +1,8 @@
<?php
require_once ("vendor/autoload.php");
use Colorfield\Mastodon\MastodonAPI;
use Symfony\Component\Yaml\Yaml;
use Revolution\Mastodon\MastodonClient;
use GuzzleHttp\Client;
$config = Yaml::parse(file_get_contents('config.yml'));
$seen = [];
@ -88,9 +88,11 @@ $telegram = new Longman\TelegramBot\Telegram(
};
}
try {
$mastodon = new MastodonClient(new Client);
$oAuth = new Colorfield\Mastodon\MastodonOAuth('IFHub.club', $config['MASTODON_SERVER']);
$oAuth->config->setAuthorizationCode($config['MASTODON_ACCESS_TOKEN']);
$mastodon = new Colorfield\Mastodon\MastodonAPI($oAuth->config);
} catch (\Exception $e) {
echo 'WARNING: could not start MastodonClient';
echo 'WARNING: could not start Mastodon client';
}
foreach ($articles as $article) {
@ -135,7 +137,6 @@ foreach ($articles as $article) {
}
}
if ($config['MASTODON'] === true && isset($mastodon)) {
$mastodon->domain($config['MASTODON_SERVER'])->token($config['MASTODON_ACCESS_TOKEN']);
/*
if ($image) {
download('https://ifhub.club'.$image, './'.basename($image));
@ -146,8 +147,9 @@ foreach ($articles as $article) {
unlink('./'.basename($image));
$mdescription .= $attachment->url;
}*/
$mastodon->createStatus($description, [
'language' => 'ru'
$mastodon->post('statuses', [
'content' => $description,
'language' => 'ru',
]);
$seen[] = $article['link'];
}

View file

@ -4,7 +4,7 @@
"sabre/xml": "^4.0",
"ryakad/pandoc-php": "^1.0",
"symfony/yaml": "^7.1",
"revolution/laravel-mastodon-api": "^2.4"
"colorfield/mastodon-api": "^0.1.5"
},
"config": {
"allow-plugins": {

1138
composer.lock generated

File diff suppressed because it is too large Load diff