Skip to content

Commit 8236b89

Browse files
committed
clean and format code v2
1 parent f330981 commit 8236b89

File tree

4 files changed

+25
-25
lines changed

4 files changed

+25
-25
lines changed

.env.example

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ APP_NAME='Telegram Github Notify Bot'
22

33
# Set your app url here
44
APP_URL=https://152.132.127.172:3000
5+
APP_HOST=localhost
6+
APP_PORT=3000
57

68
TELEGRAM_BOT_TOKEN=###########:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
79
TELEGRAM_BOT_CHAT_ID=##########
8-
TELEGRAM_BOT_GR_CHAT_IDS=
910

10-
TIMEZONE=Asia/Ho_Chi_Minh
11+
# Set your telegram group chat ids here ( please use comma to separate )
12+
TELEGRAM_GROUP_CHAT_IDS="-############,-############"
1113

12-
APP_HOST=localhost
13-
APP_PORT=3000
14+
TIMEZONE=Asia/Ho_Chi_Minh

config/tg-notifier.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
'telegram-bot' => [
1111
'token' => $_ENV['TELEGRAM_BOT_TOKEN'] ?? '',
1212
'chat_id' => $_ENV['TELEGRAM_BOT_CHAT_ID'] ?? '',
13-
'gr_chat_ids' => explode(',', $_ENV['TELEGRAM_BOT_GR_CHAT_IDS'] ?? ''),
13+
'gr_chat_ids' => explode(',', $_ENV['TELEGRAM_GROUP_CHAT_IDS'] ?? ''),
1414

1515
'set_webhook_url' => $_ENV['SET_WEBHOOK_URL'] ?? $_ENV['APP_URL'] . '/setWebhook',
1616
],

src/Http/Actions/SendNotifyAction.php

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ public function __construct()
2424
$this->notificationService = new NotificationService();
2525

2626
$this->chatIds = config('telegram-bot.gr_chat_ids');
27-
$this->chatIds[] = $this->telegramService->chatId;
2827
}
2928

3029
/**
@@ -35,8 +34,8 @@ public function __construct()
3534
*/
3635
public function handle(): void
3736
{
38-
$this->checkCallback();
39-
$chatMessageId = $this->telegramService->messageData['message']['chat']['id'] ?? null;
37+
$this->telegramService->checkCallback();
38+
$chatMessageId = $this->telegramService->messageData['message']['chat']['id'] ?? '';
4039

4140
// Send a result to only the bot owner
4241
if (!empty($chatMessageId) && $chatMessageId == $this->telegramService->chatId) {
@@ -56,21 +55,4 @@ public function handle(): void
5655
// Notify access denied to other chat ids
5756
$this->notificationService->accessDenied($this->telegramService);
5857
}
59-
60-
/**
61-
* Check callback from a telegram
62-
*
63-
* @return bool
64-
*/
65-
public function checkCallback(): bool
66-
{
67-
if (!is_null($this->telegramService->telegram->Callback_ChatID())) {
68-
$callback = $this->telegramService->telegram->Callback_Data();
69-
$this->telegramService->sendCallbackResponse($callback);
70-
71-
return true;
72-
}
73-
74-
return false;
75-
}
7658
}

src/Services/TelegramService.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,21 @@ public function sendCallbackResponse(string $callback = null): void
161161
$this->telegram->answerCallbackQuery($content);
162162
}
163163
}
164+
165+
/**
166+
* Check callback from a telegram
167+
*
168+
* @return bool
169+
*/
170+
public function checkCallback(): bool
171+
{
172+
if (!is_null($this->telegram->Callback_ChatID())) {
173+
$callback = $this->telegram->Callback_Data();
174+
$this->sendCallbackResponse($callback);
175+
176+
return true;
177+
}
178+
179+
return false;
180+
}
164181
}

0 commit comments

Comments
 (0)