-
Notifications
You must be signed in to change notification settings - Fork 121
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
Update message.go #147
Update message.go #147
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package message | ||
|
||
import ( | ||
"fmt" | ||
|
@@ -306,3 +306,15 @@ | |
return TopicEdited(msg) || TopicCreated(msg) || | ||
TopicClosed(msg) || TopicReopened(msg) | ||
} | ||
|
||
func MessageEntityPre(offset int, length int, language string) filters.Filter { | ||
return func(ctx *gotgbot.CallbackContext) bool { | ||
entities := ctx.Message.Entities | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will only work on text messages, and not on media messages; that relies on message.CaptionEntities. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. about it only working on text messages and not media messages, yeah iam included media messages in below cod
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please don't make code changes in the PR comments, make your code changes to the PR itself. I cant merge a comment :) |
||
for _, entity := range entities { | ||
if entity.Offset == offset && entity.Length == length && entity.Language == language { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you have any example scenarios where one is able to predict both the offset and the length of an incoming message entity? I am not able to come up with one myself. Additionally, this check is not asserting that the entity is a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. predicting both the offset and length of an incoming message entity might not always be feasible or practical, especially in real-time scenarios. However, if you're dealing with predefined message formats or templates, you could potentially predict these values based on the structure of your messages. Here is one example to you understand proper However, if the offset and length need to be dynamically determined based on user input or other factors, predicting them accurately might be challenging. In such cases, it's often better to rely on other attributes or patterns in the message content rather than trying to predict specific offsets and lengths. Regarding the method name not asserting that the entity is a pre entity, you're correct. If you want to specifically filter preformatted code entities, you should include additional checks for the entity type. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As you've noted yourself, this isnt feasible or practical. Which makes this function very unlikely to be used. Users that will hit the niche usecase you've mentioned can simply implement the filter themselves, to work exactly like they need. Given this, it sounds like we agree that this PR should not be merged. |
||
return true | ||
} | ||
} | ||
return false | ||
} | ||
} |
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.
This type does not exist.
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.
function
MessageEntityPre
that takesoffset
,length
, andlanguage
parameters. However,filters.Filter
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.
There are no such types as
filter.Filter
, orgotgbot.CallbackContext
.