Skip to content

Commit

Permalink
refactor TelegramChannel (#136)
Browse files Browse the repository at this point in the history
Co-authored-by: faissaloux <faissaloux@users.noreply.github.com>
  • Loading branch information
faissaloux and faissaloux authored Nov 25, 2021
1 parent cafff94 commit 194ce8e
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/TelegramChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public function send($notifiable, Notification $notification): ?array

$params = $message->toArray();

$sendMethod = str_replace('Telegram', 'send', array_reverse(explode('\\', get_class($message)))[0]);

try {
if ($message instanceof TelegramMessage) {
if ($message->shouldChunk()) {
Expand Down Expand Up @@ -99,14 +101,10 @@ public function send($notifiable, Notification $notification): ?array
}

$response = $this->telegram->sendMessage($params);
} elseif ($message instanceof TelegramLocation) {
$response = $this->telegram->sendLocation($params);
} elseif ($message instanceof TelegramFile) {
$response = $this->telegram->sendFile($params, $message->type, $message->hasFile());
} elseif ($message instanceof TelegramPoll) {
$response = $this->telegram->sendPoll($params);
} elseif ($message instanceof TelegramAudio) {
$response = $this->telegram->sendAudio($params);
} elseif (method_exists($this->telegram, $sendMethod)) {
$response = $this->telegram->{$sendMethod}($params);
} else {
return null;
}
Expand Down

0 comments on commit 194ce8e

Please # to comment.