From: Samir Benmendil Date: Thu, 6 Jul 2023 10:54:36 +0000 (+0100) Subject: weechat: update plugins X-Git-Url: https://git.rmz.io/dotfiles.git/commitdiff_plain/9dd1d50fd9311e580531b44f40aa8d4a32614f8f?ds=inline weechat: update plugins --- diff --git a/weechat/perl/highmon.pl b/weechat/perl/highmon.pl index 066fa43..f843cad 100644 --- a/weechat/perl/highmon.pl +++ b/weechat/perl/highmon.pl @@ -1,6 +1,5 @@ # # highmon.pl - Highlight Monitoring for weechat 0.3.0 -# Version 2.6 # # Add 'Highlight Monitor' buffer/bar to log all highlights in one spot # @@ -73,6 +72,8 @@ # Bugs and feature requests at: https://github.com/KenjiE20/highmon # History: +# 2020-06-21, Sebastien Helleu : +# v2.7: make call to bar_new compatible with WeeChat >= 2.9 # 2019-05-13, HubbeKing # v2.6: -add: send "logger_backlog" signal on buffer open if logging is enabled # 2014-08-16, KenjiE20 : @@ -266,7 +267,14 @@ sub highmon_bar_open # Make the bar item weechat::bar_item_new("highmon", "highmon_bar_build", ""); - $highmon_bar = weechat::bar_new ("highmon", "off", 100, "root", "", "bottom", "vertical", "vertical", 0, 0, "default", "cyan", "default", "on", "highmon"); + if (weechat::info_get("version_number", "") >= 0x02090000) + { + $highmon_bar = weechat::bar_new ("highmon", "off", 100, "root", "", "bottom", "vertical", "vertical", 0, 0, "default", "cyan", "default", "default", "on", "highmon"); + } + else + { + $highmon_bar = weechat::bar_new ("highmon", "off", 100, "root", "", "bottom", "vertical", "vertical", 0, 0, "default", "cyan", "default", "on", "highmon"); + } return weechat::WEECHAT_RC_OK; } @@ -717,7 +725,7 @@ sub highmon_new_message if ($cb_high == "1" || (weechat::config_get_plugin("merge_private") eq "on" && $cb_tags =~ /notify_private/)) { # Pre bug #29618 (0.3.3) away detect - if (weechat::info_get("version_number", "") <= 197120) + if (weechat::info_get("version_number", "") <= 0x00030200) { $away = ''; # Get infolist for this server @@ -1131,7 +1139,7 @@ sub format_buffer_name } # Check result of register, and attempt to behave in a sane manner -if (!weechat::register("highmon", "KenjiE20", "2.6", "GPL3", "Highlight Monitor", "", "")) +if (!weechat::register("highmon", "KenjiE20", "2.7", "GPL3", "Highlight Monitor", "", "")) { # Double load weechat::print ("", "\tHighmon is already loaded"); diff --git a/weechat/plugins.conf b/weechat/plugins.conf index dd3eb42..e346a39 100644 --- a/weechat/plugins.conf +++ b/weechat/plugins.conf @@ -64,7 +64,9 @@ python.go.color_number = "yellow,magenta" python.go.color_number_selected = "yellow,red" python.go.fuzzy_search = "off" python.go.message = "Go to: " +python.go.min_chars = "0" python.go.short_name = "off" +python.go.short_name_server = "off" python.go.sort = "number,beginning" python.go.use_core_instead_weechat = "off" python.grep.clear_buffer = "off" @@ -186,7 +188,9 @@ python.go.color_number = "color for buffer number (not selected) (default: "yell python.go.color_number_selected = "color for selected buffer number (default: "yellow,red")" python.go.fuzzy_search = "search buffer matches using approximation (default: "off")" python.go.message = "message to display before list of buffers (default: "Go to: ")" +python.go.min_chars = "Minimum chars to search and display list of matching buffers (default: "0")" python.go.short_name = "display and search in short names instead of buffer name (default: "off")" +python.go.short_name_server = "prefix short names with server names for search and display (default: "off")" python.go.sort = "comma-separated list of keys to sort buffers (the order is important, sorts are performed in the given order): name = sort by name (or short name), (default: "number,beginning")" python.go.use_core_instead_weechat = "use name "core" instead of "weechat" for core buffer (default: "off")" python.screen_away.away_suffix = "What to append to your nick when you're away." @@ -235,7 +239,7 @@ python.slack.shared_name_prefix = "The prefix of buffer names for shared channel python.slack.short_buffer_names = "Use `foo.#channel` rather than `foo.slack.com.#channel` as the internal name for Slack buffers." python.slack.show_buflist_presence = "Display a `+` character in the buffer list for present users." python.slack.show_reaction_nicks = "Display the name of the reacting user(s) alongside each reactji." -python.slack.slack_api_token = "List of Slack API tokens, one per Slack instance you want to connect to. See the README for details on how to get these." +python.slack.slack_api_token = "List of Slack API tokens, one per Slack instance you want to connect to; see the README for details on how to get these (note: content is evaluated, see /help eval)." python.slack.slack_timeout = "How long (ms) to wait when communicating with Slack." python.slack.switch_buffer_on_join = "When /joining a channel, automatically switch to it as well." python.slack.thread_broadcast_prefix = "Prefix to distinguish thread messages that were also sent to the channel, when thread_messages_in_channel is enabled." diff --git a/weechat/python/autosort.py b/weechat/python/autosort.py index 8f7c263..4312cda 100644 --- a/weechat/python/autosort.py +++ b/weechat/python/autosort.py @@ -25,6 +25,13 @@ # # Changelog: +# 3.9: +# * Remove `buffers.pl` from recommended settings. +# 3,8: +# * Fix relative sorting on script name in default rules. +# * Document a useful property of stable sort algorithms. +# 3.7: +# * Make default rules work with bitlbee, matrix and slack. # 3.6: # * Add more documentation on provided info hooks. # 3.5: @@ -80,7 +87,7 @@ import weechat SCRIPT_NAME = 'autosort' SCRIPT_AUTHOR = 'Maarten de Vries ' -SCRIPT_VERSION = '3.6' +SCRIPT_VERSION = '3.9' SCRIPT_LICENSE = 'GPL3' SCRIPT_DESC = 'Flexible automatic (or manual) buffer sorting based on eval expressions.' @@ -173,22 +180,21 @@ class Config: default_rules = json.dumps([ '${core_first}', - '${irc_last}', - '${buffer.plugin.name}', + '${info:autosort_order,${info:autosort_escape,${script_or_plugin}},core,*,irc,bitlbee,matrix,slack}', + '${script_or_plugin}', '${irc_raw_first}', - '${if:${plugin}==irc?${server}}', - '${if:${plugin}==irc?${info:autosort_order,${type},server,*,channel,private}}', - '${if:${plugin}==irc?${hashless_name}}', + '${server}', + '${info:autosort_order,${type},server,*,channel,private}', + '${hashless_name}', '${buffer.full_name}', ]) default_helpers = json.dumps({ - 'core_first': '${if:${buffer.full_name}!=core.weechat}', - 'irc_first': '${if:${buffer.plugin.name}!=irc}', - 'irc_last': '${if:${buffer.plugin.name}==irc}', - 'irc_raw_first': '${if:${buffer.full_name}!=irc.irc_raw}', - 'irc_raw_last': '${if:${buffer.full_name}==irc.irc_raw}', - 'hashless_name': '${info:autosort_replace,#,,${info:autosort_escape,${buffer.name}}}', + 'core_first': '${if:${buffer.full_name}!=core.weechat}', + 'irc_raw_first': '${if:${buffer.full_name}!=irc.irc_raw}', + 'irc_raw_last': '${if:${buffer.full_name}==irc.irc_raw}', + 'hashless_name': '${info:autosort_replace,#,,${info:autosort_escape,${buffer.name}}}', + 'script_or_plugin': '${if:${script_name}?${script_name}:${plugin}}', }) default_signal_delay = 5 @@ -961,6 +967,9 @@ order can be customized by defining your own sort rules, but the default should be sane enough for most people. It can also group IRC channel/private buffers under their server buffer if you like. +Autosort uses a stable sorting algorithm, meaning that you can manually move buffers +to change their relative order, if they sort equal with your rule set. + {*white}# Sort rules{reset} Autosort evaluates a list of eval expressions (see {*default}/help eval{reset}) and sorts the buffers based on evaluated result. Earlier rules will be considered first. Only @@ -993,12 +1002,9 @@ If you remove all signals you can still sort your buffers manually with the {*white}# Recommended settings For the best visual effect, consider setting the following options: {*white}/set {cyan}irc.look.server_buffer{reset} {brown}independent{reset} - {*white}/set {cyan}buffers.look.indenting{reset} {brown}on{reset} -The first setting allows server buffers to be sorted independently, which is +This setting allows server buffers to be sorted independently, which is needed to create a hierarchical tree view of the server and channel buffers. -The second one indents channel and private buffers in the buffer list of the -`{*default}buffers.pl{reset}` script. If you are using the {*default}buflist{reset} plugin you can (ab)use Unicode to draw a tree structure with the following setting (modify to suit your need): diff --git a/weechat/python/buffer_autoset.py b/weechat/python/buffer_autoset.py index 38dbc4b..9725cd7 100644 --- a/weechat/python/buffer_autoset.py +++ b/weechat/python/buffer_autoset.py @@ -22,6 +22,8 @@ # # History: # +# 2021-06-02, Sébastien Helleu : +# version 1.2: fix /help buffer_autoset # 2018-04-14, Kim B. Heino: # version 1.1: on startup apply settings to already opened buffers # 2017-06-21, Sébastien Helleu : @@ -31,9 +33,9 @@ # 2015-07-12, Sébastien Helleu : # version 0.8: add option buffer_autoset.look.timer to add a small timer # before setting buffer properties -# 2015-04-05, Nils Görs : +# 2015-04-05, Nils Görs : # version 0.7: increase priority of hook_signal('buffer_opened') -# 2012-12-09, Nils Görs : +# 2012-12-09, Nils Görs : # version 0.6: add support of core buffer # 2012-03-09, Sébastien Helleu : # version 0.5: fix reload of config file @@ -50,7 +52,7 @@ SCRIPT_NAME = "buffer_autoset" SCRIPT_AUTHOR = "Sébastien Helleu " -SCRIPT_VERSION = "1.1" +SCRIPT_VERSION = "1.2" SCRIPT_LICENSE = "GPL3" SCRIPT_DESC = "Auto-set buffer properties when a buffer is opened" @@ -291,26 +293,25 @@ if __name__ == "__main__" and import_ok: "[add buffer property value] | [del option]", " add: add a buffer/property/value in configuration file\n" " del: delete an option from configuration file\n" - " buffer: name of a buffer (can start or end with \"*\" as " - "wildcard)\n" + " buffer: name of a buffer (wildcard \"*\" is allowed)\n" "property: buffer property\n" " value: value for property\n" " option: name of option from configuration file\n\n" "Examples:\n" " disable timestamp on channel #weechat:\n" - " /" + SCRIPT_COMMAND + " add irc.freenode.#weechat " + " /" + SCRIPT_COMMAND + " add irc.libera.#weechat " "time_for_each_line 0\n" " add word \"weechat\" in highlight list on channel " "#savannah:\n" - " /" + SCRIPT_COMMAND + " add irc.freenode.#savannah " + " /" + SCRIPT_COMMAND + " add irc.libera.#savannah " "highlight_words_add weechat\n" - " disable highlights from nick \"mike\" on freenode server, " + " disable highlights from nick \"mike\" on libera server, " "channel #weechat (requires WeeChat >= 0.3.4):\n" - " /" + SCRIPT_COMMAND + " add irc.freenode.#weechat " + " /" + SCRIPT_COMMAND + " add irc.libera.#weechat " "hotlist_max_level_nicks_add mike:2\n" - " disable hotlist changes for nick \"bot\" on freenode " + " disable hotlist changes for nick \"bot\" on libera " "server (all channels) (requires WeeChat >= 0.3.4):\n" - " /" + SCRIPT_COMMAND + " add irc.freenode.* " + " /" + SCRIPT_COMMAND + " add irc.libera.* " "hotlist_max_level_nicks_add bot:-1", "add %(buffers_plugins_names)|" "%(buffer_autoset_current_buffer) " diff --git a/weechat/python/colorize_nicks.py b/weechat/python/colorize_nicks.py index 2c85c7c..10ffb71 100644 --- a/weechat/python/colorize_nicks.py +++ b/weechat/python/colorize_nicks.py @@ -21,6 +21,9 @@ # # # History: +# 2022-11-07: mva +# version 30: add ":" and "," to VALID_NICK regexp, +# to don't reset colorization in input_line # 2022-07-11: ncfavier # version 29: check nick for exclusion *after* stripping # decrease minimum min_nick_length to 1 @@ -93,13 +96,13 @@ w = weechat SCRIPT_NAME = "colorize_nicks" SCRIPT_AUTHOR = "xt " -SCRIPT_VERSION = "29" +SCRIPT_VERSION = "30" SCRIPT_LICENSE = "GPL" SCRIPT_DESC = "Use the weechat nick colors in the chat area" # Based on the recommendations in RFC 7613. A valid nick is composed # of anything but " ,*?.!@". -VALID_NICK = r'([@~&!%+-])?([^\s,\*?\.!@]+)' +VALID_NICK = r'([@~&!%+-])?([^\s,\*?\.!@:,]+)' valid_nick_re = re.compile(VALID_NICK) ignore_channels = [] ignore_nicks = [] diff --git a/weechat/python/go.py b/weechat/python/go.py index 2ab47ed..25041a8 100644 --- a/weechat/python/go.py +++ b/weechat/python/go.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2009-2014 Sébastien Helleu +# Copyright (C) 2009-2023 Sébastien Helleu # Copyright (C) 2010 m4v # Copyright (C) 2011 stfn # @@ -21,6 +21,12 @@ # # History: # +# 2023-06-21, Sébastien Helleu : +# version 2.9: add option "min_chars" +# 2023-01-08, Sébastien Helleu : +# version 2.8: send buffer pointer with signal "input_text_changed" +# 2021-05-25, Tomáš Janoušek : +# version 2.7: add new option to prefix short names with server names # 2019-07-11, Simmo Saan # version 2.6: fix detection of "/input search_text_here" # 2017-04-01, Sébastien Helleu : @@ -94,7 +100,7 @@ from __future__ import print_function SCRIPT_NAME = 'go' SCRIPT_AUTHOR = 'Sébastien Helleu ' -SCRIPT_VERSION = '2.6' +SCRIPT_VERSION = '2.9' SCRIPT_LICENSE = 'GPL3' SCRIPT_DESC = 'Quick jump to buffers' @@ -106,13 +112,19 @@ try: import weechat except ImportError: print('This script must be run under WeeChat.') - print('Get WeeChat now at: http://www.weechat.org/') + print('Get WeeChat now at: https://weechat.org/') IMPORT_OK = False import re # script options SETTINGS = { + 'auto_jump': ( + 'off', + 'automatically jump to buffer when it is uniquely selected'), + 'buffer_number': ( + 'on', + 'display buffer number'), 'color_number': ( 'yellow,magenta', 'color for buffer number (not selected)'), @@ -131,12 +143,21 @@ SETTINGS = { 'color_name_highlight_selected': ( 'red,brown', 'color for highlight in a selected buffer name'), + 'fuzzy_search': ( + 'off', + 'search buffer matches using approximation'), 'message': ( 'Go to: ', 'message to display before list of buffers'), + 'min_chars': ( + '0', + 'Minimum chars to search and display list of matching buffers'), 'short_name': ( 'off', 'display and search in short names instead of buffer name'), + 'short_name_server': ( + 'off', + 'prefix short names with server names for search and display'), 'sort': ( 'number,beginning', 'comma-separated list of keys to sort buffers ' @@ -149,15 +170,6 @@ SETTINGS = { 'use_core_instead_weechat': ( 'off', 'use name "core" instead of "weechat" for core buffer'), - 'auto_jump': ( - 'off', - 'automatically jump to buffer when it is uniquely selected'), - 'fuzzy_search': ( - 'off', - 'search buffer matches using approximation'), - 'buffer_number': ( - 'on', - 'display buffer number'), } # hooks management @@ -317,9 +329,14 @@ def go_matching_buffers(strinput): strinput = strinput.lower() infolist = weechat.infolist_get('buffer', '', '') while weechat.infolist_next(infolist): + pointer = weechat.infolist_pointer(infolist, 'pointer') short_name = weechat.infolist_string(infolist, 'short_name') + server = weechat.buffer_get_string(pointer, 'localvar_server') if go_option_enabled('short_name'): - name = weechat.infolist_string(infolist, 'short_name') + if go_option_enabled('short_name_server') and server: + name = server + '.' + short_name + else: + name = short_name else: name = weechat.infolist_string(infolist, 'name') if name == 'weechat' \ @@ -332,7 +349,6 @@ def go_matching_buffers(strinput): full_name = '%s.%s' % ( weechat.infolist_string(infolist, 'plugin_name'), weechat.infolist_string(infolist, 'name')) - pointer = weechat.infolist_pointer(infolist, 'pointer') matching = name.lower().find(strinput) >= 0 if not matching and strinput[-1] == ' ': matching = name.lower().endswith(strinput.strip()) @@ -401,6 +417,11 @@ def go_matching_buffers(strinput): def go_buffers_to_string(listbuf, pos, strinput): """Return string built with list of buffers found (matching user input).""" + try: + if len(strinput) < int(weechat.config_get_plugin('min_chars')): + return '' + except: + pass string = '' strinput = strinput.lower() for i in range(len(listbuf)): @@ -491,7 +512,7 @@ def go_command_run_input(data, buf, command): if buffers_pos >= len(buffers): buffers_pos = 0 weechat.hook_signal_send('input_text_changed', - weechat.WEECHAT_HOOK_SIGNAL_STRING, '') + weechat.WEECHAT_HOOK_SIGNAL_POINTER, buf) return weechat.WEECHAT_RC_OK_EAT elif command == '/input complete_previous': # choose previous buffer in list @@ -499,7 +520,7 @@ def go_command_run_input(data, buf, command): if buffers_pos < 0: buffers_pos = len(buffers) - 1 weechat.hook_signal_send('input_text_changed', - weechat.WEECHAT_HOOK_SIGNAL_STRING, '') + weechat.WEECHAT_HOOK_SIGNAL_POINTER, buf) return weechat.WEECHAT_RC_OK_EAT elif command == '/input return': # switch to selected buffer (if any) diff --git a/weechat/python/grep.py b/weechat/python/grep.py index 64dbc52..b675122 100644 --- a/weechat/python/grep.py +++ b/weechat/python/grep.py @@ -69,6 +69,18 @@ # # History: # +# 2022-11-11, anonymous2ch +# version 0.8.6: ignore utf-8 decoding errors +# +# 2021-05-02, Sébastien Helleu +# version 0.8.5: add compatibility with WeeChat >= 3.2 (XDG directories) +# +# 2020-10-11, Thom Wiggers +# version 0.8.4: Python3 compatibility fix +# +# 2020-05-06, Dominique Martinet and hexa- +# version 0.8.3: more python3 compatibility fixes... +# # 2019-06-30, dabbill # and Sébastien Helleu # version 0.8.2: make script compatible with Python 3 @@ -230,7 +242,7 @@ except ImportError: SCRIPT_NAME = "grep" SCRIPT_AUTHOR = "Elián Hanisch " -SCRIPT_VERSION = "0.8.2" +SCRIPT_VERSION = "0.8.6" SCRIPT_LICENSE = "GPL3" SCRIPT_DESC = "Search in buffers and logs" SCRIPT_COMMAND = "grep" @@ -446,9 +458,13 @@ def get_config_log_filter(): return [] def get_home(): - home = weechat.config_string(weechat.config_get('logger.file.path')) - home = home.replace('%h', weechat.info_get('weechat_dir', '')) - home = path.abspath(path.expanduser(home)) + options = { + 'directory': 'data', + } + home = weechat.string_eval_path_home( + weechat.config_string(weechat.config_get('logger.file.path')), + {}, {}, options, + ) return home def strip_home(s, dir=''): @@ -596,7 +612,10 @@ def get_file_by_name(buffer_name): if '$server' in mask: mask = mask.replace('$server', server) # change the unreplaced vars by '*' - from string import letters + try: + from string import letters + except ImportError: + from string import ascii_letters as letters if '%' in mask: # vars for time formatting mask = mask.replace('%', '$') @@ -722,7 +741,7 @@ def grep_file(file, head, tail, after_context, before_context, count, regexp, hi check = lambda s: check_string(s, regexp, hilight, exact) try: - file_object = open(file, 'r') + file_object = open(file, 'r', errors='ignore') except IOError: # file doesn't exist return lines @@ -885,8 +904,7 @@ def grep_buffer(buffer, head, tail, after_context, before_context, count, regexp check = lambda s: check_string(s, regexp, hilight, exact) if before_context: - before_context_range = range(1, before_context + 1) - before_context_range.reverse() + before_context_range = reversed(range(1, before_context + 1)) while infolist_next(infolist): line = get_line(infolist) @@ -984,7 +1002,7 @@ def show_matching_lines(): buffer_update() else: global hook_file_grep, grep_stdout, grep_stderr, pattern_tmpl - grep_stdout = grep_stderr = '' + grep_stdout = grep_stderr = b'' hook_file_grep = weechat.hook_process( 'func:grep_process', get_config_int('timeout_secs') * 1000, @@ -1009,14 +1027,17 @@ def grep_process(*args): except Exception as e: result = e - return pickle.dumps(result) - -grep_stdout = grep_stderr = '' + return pickle.dumps(result, 0) def grep_process_cb(data, command, return_code, out, err): global grep_stdout, grep_stderr, matched_lines, hook_file_grep + if isinstance(out, str): + out = out.encode() grep_stdout += out + + if isinstance(err, str): + err = err.encode() grep_stderr += err def set_buffer_error(message): @@ -1548,7 +1569,7 @@ def cmd_logs(data, buffer, args): buffer = buffer_create() if get_config_boolean('clear_buffer'): weechat.buffer_clear(buffer) - file_list = zip(file_list, file_sizes) + file_list = list(zip(file_list, file_sizes)) msg = 'Found %s logs.' %len(file_list) print_line(msg, buffer, display=True) @@ -1738,8 +1759,11 @@ Examples: debug = pybuffer.debugBuffer(globals(), '%s_debug' % SCRIPT_NAME) except: def debug(s, *args): - if not isinstance(s, basestring): - s = str(s) + try: + if not isinstance(s, basestring): + s = str(s) + except NameError: + pass if args: s = s %args prnt('', '%s\t%s' %(script_nick, s)) diff --git a/weechat/python/wee-slack b/weechat/python/wee-slack index 39ff696..5302c87 160000 --- a/weechat/python/wee-slack +++ b/weechat/python/wee-slack @@ -1 +1 @@ -Subproject commit 39ff696e6ad2c3c6381b2556786394adb06bf935 +Subproject commit 5302c8701c5411c28a00b022600ee7cd723718e2 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| diff --git a/weechat/ruby/samechannel.rb b/weechat/ruby/samechannel.rb index 84aa4ad..89f8478 100644 --- a/weechat/ruby/samechannel.rb +++ b/weechat/ruby/samechannel.rb @@ -1,3 +1,4 @@ +# coding: utf-8 # # (c) 2013 Hendrik 'henk' Jaeger # (c) 2015 arza @@ -22,12 +23,15 @@ # 2015-09-24 0.1 arza: # - option -m/--minimum for minimum count of mutual channels # - fixed completion +# 2021-11-06 0.2 Sébastien Helleu: +# - make script compatible with WeeChat >= 3.4 +# (new parameters in function hdata_search) def weechat_init Weechat.register( "samechannel", "henk", - "0.1", + "0.2", "GPL3", "Lists multiple occurences of the same nick(s) in a set of channels.", "", @@ -156,10 +160,17 @@ def find_channels( names, serverptr ) end def find_servers( names ) + weechat_version = Weechat.info_get('version_number', '').to_i serverptrlist = Weechat.hdata_get_list($hdata_ircserver, 'irc_servers') if names matching_servers = names.map do |name| - foundserverptr = Weechat.hdata_search($hdata_ircserver, serverptrlist, '${irc_server.name} =~ ' + name, 1) + if weechat_version >= 0x03040000 + foundserverptr = Weechat.hdata_search($hdata_ircserver, serverptrlist, + '${irc_server.name} =~ ${name}', + {}, {'name' => name}, {}, 1) + else + foundserverptr = Weechat.hdata_search($hdata_ircserver, serverptrlist, '${irc_server.name} =~ ' + name, 1) + end end else return hhh_get_ptrarray($hdata_ircserver, serverptrlist)