X-Git-Url: https://git.rmz.io/dotfiles.git/blobdiff_plain/f5d80dd7a716b4d9e3f4ce9382d9c79f9d72f5b9..fdd63454b51a35418ec23d3489cf20ae66a2299d:/weechat/ruby/colorizer.rb?ds=sidebyside diff --git a/weechat/ruby/colorizer.rb b/weechat/ruby/colorizer.rb index 21c15bb..14d1729 100644 --- a/weechat/ruby/colorizer.rb +++ b/weechat/ruby/colorizer.rb @@ -32,12 +32,13 @@ # Changelog: # # 0.1: Initial release. -# +# 0.2: Add compatibility with new weechat_print modifier data (WeeChat >= 2.9). +# 0.3: Fix the compatibility checker SCRIPT_NAME = 'colorizer' SCRIPT_AUTHOR = 'Michael B. Hix' SCRIPT_DESC = 'Colorize text in buffers based on rules.' -SCRIPT_VERSION = '0.1' +SCRIPT_VERSION = '0.3' SCRIPT_LICENSE = 'BSD' # A default coloring rule. @@ -157,8 +158,16 @@ end # Handle message printing. # def colorize_cb( data, modifier, modifier_data, message ) - _,buffer,_ = modifier_data.split( ';' ) - return message unless @buffer_regex =~ buffer + if modifier_data.start_with?('0x') + # WeeChat >= 2.9 + buffer, tags = modifier_data.split( ';' ) + buffer_name = Weechat.buffer_get_string(buffer, 'name') + else + # WeeChat <= 2.8 + plugin, buffer_name, tags = modifier_data.split( ';' ) + end + + return message unless @buffer_regex =~ buffer_name reset = Weechat.color( 'reset' ) @rules.each do |reg, color_str|