forked from hexium310/ask-java_shit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.php
38 lines (30 loc) · 1.01 KB
/
main.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
require __DIR__ . '/vendor/autoload.php';
use Dotenv\Dotenv;
use Gettext\Translations;
use Gettext\Translator;
use mpyw\Cowitter\Client;
$locale = getenv('LANGUAGE') ?: getenv('LC_ALL') ?: getenv('LC_MESSAGES') ?: getenv('LANG');
$locale = file_exists(__DIR__ . "/locale/{$locale}/LC_MESSAGES/messages.po") ? $locale : 'en_US';
$translator = new Translator();
$translator->loadTranslations(Translations::fromPoFile(__DIR__ . "/locale/{$locale}/LC_MESSAGES/messages.po"))->register();
$dotenv = new Dotenv(__DIR__);
$dotenv->load();
$client = new Client([
getenv('CONSUMER_KEY'),
getenv('CONSUMER_SECRET'),
getenv('ACCESS_TOKEN'),
getenv('ACCESS_TOKEN_SECRET'),
]);
$words = implode(' ', array_slice($argv, 1));
if (empty($words)) {
die("The application has crashed.\n");
}
try {
$target = getenv('JAVASHIT_ACCOUNT');
$client->post('statuses/update', [
'status' => __('Teach me this English', $target, $words),
]);
} catch (\RuntimeException $e) {
error_log($e->getMessage());
}