Skip to content

Commit 19c09e5

Browse files
authored
Merge pull request #34 from noplanman/26-single_fail_log
Only make a single log entry for a failed welcome message deletion.
2 parents 730ec25 + 560a5fa commit 19c09e5

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
66
## [Unreleased]
77
### Added
88
### Changed
9+
- Only log a single welcome message deletion failure.
910
### Deprecated
1011
### Removed
1112
### Fixed

src/Helpers.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,18 @@ public static function deleteOldWelcomeMessages(): void
7272
}
7373

7474
$deletion = Request::deleteMessage(compact('chat_id', 'message_id'));
75-
if ($deletion->isOk()) {
76-
unset($welcome_message_ids[$key]);
77-
continue;
75+
if (!$deletion->isOk()) {
76+
// Let's just save the error for now if it fails, to see if we can fix this better.
77+
TelegramLog::error(sprintf(
78+
'Chat ID: %s, Message ID: %s, Error Code: %s, Error Message: %s',
79+
$chat_id,
80+
$message_id,
81+
$deletion->getErrorCode(),
82+
$deletion->getDescription()
83+
));
7884
}
7985

80-
// Let's just save the error for now if it fails, to see if we can fix this better.
81-
TelegramLog::error(sprintf(
82-
'Message ID: %s, Error Code: %s, Error Message: %s',
83-
$message_id,
84-
$deletion->getErrorCode(),
85-
$deletion->getDescription()
86-
));
86+
unset($welcome_message_ids[$key]);
8787
}
8888

8989
self::setSimpleOption('welcome_message_ids', $welcome_message_ids);

0 commit comments

Comments
 (0)