diff options
Diffstat (limited to 'weechat')
-rw-r--r-- | weechat/perl/buffers.pl | 69 | ||||
-rw-r--r-- | weechat/perl/iset.pl | 198 | ||||
-rw-r--r-- | weechat/python/autojoin_on_invite.py | 27 | ||||
-rw-r--r-- | weechat/python/colorize_nicks.py | 5 |
4 files changed, 249 insertions, 50 deletions
diff --git a/weechat/perl/buffers.pl b/weechat/perl/buffers.pl index c31d8fc..73eb4b5 100644 --- a/weechat/perl/buffers.pl +++ b/weechat/perl/buffers.pl @@ -20,7 +20,13 @@ # # History: # -# 2015-03-29, Ed Santiago <ed@edsantiago.com> +# 2016-05-01, mumixam <mumixam@gmail.com>: +# v5.4: added option "detach_buffer_immediately_level" +# 2015-08-21, Matthew Cox <matthewcpcox@gmail.com> +# v5.3: add option "indenting_amount", to adjust the indenting of channel buffers +# 2015-05-02, arza <arza@arza.us>: +# v5.2: truncate long names (name_size_max) more when mark_inactive adds parenthesis +# 2015-03-29, Ed Santiago <ed@edsantiago.com>: # v5.1: merged buffers: always indent, except when filling is horizontal # 2014-12-12 # v5.0: fix cropping non-latin buffer names @@ -166,13 +172,15 @@ use strict; use Encode qw( decode encode ); # -----------------------------[ internal ]------------------------------------- my $SCRIPT_NAME = "buffers"; -my $SCRIPT_VERSION = "5.1"; +my $SCRIPT_VERSION = "5.4"; my $BUFFERS_CONFIG_FILE_NAME = "buffers"; my $buffers_config_file; my $cmd_buffers_whitelist= "buffers_whitelist"; my $cmd_buffers_detach = "buffers_detach"; +my $maxlength; + my %mouse_keys = ("\@item(buffers):button1*" => "hsignal:buffers_mouse", "\@item(buffers):button2*" => "hsignal:buffers_mouse", "\@bar(buffers):ctrl-wheelup" => "hsignal:buffers_mouse", @@ -677,6 +685,13 @@ my %default_options_look = "", 0, 0, "on", "on", 0, "", "", "buffers_signal_config", "", "", "" ], + "indenting_amount" => [ + "indenting_amount", "integer", + "amount of indenting to use. This option only takes effect if bar ". + "is left/right positioned, and indenting is enabled", + "", 0, 16, 2, 2, 0, + "", "", "buffers_signal_config", "", "", "" + ], "short_names" => [ "short_names", "boolean", "display short names (remove text before first \".\" in buffer name)", @@ -780,12 +795,24 @@ my %default_options_look = ], "detach_buffer_immediately" => [ "detach_buffer_immediately", "string", - "comma separated list of buffers to detach immediately. A query and ". - "highlight message will attach buffer again. Allows \"*\" wildcard. ". + "comma separated list of buffers to detach immediately. Buffers ". + "will attach again based on notify level set in ". + "\"detach_buffer_immediately_level\". Allows \"*\" wildcard. ". "Ex: \"BitlBee,freenode.*\"", "", 0, 0, "", "", 0, "", "", "buffers_signal_config_detach_buffer_immediately", "", "", "" ], + "detach_buffer_immediately_level" => [ + "detach_buffer_immediately_level", "integer", + "The value determines what notify level messages are reattached from activity. ". + " This option works in conjunction with \"detach_buffer_immediately\" ". + "0: low priority (like join/part messages), ". + "1: message, ". + "2: private, ". + "3: highlight", + "", 0, 3, 2, 2, 0, + "", "", "buffers_signal_config", "", "", "" + ], "detach_free_content" => [ "detach_free_content", "boolean", "buffers with free content will be detached (Ex: iset, chanmon)", @@ -994,11 +1021,11 @@ sub build_buffers weechat::infolist_free($infolist_channel); } - my $result = check_immune_detached_buffers($buffer->{"name"}); # checking for wildcard - + my $result = check_immune_detached_buffers($buffer->{"name"}); # checking for wildcard + my $maxlevel = weechat::config_integer($options{"detach_buffer_immediately_level"}); next if ( check_detach_buffer_immediately($buffer->{"name"}) eq 1 and $buffer->{"current_buffer"} eq 0 - and ( not exists $hotlist{$buffer->{"pointer"}} or $hotlist{$buffer->{"pointer"}} < 2) ); # checking for buffer to immediately detach + and ( not exists $hotlist{$buffer->{"pointer"}} or $hotlist{$buffer->{"pointer"}} < $maxlevel) ); # checking for buffer to immediately detach unless ($result) { @@ -1118,8 +1145,14 @@ sub build_buffers $name = $buffer->{"name"}; } } - if (weechat::config_integer($options{"name_size_max"}) >= 1){ - $name = encode("UTF-8", substr(decode("UTF-8", $name), 0, weechat::config_integer($options{"name_size_max"}))); + if (weechat::config_integer($options{"name_size_max"}) >= 1) + { + $maxlength = weechat::config_integer($options{"name_size_max"}); + if($buffer->{"type"} eq "channel" and weechat::config_boolean( $options{"mark_inactive"} ) eq 1 and $buffer->{"nicks_count"} == 0) + { + $maxlength -= 2; + } + $name = encode("UTF-8", substr(decode("UTF-8", $name), 0, $maxlength)); } if ( weechat::config_boolean($options{"core_to_front"}) eq 1) { @@ -1325,16 +1358,17 @@ sub build_buffers { if ( weechat::config_integer( $options{"indenting"} ) eq 1 ) { - $str .= " "; + $str .= (" " x weechat::config_integer( $options{"indenting_amount"} ) ); } elsif ( (weechat::config_integer($options{"indenting"}) eq 2) and (weechat::config_integer($options{"indenting_number"}) eq 0) ) #under_name { if ( weechat::config_boolean( $options{"show_number"} ) eq 0 ) { - $str .= " "; - }else + $str .= (" " x weechat::config_integer( $options{"indenting_amount"} ) ); + } + else { - $str .= ( (" " x ( $max_number_digits - length($buffer->{"number"}) ))." " ); + $str .= ( (" " x ( $max_number_digits - length($buffer->{"number"}) )).(" " x weechat::config_integer( $options{"indenting_amount"} ) ) ); } } } @@ -1400,7 +1434,14 @@ sub build_buffers if (weechat::config_integer($options{"name_size_max"}) >= 1) # check max_size of buffer name { $name = decode("UTF-8", $name); - $str .= encode("UTF-8", substr($name, 0, weechat::config_integer($options{"name_size_max"}))); + + $maxlength = weechat::config_integer($options{"name_size_max"}); + if($buffer->{"type"} eq "channel" and weechat::config_boolean( $options{"mark_inactive"} ) eq 1 and $buffer->{"nicks_count"} == 0) + { + $maxlength -= 2; + } + + $str .= encode("UTF-8", substr($name, 0, $maxlength)); $str .= weechat::color(weechat::config_color( $options{"color_number_char"})).weechat::config_string($options{"name_crop_suffix"}) if (length($name) > weechat::config_integer($options{"name_size_max"})); $str .= add_inactive_parentless($buffer->{"type"}, $buffer->{"nicks_count"}); $str .= add_hotlist_count($buffer->{"pointer"}, %hotlist); diff --git a/weechat/perl/iset.pl b/weechat/perl/iset.pl index af74767..163dfb5 100644 --- a/weechat/perl/iset.pl +++ b/weechat/perl/iset.pl @@ -19,6 +19,13 @@ # # History: # +# 2016-07-08, nils_2 <weechatter@arcor.de> +# version 4.2: add diff function +# 2016-02-06, Sebastien Helleu <flashcode@flashtux.org>: +# version 4.1: remove debug print +# 2015-12-24, Sebastien Helleu <flashcode@flashtux.org>: +# version 4.0: add support of parent options (inherited values in irc servers) +# with WeeChat >= 1.4 # 2015-05-16, Sebastien Helleu <flashcode@flashtux.org>: # version 3.9: fix cursor position when editing an option with WeeChat >= 1.2 # 2015-05-02, arza <arza@arza.us>: @@ -123,7 +130,7 @@ use strict; my $PRGNAME = "iset"; -my $VERSION = "3.9"; +my $VERSION = "4.2"; my $DESCR = "Interactive Set for configuration options"; my $AUTHOR = "Sebastien Helleu <flashcode\@flashtux.org>"; my $LICENSE = "GPL3"; @@ -135,9 +142,11 @@ my $iset_buffer = ""; my $wee_version_number = 0; my @iset_focus = (); my @options_names = (); +my @options_parent_names = (); my @options_types = (); my @options_values = (); my @options_default_values = (); +my @options_parent_values = (); my @options_is_null = (); my $option_max_length = 0; my $current_line = 0; @@ -145,7 +154,7 @@ my $filter = "*"; my $description = ""; my $options_name_copy = ""; my $iset_filter_title = ""; -# search modes: 0 = index() on value, 1 = grep() on value, 2 = grep() on option, 3 = grep on option & value +# search modes: 0 = index() on value, 1 = grep() on value, 2 = grep() on option, 3 = grep on option & value, 4 = diff all, 5 = diff parts my $search_mode = 2; my $search_value = ""; my $help_text_keys = "alt + space: toggle, +/-: increase/decrease, enter: change, ir: reset, iu: unset, v: toggle help bar"; @@ -195,6 +204,12 @@ sub iset_title $filter = "*" if ($filter eq ""); $show_filter = $filter; } + elsif ($search_mode == 4 or $search_mode == 5) + { + $iset_filter_title = "diff: "; + $show_filter = "all"; + $show_filter = $search_value if $search_mode == 5; + } elsif ($search_mode eq 3) { $iset_filter_title = "(option) "; @@ -267,10 +282,27 @@ sub iset_buffer_input weechat::buffer_set($iset_buffer, "localvar_set_iset_search_value", $search_value); } } + # show all diff values + elsif ($string eq "d") + { + $search_mode = 4; +# iset_title(); + iset_create_filter("*"); + iset_get_options("*"); + } + elsif ( $array_count >= 2 and $cmd_array[0] eq "d") + { + $search_mode = 5; + $search_value = substr($cmd_array[1], 0); # cut value_search_char + $search_value = substr($cmd_array[2], 0) if ( $array_count > 2); # cut value_search_char + iset_create_filter($search_value); + iset_get_options($search_value); + + } else { $search_mode = 2; - if ( $array_count >= 2 and $cmd_array[0] ne "f" or $cmd_array[0] ne "s") + if ( $array_count >= 2 and $cmd_array[0] ne "f" or $cmd_array[0] ne "s" ) { if ( defined $cmd_array[1] and substr($cmd_array[1], 0, 1) eq weechat::config_string($options_iset{"value_search_char"}) or defined $cmd_array[2] and substr($cmd_array[2], 0, 1) eq weechat::config_string($options_iset{"value_search_char"}) ) @@ -284,7 +316,8 @@ sub iset_buffer_input { iset_create_filter($string); iset_get_options($search_value); - }else + } + else { iset_create_filter($string); iset_get_options(""); @@ -353,9 +386,11 @@ sub iset_get_options $search_value = $var_value; @iset_focus = (); @options_names = (); + @options_parent_names = (); @options_types = (); @options_values = (); @options_default_values = (); + @options_parent_values = (); @options_is_null = (); $option_max_length = 0; my %options_internal = (); @@ -371,34 +406,61 @@ sub iset_get_options { $key = sprintf("%08d", $i); my $name = weechat::infolist_string($infolist, "full_name"); + my $parent_name = weechat::infolist_string($infolist, "parent_name"); next if (weechat::config_boolean($options_iset{"show_plugin_description"}) == 0 and index ($name, "plugins.desc.") != -1); my $type = weechat::infolist_string($infolist, "type"); my $value = weechat::infolist_string($infolist, "value"); my $default_value = weechat::infolist_string($infolist, "default_value"); + my $parent_value; + if ($parent_name && (($wee_version_number < 0x00040300) || (weechat::infolist_search_var($infolist, "parent_value")))) + { + $parent_value = weechat::infolist_string($infolist, "parent_value"); + } my $is_null = weechat::infolist_integer($infolist, "value_is_null"); + if ($search_mode == 3) { my $value = weechat::infolist_string($infolist, "value"); if ( grep /\Q$var_value/,lc($value) ) { + $options_internal{$name}{"parent_name"} = $parent_name; $options_internal{$name}{"type"} = $type; $options_internal{$name}{"value"} = $value; $options_internal{$name}{"default_value"} = $default_value; + $options_internal{$name}{"parent_value"} = $parent_value; $options_internal{$name}{"is_null"} = $is_null; $option_max_length = length($name) if (length($name) > $option_max_length); - $iset_struct{$key} = $options_internal{$name}; - push(@iset_focus, $iset_struct{$key}); + $iset_struct{$key} = $options_internal{$name}; + push(@iset_focus, $iset_struct{$key}); + } + } + # search for diff? + elsif ( $search_mode == 4 or $search_mode == 5) + { + if ($value ne $default_value ) + { + $options_internal{$name}{"parent_name"} = $parent_name; + $options_internal{$name}{"type"} = $type; + $options_internal{$name}{"value"} = $value; + $options_internal{$name}{"default_value"} = $default_value; + $options_internal{$name}{"parent_value"} = $parent_value; + $options_internal{$name}{"is_null"} = $is_null; + $option_max_length = length($name) if (length($name) > $option_max_length); + $iset_struct{$key} = $options_internal{$name}; + push(@iset_focus, $iset_struct{$key}); } } else { + $options_internal{$name}{"parent_name"} = $parent_name; $options_internal{$name}{"type"} = $type; $options_internal{$name}{"value"} = $value; $options_internal{$name}{"default_value"} = $default_value; + $options_internal{$name}{"parent_value"} = $parent_value; $options_internal{$name}{"is_null"} = $is_null; $option_max_length = length($name) if (length($name) > $option_max_length); - $iset_struct{$key} = $options_internal{$name}; - push(@iset_focus, $iset_struct{$key}); + $iset_struct{$key} = $options_internal{$name}; + push(@iset_focus, $iset_struct{$key}); } $i++; } @@ -407,9 +469,11 @@ sub iset_get_options foreach my $name (sort keys %options_internal) { push(@options_names, $name); + push(@options_parent_names, $options_internal{$name}{"parent_name"}); push(@options_types, $options_internal{$name}{"type"}); push(@options_values, $options_internal{$name}{"value"}); push(@options_default_values, $options_internal{$name}{"default_value"}); + push(@options_parent_values, $options_internal{$name}{"parent_value"}); push(@options_is_null, $options_internal{$name}{"is_null"}); } } @@ -432,9 +496,11 @@ sub iset_search_values { my ($var_value,$search_mode) = ($_[0],$_[1]); @options_names = (); + @options_parent_names = (); @options_types = (); @options_values = (); @options_default_values = (); + @options_parent_values = (); @options_is_null = (); $option_max_length = 0; my %options_internal = (); @@ -443,18 +509,26 @@ sub iset_search_values while (weechat::infolist_next($infolist)) { my $name = weechat::infolist_string($infolist, "full_name"); + my $parent_name = weechat::infolist_string($infolist, "parent_name"); next if (weechat::config_boolean($options_iset{"show_plugin_description"}) == 0 and index ($name, "plugins.desc.") != -1); my $type = weechat::infolist_string($infolist, "type"); my $is_null = weechat::infolist_integer($infolist, "value_is_null"); my $value = weechat::infolist_string($infolist, "value"); my $default_value = weechat::infolist_string($infolist, "default_value"); + my $parent_value; + if ($parent_name && (($wee_version_number < 0x00040300) || (weechat::infolist_search_var($infolist, "parent_value")))) + { + $parent_value = weechat::infolist_string($infolist, "parent_value"); + } if ($search_mode) { if ( grep /\Q$var_value/,lc($value) ) { + $options_internal{$name}{"parent_name"} = $parent_name; $options_internal{$name}{"type"} = $type; $options_internal{$name}{"value"} = $value; $options_internal{$name}{"default_value"} = $default_value; + $options_internal{$name}{"parent_value"} = $parent_value; $options_internal{$name}{"is_null"} = $is_null; $option_max_length = length($name) if (length($name) > $option_max_length); } @@ -464,9 +538,11 @@ sub iset_search_values # if ($value =~ /\Q$var_value/si) if (lc($value) eq $var_value) { + $options_internal{$name}{"parent_name"} = $parent_name; $options_internal{$name}{"type"} = $type; $options_internal{$name}{"value"} = $value; $options_internal{$name}{"default_value"} = $default_value; + $options_internal{$name}{"parent_value"} = $parent_value; $options_internal{$name}{"is_null"} = $is_null; $option_max_length = length($name) if (length($name) > $option_max_length); } @@ -477,9 +553,11 @@ sub iset_search_values foreach my $name (sort keys %options_internal) { push(@options_names, $name); + push(@options_parent_names, $options_internal{$name}{"parent_name"}); push(@options_types, $options_internal{$name}{"type"}); push(@options_values, $options_internal{$name}{"value"}); push(@options_default_values, $options_internal{$name}{"default_value"}); + push(@options_parent_values, $options_internal{$name}{"parent_value"}); push(@options_is_null, $options_internal{$name}{"is_null"}); } } @@ -508,9 +586,11 @@ sub iset_refresh_line my $color1 = weechat::color(weechat::config_color($options_iset{"color_option"})); my $color2 = weechat::color(weechat::config_color($options_iset{"color_type"})); my $color3 = ""; + my $color4 = ""; if ($options_is_null[$y]) { $color3 = weechat::color(weechat::config_color($options_iset{"color_value_undef"})); + $color4 = weechat::color(weechat::config_color($options_iset{"color_value"})); } elsif ($options_values[$y] ne $options_default_values[$y]) { @@ -527,6 +607,7 @@ sub iset_refresh_line if ($options_is_null[$y]) { $color3 = weechat::color(weechat::config_color($options_iset{"color_value_undef_selected"}).",".weechat::config_color($options_iset{"color_bg_selected"})); + $color4 = weechat::color(weechat::config_color($options_iset{"color_value_selected"}).",".weechat::config_color($options_iset{"color_bg_selected"})); } elsif ($options_values[$y] ne $options_default_values[$y]) { @@ -538,7 +619,23 @@ sub iset_refresh_line } } my $value = $options_values[$y]; - $value = "(undef)" if ($options_is_null[$y]); + if ($options_is_null[$y]) + { + $value = "null"; + if ($options_parent_names[$y]) + { + if (defined $options_parent_values[$y]) + { + my $around_parent = ""; + $around_parent = "\"" if ($options_types[$y] eq "string"); + $value .= $color1." -> ".$color4.$around_parent.$options_parent_values[$y].$around_parent; + } + else + { + $value .= $color1." -> ".$color3."null"; + } + } + } my $strline = sprintf($format, $color1, $options_names[$y], $padding, $color2, $options_types[$y], @@ -712,6 +809,39 @@ sub iset_get_option_name_index return -1; } +sub iset_refresh_option +{ + my $option_name = $_[0]; + my $index = $_[1]; + my $infolist = weechat::infolist_get("option", "", $option_name); + if ($infolist) + { + weechat::infolist_next($infolist); + if (weechat::infolist_fields($infolist)) + { + $options_parent_names[$index] = weechat::infolist_string($infolist, "parent_name"); + $options_types[$index] = weechat::infolist_string($infolist, "type"); + $options_values[$index] = weechat::infolist_string($infolist, "value"); + $options_default_values[$index] = weechat::infolist_string($infolist, "default_value"); + $options_is_null[$index] = weechat::infolist_integer($infolist, "value_is_null"); + $options_parent_values[$index] = undef; + if ($options_parent_names[$index] + && (($wee_version_number < 0x00040300) || (weechat::infolist_search_var($infolist, "parent_value")))) + { + $options_parent_values[$index] = weechat::infolist_string($infolist, "parent_value"); + } + iset_refresh_line($index); + iset_title() if ($option_name eq "iset.look.show_current_line"); + } + else + { + iset_full_refresh(1); # if not found, refresh fully without clearing buffer + weechat::print_y($iset_buffer, $#options_names + 1, ""); + } + weechat::infolist_free($infolist); + } +} + sub iset_config_cb { my ($data, $option_name, $value) = ($_[0], $_[1], $_[2]); @@ -724,25 +854,14 @@ sub iset_config_cb if ($index >= 0) { # refresh info about changed option - my $infolist = weechat::infolist_get("option", "", $option_name); - if ($infolist) + iset_refresh_option($option_name, $index); + # refresh any other option having this changed option as parent + foreach my $i (0 .. $#options_names) { - weechat::infolist_next($infolist); - if (weechat::infolist_fields($infolist)) - { - $options_types[$index] = weechat::infolist_string($infolist, "type"); - $options_values[$index] = weechat::infolist_string($infolist, "value"); - $options_default_values[$index] = weechat::infolist_string($infolist, "default_value"); - $options_is_null[$index] = weechat::infolist_integer($infolist, "value_is_null"); - iset_refresh_line($index); - iset_title() if ($option_name eq "iset.look.show_current_line"); - } - else + if ($options_parent_names[$i] eq $option_name) { - iset_full_refresh(1); # if not found, refresh fully without clearing buffer - weechat::print_y($iset_buffer, $#options_names + 1, ""); + iset_refresh_option($options_names[$i], $i); } - weechat::infolist_free($infolist); } } else @@ -817,20 +936,37 @@ sub iset_cmd_cb { # f/s option =value # option =value - $search_mode = 2; + $search_mode = 2; # grep on option if ( $array_count >= 2 and $cmd_array[0] ne "f" or $cmd_array[0] ne "s") { if ( defined $cmd_array[1] and substr($cmd_array[1], 0, 1) eq weechat::config_string($options_iset{"value_search_char"}) or defined $cmd_array[2] and substr($cmd_array[2], 0, 1) eq weechat::config_string($options_iset{"value_search_char"}) ) { - $search_mode = 3; + $search_mode = 3; # grep on option and value $search_value = substr($cmd_array[1], 1); # cut value_search_char $search_value = substr($cmd_array[2], 1) if ( $array_count > 2); # cut value_search_char } } + + # show all diff values + if ( $args eq "d") + { + $search_mode = 4; + $search_value = "*"; + $args = $search_value; + } + if ( $array_count >= 2 and $cmd_array[0] eq "d") + { + $search_mode = 5; + $search_value = substr($cmd_array[1], 0); # cut value_search_char + $search_value = substr($cmd_array[2], 0) if ( $array_count > 2); # cut value_search_char + $args = $search_value; + } + iset_create_filter($args); $filter_set = 1; my $ptrbuf = weechat::buffer_search($LANG, $PRGNAME); + if ($ptrbuf eq "") { iset_init(); @@ -1421,7 +1557,8 @@ $wee_version_number = weechat::info_get("version_number", "") || 0; iset_config_init(); iset_config_read(); -weechat::hook_command($PRGNAME, "Interactive set", "f <file> || s <section> || [=][=]<text>", +weechat::hook_command($PRGNAME, "Interactive set", "d <text> || f <file> || s <section> || [=][=]<text>", + "d <text> : show only changed options\n". "f file : show options for a file\n". "s section: show options for a section\n". "text : show options with 'text' in name\n". @@ -1442,6 +1579,7 @@ weechat::hook_command($PRGNAME, "Interactive set", "f <file> || s <section> || [ "text,enter : set a new filter using command line (use '*' to see all options)\n". "alt+'v' : toggle help bar on/off\n". "alt+'p' : toggle option \"show_plugin_description\" on/off\n". + "q : as input in iset buffer to close it\n". "\n". "Mouse actions:\n". "wheel up/down : move cursor up/down\n". @@ -1450,8 +1588,8 @@ weechat::hook_command($PRGNAME, "Interactive set", "f <file> || s <section> || [ "right button + drag left/right: increase/decrease value (for integer or color)\n". "\n". "Examples:\n". - " show options for file 'weechat'\n". - " /iset f weechat\n". + " show changed options in 'aspell' plugin\n". + " /iset d aspell\n". " show options for file 'irc'\n". " /iset f irc\n". " show options for section 'look'\n". diff --git a/weechat/python/autojoin_on_invite.py b/weechat/python/autojoin_on_invite.py index cdaeaf0..45adab5 100644 --- a/weechat/python/autojoin_on_invite.py +++ b/weechat/python/autojoin_on_invite.py @@ -20,6 +20,8 @@ # (this script requires WeeChat 0.3.0 or newer) # # History: +# 2015-10-11, Simmo Saan <simmo.saan@gmail.com> +# version 0.6: allow joining channels with keys in autojoin # 2013-12-21, Sebastien Helleu <flashcode@flashtux.org> # version 0.5: fix parsing of INVITE message # 2013-11-28, sakkemo <scajanus@gmail.com> @@ -36,7 +38,7 @@ import re SCRIPT_NAME = "autojoin_on_invite" SCRIPT_AUTHOR = "xt <xt@bash.no>" -SCRIPT_VERSION = "0.5" +SCRIPT_VERSION = "0.6" SCRIPT_LICENSE = "GPL3" SCRIPT_DESC = "Auto joins channels when invited" @@ -49,6 +51,7 @@ settings = { 'ignore_nicks': '', # comma separated list of nicks #that we will not accept auto invite from 'ignore_channels': '', # comma separated list of channels to not join + 'autojoin_key': 'on', # use channel keys from server's autojoin list } if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, @@ -59,6 +62,20 @@ if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, w.hook_signal('*,irc_in2_invite', 'invite_cb', '') +def join(server, channel): + key = None + + if w.config_string_to_boolean(w.config_get_plugin('autojoin_key')): + autojoin = w.config_string(w.config_get('irc.server.%s.autojoin' % server)).split(' ', 1) + + if len(autojoin) > 1: # any keys specified + autojoin_keys = dict(zip(autojoin[0].split(','), autojoin[1].split(','))) + key = autojoin_keys.get(channel) # defaults to None when not set + + if key: + w.command('', '/quote -server %s JOIN %s %s' % (server, channel, key)) + else: + w.command('', '/quote -server %s JOIN %s' % (server, channel)) def invite_cb(data, signal, signal_data): server = signal.split(',')[0] # EFNet,irc_in_INVITE @@ -69,7 +86,7 @@ def invite_cb(data, signal, signal_data): if from_nick in w.config_get_plugin('whitelist_nicks').split(',') or channel in w.config_get_plugin('whitelist_channels').split(','): w.prnt('', 'Automatically joining %s on server %s, invitation from %s (whitelist).' \ %(channel, server, from_nick)) - w.command('', '/quote -server %s JOIN %s' % (server, channel)) + join(server, channel) else: w.prnt('', 'Ignoring invite from %s to channel %s. Neither inviter nor channel in whitelist.' %(from_nick, channel)) @@ -77,7 +94,7 @@ def invite_cb(data, signal, signal_data): if from_nick in w.config_get_plugin('whitelist_nicks').split(','): w.prnt('', 'Automatically joining %s on server %s, invitation from %s (whitelist).' \ %(channel, server, from_nick)) - w.command('', '/quote -server %s JOIN %s' % (server, channel)) + join(server, channel) else: w.prnt('', 'Ignoring invite from %s to channel %s. Inviter not in whitelist.' %(from_nick, channel)) @@ -85,7 +102,7 @@ def invite_cb(data, signal, signal_data): if channel in w.config_get_plugin('whitelist_channels').split(','): w.prnt('', 'Automatically joining %s on server %s, invitation from %s (whitelist).' \ %(channel, server, from_nick)) - w.command('', '/quote -server %s JOIN %s' % (server, channel)) + join(server, channel) else: w.prnt('', 'Ignoring invite from %s to channel %s. Channel not in whitelist.' %(from_nick, channel)) @@ -97,6 +114,6 @@ def invite_cb(data, signal, signal_data): else: w.prnt('', 'Automatically joining %s on server %s, invitation from %s.' \ %(channel, server, from_nick)) - w.command('', '/quote -server %s JOIN %s' % (server, channel)) + join(server, channel) return w.WEECHAT_RC_OK diff --git a/weechat/python/colorize_nicks.py b/weechat/python/colorize_nicks.py index 03dac1d..506a3ab 100644 --- a/weechat/python/colorize_nicks.py +++ b/weechat/python/colorize_nicks.py @@ -21,6 +21,8 @@ # # # History: +# 2016-05-01, Simmo Saan <simmo.saan@gmail.com> +# version 22: invalidate cached colors on hash algorithm change # 2015-07-28, xt # version 21: fix problems with nicks with commas in them # 2015-04-19, xt @@ -75,7 +77,7 @@ w = weechat SCRIPT_NAME = "colorize_nicks" SCRIPT_AUTHOR = "xt <xt@bash.no>" -SCRIPT_VERSION = "21" +SCRIPT_VERSION = "22" SCRIPT_LICENSE = "GPL" SCRIPT_DESC = "Use the weechat nick colors in the chat area" @@ -339,6 +341,7 @@ if __name__ == "__main__": w.hook_modifier('weechat_print', 'colorize_cb', '') # Hook config for changing colors w.hook_config('weechat.color.chat_nick_colors', 'populate_nicks', '') + w.hook_config('weechat.look.nick_color_hash', 'populate_nicks', '') # Hook for working togheter with other scripts (like colorize_lines) w.hook_modifier('colorize_nicks', 'colorize_cb', '') # Hook for modifying input |