colorize_nicks.py 33: add many improvements, features, and fixes#574
Merged
flashcode merged 1 commit intoweechat:mainfrom May 9, 2025
Merged
colorize_nicks.py 33: add many improvements, features, and fixes#574flashcode merged 1 commit intoweechat:mainfrom
flashcode merged 1 commit intoweechat:mainfrom
Conversation
Contributor
|
works for me |
Member
|
Hi @ryoskzypu, Thanks for all these improvements. To trace the history, could you please add all new features and fixes into the body of the And then you can remove Thanks! |
Changes: - Remove the VALID_NICK regex to not be dependent on RFC spec and change the loop to split only on spaces, so the nick regex is free to match any suffix. - Add nick_prefixes and nick_suffixes options to configure charset affixes. - Replace the default 'greedy' matching with improved 'lazy' matching, because 'greedy' matches nicks incorrectly and crashes weechat. Thus remove ignore_nicks_in_urls option, since 'lazy' matching does not match nicks in substrings. closes weechat#133 and weechat#197. Rationale: - The greedy matching code recolors duplicated strings because of the way replace() works, so it crashes weechat on multiple duplicated nicks. - weechat#259 does not really prevent that, since it can still be reproduced by mentioning a short nick e.g. F1, repeatedly in a message. - It can be fixed by iterating on unique words, but it still colorizes nicks in substrings if a nick is mentioned before (e.g. alice https://www.alice.com), hence the option ignore_nicks_in_urls fails. - Replace hook_modifier() with hook_line() for a more granular parsing (e.g. prefix is separated from message, get filtered lines, etc). closes weechat#70, closes weechat#135. - Add preserving of message colors logic. closes weechat#49, closes weechat#175. - Add irc_only option to ignore non IRC messages (i.e. set buffer restrictions: plugin = irc, tags = irc_privmsg and irc_notice, type = channel and private). - Add do not colorize nicks in filtered messages, and colorize_filtered option. - Add colorizing of IRC prefixes and nicks on IRC private buffers. - Update colorized_input_cb() with the changes, and add decoding of IRC colors from input. - Update config_init() parsing of options. - Remove 'so,root' from blacklist_nicks default option. (These nicks do not make sense for defaults.) - Change min_nick_length default option to 1. (Single char nicks should not be excluded by default.) - Remove hook_modifier() that has the modifier colorize_nicks. (Is it possible to pass custom modifiers?) - Replace % formatting strings with f-strings, " with ', and some code to use the := operator. - Update identifiers, comments, and add some whitespace in code for readability. - Remove unused global keywords and add error handlings. - Remove utf-8 encoding header, add SPDX copyright + license tags, and add upstream link.
Contributor
Author
|
@weechatter: Thanks for testing. @flashcode: Done! Is it okay? I tried my best to fit the changes in commit for git log.
You're welcome and thank you for this great piece of software (WeeChat ofc). ;-) |
Member
|
Thanks, merged. |
|
Thank you, heartfelt, for the awesome work, marvel you do, dear Developers and Artists! ✨ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Script info
Description
Changes:
Remove the
VALID_NICKregex to not be dependent on RFC spec and change the loop to split only on spaces, so the nick regex is free to match any suffix.Add
nick_prefixesandnick_suffixesoptions to configure charset affixes.Replace the default 'greedy' matching with improved 'lazy' matching, because 'greedy' matches nicks incorrectly and crashes weechat.
'lazy' matching does not match nicks in substrings, so remove
ignore_nicks_in_urlsoption.fixes [colorize_nicks.py] Freeze on lines with repeated nick and greedy_matching = on #133 and colorize_nicks.py: Freezes weechat with too many nicks on one line #197.
Rationale:
replace()works, so it crashes weechat on multiple duplicated nicks.ignore_nicks_in_urlsfails.Replace
hook_modifier()withhook_line()for a more granular parsing (e.g. prefix is separated from message, get filtered lines, etc).Add preserving of message colors logic.
Add
irc_onlyoption to ignore non IRC messages (i.e. set buffer restrictions: plugin = irc, tags = irc_privmsg and irc_notice, type = channel and private).Add do not colorize nicks in filtered messages, and
colorize_filteredoption.Add colorizing of IRC prefixes and nicks on IRC private buffers.
Update
colorized_input_cb()with the changes, and add decoding of IRC colors from input.Update
config_init()parsing of options.Remove 'so,root' from
blacklist_nicksdefault option. (These nicks do not make sense for defaults.)Change
min_nick_lengthdefault option to 1. (Single char nicks should not be excluded by default.)Remove
hook_modifier()that has the modifier colorize_nicks. (Is it possible to pass custom modifiers?)Replace
%formatting strings with f-strings,"with', and some code to use the:=operator.Update identifiers, comments, and add some whitespace in code for readability.
Remove unused global keywords and add error handlings.
Remove utf-8 encoding header, add SPDX copyright + license tags, and add upstream link.
Checklist (script update)
script_name.py X.Y: …