-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathSettings.php
69 lines (60 loc) · 2.41 KB
/
Settings.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
namespace LINE2Discord;
require_once 'ReadOnlyTrait.php';
require_once 'Reader.php';
use LINE2Discord\ReadOnlyTrait as ReadOnlyTrait;
use LINE2Discord\Reader as Reader;
class Settings
{
use ReadOnlyTrait;
use Reader;
private $configure = "configure.json";
private $serviceURI;
private $uploadURI;
private $uploadLocation;
private $defaultUserName;
private $token;
private $secret;
private $groupId;
private $userNameURL = "https://api.line.me/v2/bot/group/{roomId}/member/{userId}";
private $downloadURL = "https://api.line.me/v2/bot/message/{messageID}/content";
private $stickerURL = "https://stickershop.line-scdn.net/stickershop/v1/sticker/{stickerID}/ANDROID/sticker.png";
private $discordUrl;
private $botName;
private $botThumbnail;
private $maxFileSize;
/**
* __construct
*
* @return void
*/
public function __construct()
{
// configureの読み込み
$this->loadConfigure();
}
/**
* configureファイルから設定を読み出します
*
* @return void
*/
private function loadConfigure()
{
// configure.jsonを読み込む
$json = $this->readFileAsJson($this->configure);
// URLの正しい解釈のためにsetlocaleを行う
\setlocale(LC_ALL, $json["system"]["locale"]);
$this->serviceURI = (empty($_SERVER['HTTPS']) ? "http://" : "https://") . $_SERVER['SERVER_NAME'] . \pathinfo($_SERVER['REQUEST_URI'])['dirname'] . DIRECTORY_SEPARATOR;
$this->uploadURI = $this->serviceURI . $json["system"]["uploadLocation"] . DIRECTORY_SEPARATOR;
$this->uploadLocation = __DIR__ . $json["system"]["uploadLocation"] . DIRECTORY_SEPARATOR;
$this->defaultUserName = $json["system"]["defaultUserName"];
$this->token = $json["line"]["token"];
$this->secret = $json["line"]["secret"];
$this->groupId = $json["line"]["groupId"];
$this->discordUrl = $json["discord"]["hookUrl"];
$this->botName = $json["discord"]["botName"];
$this->botThumbnail = $json["discord"]["botThumbnail"];
$this->maxFileSize = intval($json["discord"]["maxFileSize"]);
}
}
?>