grammY icon indicating copy to clipboard operation
grammY copied to clipboard

feat: add ctx.entities

Open roziscoding opened this issue 3 years ago • 10 comments

As discussed in https://grammyjs.t.me/64539

roziscoding avatar Sep 05 '22 23:09 roziscoding

Codecov Report

Base: 36.98% // Head: 37.21% // Increases project coverage by +0.23% :tada:

Coverage data is based on head (bb96b19) compared to base (6c20883). Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #276      +/-   ##
==========================================
+ Coverage   36.98%   37.21%   +0.23%     
==========================================
  Files          17       17              
  Lines        4367     4383      +16     
  Branches      159      166       +7     
==========================================
+ Hits         1615     1631      +16     
  Misses       2750     2750              
  Partials        2        2              
Impacted Files Coverage Δ
src/context.ts 23.81% <100.00%> (+0.99%) :arrow_up:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

codecov-commenter avatar Sep 05 '22 23:09 codecov-commenter

Docs PR: https://github.com/grammyjs/website/pull/497

roziscoding avatar Sep 05 '22 23:09 roziscoding

Should we support caption entities as well?

Loskir avatar Sep 05 '22 23:09 Loskir

Should we support caption entities as well?

I think so. Would this ~work~ be enough?

const text = message.text || message.caption;
const entities = message.entities || message.caption_entities;

roziscoding avatar Sep 05 '22 23:09 roziscoding

It should

Loskir avatar Sep 06 '22 07:09 Loskir

@roziscoding replace the || with ??.

rojvv avatar Sep 06 '22 09:09 rojvv

@Loskir @roj1512 done :)

roziscoding avatar Sep 06 '22 10:09 roziscoding

Do we also want to support Context.has.entity as well as ctx.hasEntity in order to filter for specific entities, not just entity types they way ctx.has("::hashtag") does? If so, this may be added either here or in a second PQ, whatever works best.

KnorpelSenf avatar Oct 10 '22 13:10 KnorpelSenf

Do we also want to support Context.has.entity as well as ctx.hasEntity in order to filter for specific entities, not just entity types they way ctx.has("::hashtag") does? If so, this may be added either here or in a second PQ, whatever works best.

@KnorpelSenf I don't know if I get it. Could you provide a sample of the use-case?

roziscoding avatar Oct 18 '22 18:10 roziscoding

Do we also want to support Context.has.entity as well as ctx.hasEntity in order to filter for specific entities, not just entity types they way ctx.has("::hashtag") does? If so, this may be added either here or in a second PQ, whatever works best.

@KnorpelSenf I don't know if I get it. Could you provide a sample of the use-case?

Something like ctx.hasEntity("hashtag", "grammy") perhaps? I myself am not sure if that's desirable, though …

KnorpelSenf avatar Oct 18 '22 21:10 KnorpelSenf

I myself am not sure if that's desirable, though

To be honest, I think this fits better into a plugin, seems a little out of scope for core. But if you think it makes sense to have on core, I can add that

roziscoding avatar Oct 21 '22 15:10 roziscoding

Alright, then let's not add it to the core. I feel like it's a rare use case anyway, and it's also not much harder to implement manually by combining this PQ with bot.filter.

KnorpelSenf avatar Oct 22 '22 12:10 KnorpelSenf