|
1 | 1 | #
|
2 | 2 | # Copyright (c) 2010-2023 by Nils Görs <weechatter@arcor.de>
|
| 3 | +# Copyright (c) 2025 by Kamil Wiśniewski <tomteipl@gmail.com> |
3 | 4 | #
|
4 | 5 | # display the status and visited buffers of your buddies in a buddylist bar
|
5 | 6 | #
|
|
15 | 16 | #
|
16 | 17 | # You should have received a copy of the GNU General Public License
|
17 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>.
|
18 |
| -# |
| 19 | +# 2.3 : fix (get nickname) function and remake it to use "irc_message_parse". Fixed "completion_list_add" for compatibility with WeeChat >= 2.9 |
19 | 20 | # 2.2 : fix: make /whois lower-case
|
20 | 21 | # 2.1 : add compatibility with WeeChat >= 3.2 (XDG directories)
|
21 | 22 | # 2.0 : make call to bar_new compatible with WeeChat >= 2.9
|
|
38 | 39 | # 1.2.1 : fixed: bitlbee_service was not set, for new added buddy
|
39 | 40 | # v1.2 : added: function "hide_bar = always" (requested by: Emralegna)
|
40 | 41 | # : added: buddies will be separated by protocol (msn/jabber etc.pp.) on bitlbee server (requested by: ArcAngel)
|
41 |
| -# : added: options "text.online", "text.away", "text.offline" (maybe usefull for color-blind people:-) |
| 42 | +# : added: options "text.online", "text.away", "text.offline" (maybe usefull for color-blind people:-) |
42 | 43 | # : added: function weechat_config_set_desc_plugin() (only for weechat >= v0.3.5)
|
43 | 44 | # v1.1 : fixed: offline users on bitlbee were shown as away. (reported and beta-testing by javuchi)
|
44 | 45 | # v1.0 : redirection implemented (needs weechat >= 0.3.4). Now, its a real buddylist
|
|
72 | 73 | # 0.4 : added option "sort"
|
73 | 74 | # 0.3 : remove spaces for indenting when bar position is top/bottom
|
74 | 75 | # hook_config when settings changed.
|
75 |
| -# 0.2 : work-around for crash when searching nick in buffer without nicklist (function nicklist_search_nick) removed |
| 76 | +# 0.2 : work-around for crash when searching nick in buffer without nicklist (function nicklist_search_nick) removed |
76 | 77 | # 0.1 : initial release
|
77 | 78 | #
|
78 | 79 | # Development is currently hosted at
|
|
85 | 86 | use strict;
|
86 | 87 |
|
87 | 88 | my $prgname = "buddylist";
|
88 |
| -my $version = "2.2"; |
| 89 | +my $version = "2.3"; |
89 | 90 | my $description = "display status from your buddies a bar-item.";
|
90 | 91 |
|
91 | 92 | # -------------------------------[ config ]-------------------------------------
|
|
218 | 219 | hook_timer_and_redirect() if ($default_options{check_buddies} ne "0" and $default_options{use_redirection} eq "on");
|
219 | 220 |
|
220 | 221 | weechat::hook_command($prgname, $description,
|
221 |
| - "<add>[nick_1 [... nick_n]] | <del>[nick_1 [... nick_n]]", |
| 222 | + "<add>[nick_1 [... nick_n]] | <del>[nick_1 [... nick_n]]", |
222 | 223 |
|
223 | 224 | "<add> [nick(s)] add nick(s) to the buddylist\n".
|
224 | 225 | "<del> [nick(s)] delete nick(s) from the buddylist\n".
|
@@ -446,7 +447,7 @@ sub build_buddylist{
|
446 | 447 |
|
447 | 448 | # sorted by status first, then bitlbee_service and nick case insensitiv at least
|
448 | 449 | # foreach my $n (sort { $nick_structure{$s}{$a}->{status} cmp $nick_structure{$s}{$b}->{status}} (sort {uc($a) cmp uc($b)} (sort keys(%{$nick_structure{$s}})))){
|
449 |
| - |
| 450 | + |
450 | 451 | my $status_output = "";
|
451 | 452 | my $status_output_copy = "";
|
452 | 453 | foreach my $n (sort { $nick_structure{$s}{$a}->{status} cmp $nick_structure{$s}{$b}->{status}} (sort { $nick_structure{$s}{$a}->{bitlbee_service} cmp $nick_structure{$s}{$b}->{bitlbee_service}} (sort {uc($a) cmp uc($b)} (sort keys(%{$nick_structure{$s}})) ) ) ){
|
@@ -1492,9 +1493,27 @@ sub parse_redirect{
|
1492 | 1493 | }
|
1493 | 1494 | }
|
1494 | 1495 |
|
1495 |
| - # get nick name |
1496 |
| - my $rfc_311 = " 311 "; # nick username address * :info |
1497 |
| - my (undef, undef, undef, $nickname2, undef) = split /\s+/, $args, 5 if ($args =~ /($rfc_311)/); # get nickname |
| 1496 | +# get nick name ($rfc_311) |
| 1497 | +my $nickname2; |
| 1498 | +my $parsed_hash = weechat::info_get_hashtable("irc_message_parse", { "message" => $args }); |
| 1499 | +if ($parsed_hash) { |
| 1500 | + my $parsed_message = $parsed_hash->{'message_without_tags'}; |
| 1501 | + if ($parsed_message =~ /^\S+ 311 \S+ (\S+)/) { # gets the nickname |
| 1502 | + $nickname2 = $1; |
| 1503 | + if ($debug_redir_out eq "on") { |
| 1504 | + weechat::print("", "Parsed nickname: $nickname2"); # DEBUG |
| 1505 | + } |
| 1506 | + } else { |
| 1507 | + if ($debug_redir_out eq "on") { |
| 1508 | + weechat::print("", "Failed to extract nickname from: $parsed_message"); # DEBUG |
| 1509 | + } |
| 1510 | + } |
| 1511 | +} else { |
| 1512 | + if ($debug_redir_out eq "on") { |
| 1513 | + weechat::print("", "Failed to parse: $args"); # DEBUG |
| 1514 | + } |
| 1515 | +} |
| 1516 | + |
1498 | 1517 |
|
1499 | 1518 | # check nick away....
|
1500 | 1519 | $args =~ /($rfc_301)/;
|
@@ -1529,7 +1548,7 @@ sub buddy_list_completion_cb{
|
1529 | 1548 | $server = $channel if ( $server eq "server"); # are we in server buffer?
|
1530 | 1549 |
|
1531 | 1550 | foreach my $nickname ( keys %{$nick_structure{$server}} ) {
|
1532 |
| - weechat::hook_completion_list_add($completion, $nickname,1, weechat::WEECHAT_LIST_POS_SORT); |
| 1551 | + weechat::completion_list_add($completion, $nickname,1, weechat::WEECHAT_LIST_POS_SORT); |
1533 | 1552 | }
|
1534 | 1553 |
|
1535 | 1554 | return weechat::WEECHAT_RC_OK;
|
|
0 commit comments