Skip to content

Conversation

@SpEcHiDe
Copy link
Contributor

@SpEcHiDe SpEcHiDe commented Apr 8, 2025

Based on the message_thread

Please let me know if this is expected approach.

SpEcHiDe added 2 commits April 8, 2025 16:04
i am not sure if this is as easy as this..
@SpEcHiDe SpEcHiDe marked this pull request as draft April 8, 2025 10:53
@KnorpelSenf
Copy link
Member

Nice, did you test this locally? Does it work as expected?

@SpEcHiDe
Copy link
Contributor Author

SpEcHiDe commented Apr 8, 2025

steps i did to test locally:

git clone https://github.com/spechide/grammY
git checkout patch-1
npm install
npm run backport
deno task bundle-web

screenshot

I was not able to test the link_preview_options:is_disabled scenario. Apart from that I was not able to find any issues in the above code.

but by testing below code, I found one issue,

const privateComposer = composer.chatType("private");

privateComposer.on("::url", async ctx => {
    console.log(ctx.update);
    
    const urls = ctx.entities(["url"]);
    console.log(urls);  // 
});

by testing with the below message.

screenshot

The ctx.entities would not be able to obtain the url yet. Should it be able to do it, or not? 🤔

Can you let me know what are the expectations?

@KnorpelSenf
Copy link
Member

The filter query ::url and ctx.entities both operate on the message entities. They are not related to the link preview in any way, so it is correct that they do not appear there.

Copy link
Member

@KnorpelSenf KnorpelSenf left a comment

Choose a reason for hiding this comment

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

LGTM.

What needs to be done to move this out of draft state and get this ready to be merged?

@KnorpelSenf KnorpelSenf changed the title attempt to add link_preview_options feat: add filter query for link_preview_options Apr 16, 2025
@SpEcHiDe
Copy link
Contributor Author

SpEcHiDe commented Apr 16, 2025

The filter query ::url and ctx.entities both operate on the message entities. They are not related to the link preview in any way, so it is correct that they do not appear there.

Ok,

What about the ::is_disabled thing? Apparently, if is_disabled is used to sendMessage then the Message object does not contain link_preview_options key. OR, maybe i am not able to test correctly.

@KnorpelSenf
Copy link
Member

That's a great catch. I think it makes no sense to filter for is_disabled actually. It is already possible to filter for

bot.on("::url").drop(Context.has.filterQuery(":link_preview_options"))

which effectively only gives you messages URL entities but without link preview.

Co-authored-by: KnorpelSenf <[email protected]>
@SpEcHiDe SpEcHiDe marked this pull request as ready for review April 16, 2025 09:32
@KnorpelSenf KnorpelSenf merged commit 2394e85 into grammyjs:main Apr 16, 2025
6 checks passed
@KnorpelSenf
Copy link
Member

@all-contributors add @SpEcHiDe for idea and code and test

@allcontributors
Copy link
Contributor

@KnorpelSenf

I've put up a pull request to add @SpEcHiDe! 🎉

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