Skip to content

Commit 2d01f16

Browse files
committed
More detailed .env.example file, use env variable for logs directory, rename webhook secrets envs.
1 parent c8bd5f4 commit 2d01f16

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

.env.example

+17-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
TG_ENV='development"
1+
# Environment
2+
TG_ENV='development'
3+
4+
# Directories
5+
TG_BASE_DIR='/var/www/tg-support-bot'
6+
TG_CACHE_DIR='${TG_BASE_DIR}/cache'
7+
TG_COMMANDS_DIR='${TG_BASE_DIR}/commands'
8+
TG_LOGS_DIR='${TG_BASE_DIR}/logs'
9+
TG_PUBLIC_DIR='${TG_BASE_DIR}/public'
10+
TG_DOWNLOADS_DIR='${TG_BASE_DIR}/downloads'
11+
TG_UPLOADS_DIR='${TG_BASE_DIR}/uploads'
212

313
# Bot vitals
414
TG_API_KEY='12345:api_key'
@@ -8,6 +18,7 @@ TG_SECRET='super-secret'
818
# Bot extras
919
TG_WEBHOOK='{"url": "https://bot.com/manager.php"}'
1020
TG_ADMINS='[123,456]'
21+
TG_LOGGING='{"error": "${TG_LOGS_DIR}/error.log", "update": "${TG_LOGS_DIR}/update.log"}'
1122

1223
# Database
1324
TG_DB_HOST='localhost'
@@ -16,4 +27,8 @@ TG_DB_PASSWORD='root'
1627
TG_DB_DATABASE='tgbot'
1728

1829
# Paths
19-
TG_PATHS='{"download": "/var/www/tgbot/downloads","upload": "/var/www/tgbot/uploads"}'
30+
TG_COMMANDS='{"paths": ["${TG_COMMANDS_DIR}"]}'
31+
TG_PATHS='{"download": "${TG_DOWNLOADS_DIR}", "upload": "${TG_UPLOADS_DIR}"}'
32+
33+
# Webhook secrets
34+
TG_WEBHOOK_SECRET_GITHUB='github-secret'

public/webhooks/github.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
require_once __DIR__ . '/../../vendor/autoload.php';
1717
Dotenv\Dotenv::create(__DIR__ . '/../..')->load();
1818

19-
$webhook = new GitHubHandler(getenv('SB_WEBHOOK_SECRET_GITHUB'));
19+
$webhook = new GitHubHandler(getenv('TG_WEBHOOK_SECRET_GITHUB'));
2020
if (!$webhook->validate()) {
2121
http_response_code(404);
2222
die;
2323
}
2424

2525
// Save all incoming data to a log file for future reference.
26-
Utils::logWebhookData(__DIR__ . '/../../logs/' . getenv('SB_BOT_USERNAME') . '_webhook_github.log');
26+
Utils::logWebhookData(getenv('TG_LOGS_DIR') . '/' . getenv('TG_BOT_USERNAME') . '_webhook_github.log');

public/webhooks/travis-ci.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@
2323
}
2424

2525
// Save all incoming data to a log file for future reference.
26-
Utils::logWebhookData(__DIR__ . '/../../logs/' . getenv('SB_BOT_USERNAME') . '_webhook_travis-ci.log');
26+
Utils::logWebhookData(getenv('TG_LOGS_DIR') . '/' . getenv('TG_BOT_USERNAME') . '_webhook_travis-ci.log');

0 commit comments

Comments
 (0)