]> git.rmz.io Git - dotfiles.git/commitdiff
weechat: update plugins
authorSamir Benmendil <me@rmz.io>
Thu, 6 Jul 2023 10:54:36 +0000 (11:54 +0100)
committerSamir Benmendil <me@rmz.io>
Sun, 17 Dec 2023 17:36:17 +0000 (17:36 +0000)
weechat/perl/highmon.pl
weechat/plugins.conf
weechat/python/autosort.py
weechat/python/buffer_autoset.py
weechat/python/colorize_nicks.py
weechat/python/go.py
weechat/python/grep.py
weechat/python/wee-slack
weechat/ruby/colorizer.rb
weechat/ruby/samechannel.rb

index 066fa4370997aa43c653df0aa097bd037f11a999..f843cade98fb108aa2eb4e6dc200d36a85433c27 100644 (file)
@@ -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 <flashcode@flashtux.org>:
+#      v2.7: make call to bar_new compatible with WeeChat >= 2.9
 # 2019-05-13, HubbeKing <hubbe128@gmail.com>
 #      v2.6:   -add: send "logger_backlog" signal on buffer open if logging is enabled
 # 2014-08-16, KenjiE20 <longbow@longbowslair.co.uk>:
@@ -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");
index dd3eb42b41a8e9a1cb1f68a1e829c21d1b40146b..e346a39b5f05bc355a8244774f873078ee3351c5 100644 (file)
@@ -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."
index 8f7c263e149ae1b24868b0c840f480b887710f8a..4312cda767c919e66bf66506d85f9caff95e2f09 100644 (file)
 
 #
 # 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 <maarten@de-vri.es>'
-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):
index 38dbc4b71023f8c301c507469ce8d96f7ac52b87..9725cd769b2cc4e3a059cc43f312fdd776952eaa 100644 (file)
@@ -22,6 +22,8 @@
 #
 # History:
 #
+# 2021-06-02, Sébastien Helleu <flashcode@flashtux.org>:
+#     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 <flashcode@flashtux.org>:
@@ -31,9 +33,9 @@
 # 2015-07-12, Sébastien Helleu <flashcode@flashtux.org>:
 #     version 0.8: add option buffer_autoset.look.timer to add a small timer
 #                  before setting buffer properties
-# 2015-04-05, Nils Görs <freenode@#weechat>:
+# 2015-04-05, Nils Görs <libera@#weechat>:
 #     version 0.7: increase priority of hook_signal('buffer_opened')
-# 2012-12-09, Nils Görs <freenode@#weechat>:
+# 2012-12-09, Nils Görs <libera@#weechat>:
 #     version 0.6: add support of core buffer
 # 2012-03-09, Sébastien Helleu <flashcode@flashtux.org>:
 #     version 0.5: fix reload of config file
@@ -50,7 +52,7 @@
 
 SCRIPT_NAME = "buffer_autoset"
 SCRIPT_AUTHOR = "Sébastien Helleu <flashcode@flashtux.org>"
-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) "
index 2c85c7c80d7cfe82ab2d3516ecc27ce3f4f82657..10ffb71121991b732f57e929fcd790363a0735a9 100644 (file)
@@ -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 <xt@bash.no>"
-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 = []
index 2ab47ed4523a104c06311709773d0c19c80d60fc..25041a8079665e5a59961624cb17ebf78ce7b4c3 100644 (file)
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2009-2014 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2009-2023 Sébastien Helleu <flashcode@flashtux.org>
 # Copyright (C) 2010 m4v <lambdae2@gmail.com>
 # Copyright (C) 2011 stfn <stfnmd@googlemail.com>
 #
 #
 # History:
 #
+# 2023-06-21, Sébastien Helleu <flashcode@flashtux.org>:
+#     version 2.9: add option "min_chars"
+# 2023-01-08, Sébastien Helleu <flashcode@flashtux.org>:
+#     version 2.8: send buffer pointer with signal "input_text_changed"
+# 2021-05-25, Tomáš Janoušek <tomi@nomi.cz>:
+#     version 2.7: add new option to prefix short names with server names
 # 2019-07-11, Simmo Saan <simmo.saan@gmail.com>
 #     version 2.6: fix detection of "/input search_text_here"
 # 2017-04-01, Sébastien Helleu <flashcode@flashtux.org>:
@@ -94,7 +100,7 @@ from __future__ import print_function
 
 SCRIPT_NAME = 'go'
 SCRIPT_AUTHOR = 'Sébastien Helleu <flashcode@flashtux.org>'
-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)
index 64dbc528f55b6afba0b9c34c8c5002e5c4324f07..b6751225a5320df67770b3012f2e2816ab4bba0b 100644 (file)
 #
 #   History:
 #
+#   2022-11-11, anonymous2ch
+#   version 0.8.6: ignore utf-8 decoding errors
+#
+#   2021-05-02, Sébastien Helleu <flashcode@flashtux.org>
+#   version 0.8.5: add compatibility with WeeChat >= 3.2 (XDG directories)
+#
+#   2020-10-11, Thom Wiggers <thom@thomwiggers.nl>
+#   version 0.8.4: Python3 compatibility fix
+#
+#   2020-05-06, Dominique Martinet <asmadeus@codewreck.org> and hexa-
+#   version 0.8.3: more python3 compatibility fixes...
+#
 #   2019-06-30, dabbill <dabbill@gmail.com>
 #               and Sébastien Helleu <flashcode@flashtux.org>
 #   version 0.8.2: make script compatible with Python 3
@@ -230,7 +242,7 @@ except ImportError:
 
 SCRIPT_NAME    = "grep"
 SCRIPT_AUTHOR  = "Elián Hanisch <lambdae2@gmail.com>"
-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))
index 39ff696e6ad2c3c6381b2556786394adb06bf935..5302c8701c5411c28a00b022600ee7cd723718e2 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 39ff696e6ad2c3c6381b2556786394adb06bf935
+Subproject commit 5302c8701c5411c28a00b022600ee7cd723718e2
index 21c15bbe5154dc70dad660cf8559a07fdb60e3b5..14d1729eef6b429276a74e9081e7d8ac2a20a02e 100644 (file)
 # 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|
index 84aa4ad5fdc51cd252ff71dd0aad813a66238bb7..89f8478a69bc55922789c6c19ac21cacb2e5cd3b 100644 (file)
@@ -1,3 +1,4 @@
+# coding: utf-8
 #
 # (c) 2013 Hendrik 'henk' Jaeger <weechat@henk.geekmail.org>
 # (c) 2015 arza <arza@arza.us>
 # 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)