Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

Added url Filter#565

Closed
logicfool wants to merge 1 commit into
pyrogram:masterfrom
logicfool:master
Closed

Added url Filter#565
logicfool wants to merge 1 commit into
pyrogram:masterfrom
logicfool:master

Conversation

@logicfool

@logicfool logicfool commented Dec 19, 2020

Copy link
Copy Markdown

Url filter

It would be easier for people working with urls to use this filter and check if that message has a url or not so they wont have to go all the way through entities and check the type and then use if else

right now I just used entities to go through all of them but will read the whole pyrogram code and modify this later on to make it better then it is right now

@zeroone2numeral2

Copy link
Copy Markdown
Contributor

Hmm, why not just adding a filter that filters messages based on an user-specified entity? Such as python-telegram-bot's Filters.entity(), to which one could pass a list of pyrogram.types.MessageEntity. Stopping at checking whether a message has urls or not feels unnecessarily limited

@logicfool

logicfool commented Dec 19, 2020

Copy link
Copy Markdown
Author

Yeah that can be done as well and that would be better but as everything else like common entities are present in filters directly and urls are used by alot of programmers so just thought why not make a common filter for urls.

The method you said looks clean will try to impliment that till then this can be considered as a quick fix for all those who want to skip those nested if else's for checking if a url is present in their text or not.

@zeroone2numeral2

Copy link
Copy Markdown
Contributor

Uhm, I think quick fixes be part of the user's code instead of being embedded directly in the library

@logicfool

Copy link
Copy Markdown
Author

Yeah that's true will close this Pull Request.

@logicfool logicfool closed this Dec 19, 2020
@logicfool logicfool reopened this Dec 19, 2020
@logicfool logicfool closed this Dec 19, 2020

@ChenZehong13 ChenZehong13 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@ColinShark

Copy link
Copy Markdown
Contributor

Hi @logicfool, Your implementation of a URL filter looks quite messy in my opinion. The other filters we have in Pyrogram aren't quite for MessageEntities, but for attributes already easily accessible. These are convenient for the user as they don't have to do long if-chains anymore. A URL filter for the MessageEntity isn't really beneficial, as a User still has to check the individual Entities to check whether or not the URL is correct or expected. It would be a lot easier to use a basic URL RegEx (I made this in about a minute).

@ChenZehong13 From your commit history in your own repositories and your stars I take you don't work with Python or Pyrogram often or at all. Why do you leave Reviews and comments that contribute literally nothing to the PR at hand? That's a rhetorical question

@logicfool

Copy link
Copy Markdown
Author

Ah yes I understand better not put it in the main library..

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants