Control: tags -1 +patch

On 2018-05-21 16:01:59, Yves-Alexis Perez wrote:
> subject mostly says it all, but it'd be nice if KGB could support
> password-protected IRC channels for notifications.

The library backing KGB does support it, so it seems it's only a matter
of a few lines patch:

https://salsa.debian.org/kgb-team/kgb/-/merge_requests/8

Also attached.

Please test and report back here or, preferably, in the above merge request.

a.

-- 
The secret of life is to have no fear; it's the only way to function.
                        - Stokely Carmichael
>From e904a049138a0cbae7ae9e72ecc0f65f9579837f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= <anar...@debian.org>
Date: Tue, 12 Dec 2023 16:33:35 -0500
Subject: [PATCH] channel secret support (Closes: #899245)

---
 script/kgb-bot | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/script/kgb-bot b/script/kgb-bot
index 34ffdf5..6bc422a 100755
--- a/script/kgb-bot
+++ b/script/kgb-bot
@@ -296,7 +296,7 @@ sub read_conf ($) {
         die "Missing channel name at channel\n" unless ( $_->{name} );
         die "Invalid network at channel " . $_->{name} . "\n"
             unless ( $_->{network} and $conf->{networks}{ $_->{network} } );
-        push @{ $conf->{networks}{ $_->{network} }{channels} }, $_->{name};
+        $conf->{networks}{ $_->{network} }{channels}{$_->{name}} = $_->{secret};
         my $chanid = KGB->get_chanid( $_->{network}, $_->{name} );
         die "Invalid repos key at channel $chanid\n"
             unless $_->{broadcast}
@@ -947,8 +947,8 @@ sub _irc_reconnect {
         }
         else {
             my ( %newchan, %oldchan, %allchan );
-            %newchan = map( { $_ => 1 } @{ $new->{channels} } );
-            %oldchan = map( { $_ => 1 } @{ $old->{channels} } );
+            %newchan = map( { $_ => 1 } %{ $new->{channels} } );
+            %oldchan = map( { $_ => 1 } %{ $old->{channels} } );
             %allchan = ( %newchan, %oldchan );
             foreach my $chan ( keys %allchan ) {
                 if ( $newchan{$chan} and !$oldchan{$chan} ) {
@@ -1094,7 +1094,8 @@ sub add_channel ($$$) {
         unless (exists $KGB::config->{networks}{$network});
     return if (exists $KGB::config->{chanidx}{$chanid});
 
-    push @{ $KGB::config->{networks}{$network}{channels} }, $channel;
+    # secret-less
+    $KGB::config->{networks}{$network}{channels}{$channel} = '';
     $KGB::config->{chanidx}{$chanid} = {
         name => $channel,
         network => $network,
@@ -1124,11 +1125,12 @@ sub irc_001 {
     my ( $kernel, $sender ) = @_[ KERNEL, SENDER ];
     my $net = get_net($sender);
     my $channels = $KGB::config->{networks}{$net}{channels};
+    my @channel_names = keys %{$channels};
 
     # Get the component's object at any time by accessing the heap of
     # the SENDER
     KGB->out( "Connected to $net (", $sender->get_heap->server_name(), ")\n" );
-    KGB->out( "Joining @$channels...\n" ) if ($channels);
+    KGB->out( "Joining @channel_names...\n" ) if ($channels);
     undef;
 }
 
-- 
GitLab

Reply via email to