feat: add ctx.entities
As discussed in https://grammyjs.t.me/64539
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.
Docs PR: https://github.com/grammyjs/website/pull/497
Should we support caption entities as well?
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;
It should
@roziscoding replace the || with ??.
@Loskir @roj1512 done :)
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.
Do we also want to support
Context.has.entityas well asctx.hasEntityin order to filter for specific entities, not just entity types they wayctx.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?
Do we also want to support
Context.has.entityas well asctx.hasEntityin order to filter for specific entities, not just entity types they wayctx.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 …
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
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.