Skip to content
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

feat(body): add entities formatting support #250

Merged
merged 9 commits into from
Oct 16, 2024

Conversation

BubuMVX
Copy link
Contributor

@BubuMVX BubuMVX commented Oct 13, 2024

Hi !

This pull request adds the support to entities on text messages sent.
This allows:

  • messages to be formatted with this Telegram method, instead of Markdown or HTML,
  • the usage of FormattedString objects created with grammyjs/parse-mode.

Example

import { bold, fmt, underline } from '@grammyjs/parse-mode';
import { MenuTemplate } from 'grammy-inline-menu';

const menu = new MenuTemplate<MyContext>(async () => {
    const message = fmt`${bold(underline('Hello world!'))}`

    return {
        text: message.text,
        entities: message.entities,
    };
});

@BubuMVX
Copy link
Contributor Author

BubuMVX commented Oct 14, 2024

Hi @EdJoPaTo !

Sorry, but I struggle to fix this @typescript-eslint/prefer-readonly-parameter-types error.
I tried Readonly<>, ReadonlyArray<> and stuff like that, without success.

Can you help me or point me in the right direction?
Thanks.

Copy link
Owner

@EdJoPaTo EdJoPaTo left a comment

Choose a reason for hiding this comment

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

I like the simplicity of the change!

I'm not sure about the readonly part (see comment on the TextBody) but otherwise I like the addition.

(Side note: I will squash the PR into a single commit later on so adding commits to the PR is easier to review than having force pushes which need to be diffed, loosing a bit of the reasoning of the changes while the PR is ongoing)

source/body.ts Show resolved Hide resolved
Copy link
Owner

@EdJoPaTo EdJoPaTo left a comment

Choose a reason for hiding this comment

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

Can you add a simple test case where some input entity ends up in the sendMessage / sendPhoto method argument just making sure its passed through correctly?

Otherwise its good to merge!

@BubuMVX
Copy link
Contributor Author

BubuMVX commented Oct 14, 2024

Tests added, I hope they're in line with your standards.

Copy link
Owner

@EdJoPaTo EdJoPaTo left a comment

Choose a reason for hiding this comment

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

I like the added FAQ entry. A few nitpicks but I already like the current state of the PR!

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
@BubuMVX
Copy link
Contributor Author

BubuMVX commented Oct 15, 2024

Thanks a lot for your feedback, I updated the documentation

Copy link
Owner

@EdJoPaTo EdJoPaTo left a comment

Choose a reason for hiding this comment

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

Wanted to hit the approve and merge, but I have more nitpicks… Sorry for that! 😇

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@BubuMVX
Copy link
Contributor Author

BubuMVX commented Oct 16, 2024

Wanted to hit the approve and merge, but I have more nitpicks… Sorry for that! 😇

Hahaha! Don't hesitate!
Corrections added

Copy link
Owner

@EdJoPaTo EdJoPaTo left a comment

Choose a reason for hiding this comment

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

I'll merge and release later when I have more time, so I don't introduce mistakes from trying to get it done in a hurry.

@EdJoPaTo EdJoPaTo changed the title Add entities formatting support in messages sent feat(body): add entities formatting support Oct 16, 2024
@EdJoPaTo EdJoPaTo merged commit 7a7e88b into EdJoPaTo:main Oct 16, 2024
1 check passed
@EdJoPaTo
Copy link
Owner

EdJoPaTo commented Oct 16, 2024

Thank you for the addition!

It's released as 9.1.0

@BubuMVX BubuMVX deleted the feat/entities-support branch October 16, 2024 17:27
@BubuMVX
Copy link
Contributor Author

BubuMVX commented Oct 16, 2024

Nice!
Thank you so much for your library.
It's one of the best for Telegram bots I've encountered so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants