Skip to content

[Notifier] Add support for editing Telegram messages #47956

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 23, 2022
Merged

[Notifier] Add support for editing Telegram messages #47956

merged 1 commit into from
Oct 23, 2022

Conversation

chr-hertel
Copy link
Contributor

Q A
Branch? 6.2
Bug fix? no
New feature? yes
Deprecations? no
License MIT

Telegram supports updating messages which is quite a use case while working with buttons to create an interactive inline interface.

See https://core.telegram.org/bots/api#editmessagetext

@@ -98,7 +100,7 @@ protected function doSend(MessageInterface $message): SentMessage
if (200 !== $statusCode) {
$result = $response->toArray(false);

throw new TransportException('Unable to post the Telegram message: '.$result['description'].sprintf(' (code %s).', $result['error_code']), $response);
throw new TransportException('Unable to post the Telegram message: '.$result['description'].sprintf(' (code "%s").', $result['error_code']), $response);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use post and edit accordingly?

@@ -98,7 +100,7 @@ protected function doSend(MessageInterface $message): SentMessage
if (200 !== $statusCode) {
$result = $response->toArray(false);

throw new TransportException('Unable to post the Telegram message: '.$result['description'].sprintf(' (code %s).', $result['error_code']), $response);
throw new TransportException('Unable to post the Telegram message: '.$result['description'].sprintf(' (code "%s").', $result['error_code']), $response);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw new TransportException('Unable to post the Telegram message: '.$result['description'].sprintf(' (code "%s").', $result['error_code']), $response);
throw new TransportException('Unable to post the Telegram message: '.$result['description'].sprintf(' (code %d).', $result['error_code']), $response);

@@ -98,7 +100,8 @@ protected function doSend(MessageInterface $message): SentMessage
if (200 !== $statusCode) {
$result = $response->toArray(false);

throw new TransportException('Unable to post the Telegram message: '.$result['description'].sprintf(' (code %s).', $result['error_code']), $response);
$verb = isset($options['message_id']) ? 'edit' : 'post';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove this temp var.

@fabpot
Copy link
Member

fabpot commented Oct 23, 2022

Thank you @chr-hertel.

@chr-hertel
Copy link
Contributor Author

Really fast, thanks a lot! :)

@chr-hertel chr-hertel deleted the telegram-notifier-edit-message branch October 23, 2022 10:31
@OskarStark
Copy link
Contributor

As always 🤷🏼‍♂️ 😁

@fabpot fabpot mentioned this pull request Oct 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants