Commit 69ca3a99 authored by Sébastien Helleu's avatar Sébastien Helleu 0.1.3: add compatibility with new weechat_print modifier data (WeeChat >= 2.9)

parent a8023f15
......@@ -28,7 +28,7 @@ import re
SCRIPT_NAME = 'unhighlight'
SCRIPT_DESC = 'Allows per-buffer specification of a regex that prevents highlights.'
......@@ -40,19 +40,17 @@ def matches_unhighlight_strings(msg, regex):
def unhighlight_cb(data, modifier, modifier_data, message):
"""Check if the line matches the unhighlight regular expression, and if it does, clear the message and reprint it with the no_highlight tag added."""
# Buffer names can have ; in them, but not plugins or tags (I HOPE),
# so just split(';') would have weird edgecases with channels that have a ;
# in the name.
m = re.match("^(?P<plugin>\S+);(?P<full_name>\S+);(?P<tags>\S*)$", modifier_data)
if modifier_data.startswith('0x'):
# WeeChat >= 2.9
buffer, tags = modifier_data.split(';', 1)
# WeeChat <= 2.8
plugin, buffer_name, tags = modifier_data.split(';', 2)
buffer = weechat.buffer_search(plugin, buffer_name)
tags ='tags')
if 'no_highlight' in tags or 'notify_none' in tags:
return message
plugin ='plugin')
full_name ='full_name')
buffer = weechat.buffer_search(plugin, full_name)
unhighlight_regex = weechat.buffer_get_string(buffer, 'localvar_unhighlight_regex')
if not matches_unhighlight_strings(message, unhighlight_regex):
return message
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment