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
Formatting helpers #1690
Formatting helpers #1690
Conversation
3284fe6
to
80494b7
Compare
fd2cc1f
to
a3c8dc6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks ok.
So effectively you're slowly integrating the most useful plugins into the core lib? That sounds like a better strategy than hoping for permission to publish packages under |
@KnorpelSenf I have access to npm I started this PR thinking of format being a tiny function in The benefit of in-core here is that user doesn't have to mess with Context/API types or implementation - even external plugins (like a future |
Signed-off-by: Muthu Kumar <muthukumar@thefeathers.in>
Signed-off-by: Muthu Kumar <muthukumar@thefeathers.in>
Signed-off-by: Muthu Kumar <muthukumar@thefeathers.in>
Signed-off-by: Muthu Kumar <muthukumar@thefeathers.in>
Use sendChatAction instead Signed-off-by: Muthu Kumar <muthukumar@thefeathers.in>
Signed-off-by: Muthu Kumar <muthukumar@thefeathers.in>
Signed-off-by: Muthu Kumar <muthukumar@thefeathers.in>
Signed-off-by: Muthu Kumar <muthukumar@thefeathers.in>
Signed-off-by: Muthu Kumar <muthukumar@thefeathers.in>
Signed-off-by: Muthu Kumar <muthukumar@thefeathers.in>
Signed-off-by: Muthu Kumar <muthukumar@thefeathers.in>
e39398a
to
e033a03
Compare
Unless necessary - when FmtString entities are present
e033a03
to
05cb922
Compare
Interesting idea, but what about localization? Many bots use it. I think the use of such solutions complicates the localization and translating of the text, even if i18n was not used now, may be needed in the future. About escaping - telegram-escape |
@Viiprogrammer That's a very good point - at the moment I don't think there's any way to reconcile fmt and i18n.
Any solution in this regard will need to be rewritten when i18n is needed - so not many ways to be prematurely prepared for it. I think the two needs are orthographic. |
Ref: related conversation
Formatting is often troublesome, especially if you have many characters that need escaping. Escaping is messy, and it is much cleaner to create entities instead, but there were no utils to help with this in Telegraf so far. This PR adds support for
telegraf/format
. To be used like this:This also just works with captions!
For the future:
emoji()
may be a nice addition to formatting; however emojibase is quite large and would not be a suitable dependency for telegraf. Creating a separate@telegraf/format-emoji
package could work.