mirror of
https://gitlab.com/ifiction/ifhub-telegram.git
synced 2024-10-22 22:15:31 +00:00
This commit is contained in:
parent
065d07675e
commit
63bef85ff9
3 changed files with 185 additions and 971 deletions
16
bot.php
16
bot.php
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
require_once ("vendor/autoload.php");
|
require_once ("vendor/autoload.php");
|
||||||
|
|
||||||
|
use Colorfield\Mastodon\MastodonAPI;
|
||||||
use Symfony\Component\Yaml\Yaml;
|
use Symfony\Component\Yaml\Yaml;
|
||||||
use Revolution\Mastodon\MastodonClient;
|
|
||||||
use GuzzleHttp\Client;
|
|
||||||
|
|
||||||
$config = Yaml::parse(file_get_contents('config.yml'));
|
$config = Yaml::parse(file_get_contents('config.yml'));
|
||||||
$seen = [];
|
$seen = [];
|
||||||
|
@ -88,9 +88,11 @@ $telegram = new Longman\TelegramBot\Telegram(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
try {
|
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) {
|
} catch (\Exception $e) {
|
||||||
echo 'WARNING: could not start MastodonClient';
|
echo 'WARNING: could not start Mastodon client';
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($articles as $article) {
|
foreach ($articles as $article) {
|
||||||
|
@ -135,7 +137,6 @@ foreach ($articles as $article) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($config['MASTODON'] === true && isset($mastodon)) {
|
if ($config['MASTODON'] === true && isset($mastodon)) {
|
||||||
$mastodon->domain($config['MASTODON_SERVER'])->token($config['MASTODON_ACCESS_TOKEN']);
|
|
||||||
/*
|
/*
|
||||||
if ($image) {
|
if ($image) {
|
||||||
download('https://ifhub.club'.$image, './'.basename($image));
|
download('https://ifhub.club'.$image, './'.basename($image));
|
||||||
|
@ -146,8 +147,9 @@ foreach ($articles as $article) {
|
||||||
unlink('./'.basename($image));
|
unlink('./'.basename($image));
|
||||||
$mdescription .= $attachment->url;
|
$mdescription .= $attachment->url;
|
||||||
}*/
|
}*/
|
||||||
$mastodon->createStatus($description, [
|
$mastodon->post('statuses', [
|
||||||
'language' => 'ru'
|
'content' => $description,
|
||||||
|
'language' => 'ru',
|
||||||
]);
|
]);
|
||||||
$seen[] = $article['link'];
|
$seen[] = $article['link'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"sabre/xml": "^4.0",
|
"sabre/xml": "^4.0",
|
||||||
"ryakad/pandoc-php": "^1.0",
|
"ryakad/pandoc-php": "^1.0",
|
||||||
"symfony/yaml": "^7.1",
|
"symfony/yaml": "^7.1",
|
||||||
"revolution/laravel-mastodon-api": "^2.4"
|
"colorfield/mastodon-api": "^0.1.5"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"allow-plugins": {
|
"allow-plugins": {
|
||||||
|
|
1138
composer.lock
generated
1138
composer.lock
generated
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue