🎉 Hello world

This commit is contained in:
Clément 2021-02-26 13:17:32 +01:00
commit bcb51718d5
8 changed files with 1768 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
/config.php
/.idea
/vendor/

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "webcollage"]
path = webcollage
url = ssh://gogs@git.shikiryu.com:2200/Shikiryu/WebCollage.git

39
bot.php Normal file
View File

@ -0,0 +1,39 @@
<?php
use Abraham\TwitterOAuth\TwitterOAuth;
use Abraham\TwitterOAuth\TwitterOAuthException;
use Shikiryu\WebGobbler\Assembler\Superpose;
use Shikiryu\WebGobbler\Config;
use Shikiryu\WebGobbler\Pool;
include 'vendor/autoload.php';
$twitter_config = require 'config.php';
try {
// generate picture
$config = new Config('./config.json');
$pool = new Pool($config);
$upload_image_name = uniqid('superpose_', true);
$image = new Superpose($pool, $config);
$image->saveTo(sprintf('./render/%s.jpg', $upload_image_name));
// send picture to twitter
$connection = new TwitterOAuth(
$twitter_config['api_key'],
$twitter_config['api_secret'],
$twitter_config['access_token'],
$twitter_config['access_secret']
);
$connection->setTimeouts(5, 60000);
$collage = $connection->upload('media/upload', ['media' => realpath(sprintf('./render/%s.jpg', $upload_image_name))]);
$parameters = [
'status' => 'Nouveau collage',
'media_ids' => $collage->media_id_string,
];
$result = $connection->post('statuses/update', $parameters);
} catch (TwitterOAuthException | Exception $exception) {
echo $exception->getMessage();
}

25
composer.json Normal file
View File

@ -0,0 +1,25 @@
{
"name": "shikiryu/twitter-webcollage",
"description": "Bot with collage",
"minimum-stability": "stable",
"license": "proprietary",
"authors": [
{
"name": "Clément",
"email": "projets@shiki.fr"
}
],
"autoload": {
"psr-4": {
"Shikiryu\\WebGobbler\\": "webcollage/src"
}
},
"require": {
"ext-json": "*",
"ext-imagick": "*",
"ext-curl": "*",
"abraham/twitteroauth": "^2.0",
"fabpot/goutte": "^4.0",
"samwilson/phpflickr": "^4.14"
}
}

1656
composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

33
config.json Normal file
View File

@ -0,0 +1,33 @@
{
"collectors": [],
"pool": {
"directory": "/var/www/html/dev/twitter-webcollage/pool",
"nb_images": 45,
"pre_download": true
},
"collector": {
"keywords": {
},
"flickr": {
"key": "bdc091a2ceb8de8cfd4e3569e62d12d9",
"secret": "090a6b2af3213a2e"
},
"imgur": {
"client_id": "63142265e5c35f7"
}
},
"assembler": {
"superpose": {
"randomrotation": true,
"min_num_images": 32,
"scale": 0.8
},
"sizex": 1920,
"sizey": 1080,
"mirror": false,
"emboss": true,
"invert": false,
"nbx": 5,
"nby": 5
}
}

8
config.php.template Normal file
View File

@ -0,0 +1,8 @@
<?php
return [
'api_key' => '',
'api_secret' => '',
'access_token' => '',
'access_secret' => '',
];

1
webcollage Submodule

@ -0,0 +1 @@
Subproject commit cd452fe0d1d709730b46114aedb49e4e2476f34e