From 0a8b0005690eb43956513d3e6cb3d95a7834abc9 Mon Sep 17 00:00:00 2001 From: dms Date: Sat, 3 Feb 2001 12:51:20 +0000 Subject: [PATCH] fixed '.chanset' code. git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@313 c11ca15a-4712-0410-83d8-924469b57eb5 --- src/Modules/UserDCC.pl | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/src/Modules/UserDCC.pl b/src/Modules/UserDCC.pl index 6967881..175966b 100644 --- a/src/Modules/UserDCC.pl +++ b/src/Modules/UserDCC.pl @@ -461,21 +461,21 @@ sub userDCC { # +chan. if ($message =~ /^(chanset|\+chan)(\s+(.*?))?$/) { - my $cmd = $1; - my $args = $3; + my $cmd = $1; + my $args = $3; + my $no_chan = 0; if (!defined $args) { &help($cmd); return; } - my ($chan); + my $chan; if ($args =~ s/^($mask{chan})\s*//) { $chan = $1; - &DEBUG("chan => $chan."); } else { - &DEBUG("no chan arg; setting to default."); $chan = "_default"; + $no_chan = 1; } my($what,$val) = split /[\s\t]+/, $args, 2; @@ -500,24 +500,44 @@ sub userDCC { my $update = 0; ### TODO: $what can be undefined. fix it! - if ($what =~ /^\+(\S+)/) { + if ($what =~ s/^\+(\S+)/$1/) { my $was = $chanconf{$chan}{$1}; + if ($was eq "1") { + &pSReply("setting $what for $chan already 1."); + return; + } + $was = ($was) ? "; was '$was'" : ""; - &pSReply("Setting $1 for $chan to '1'$was."); + &pSReply("Setting $what for $chan to '1'$was."); - $chanconf{$chan}{$1} = 1; + $chanconf{$chan}{$what} = 1; $update++; - } elsif ($what =~ /^\-(\S+)/) { + } elsif ($what =~ s/^\-(\S+)/$1/) { my $was = $chanconf{$chan}{$1}; + # hrm... + if (!defined $was) { + &pSReply("setting $1 for $chan is not set."); + return; + } + + if ($was eq "0") { + &pSReply("setting $1 for $chan already 0."); + return; + } + $was = ($was) ? "; was '$was'" : ""; - &pSReply("Setting $1 for $chan to '0'$was."); + &pSReply("Setting $what for $chan to '0'$was."); - $chanconf{$chan}{$1} = 0; + $chanconf{$chan}{$what} = 0; $update++; } elsif (defined $val) { my $was = $chanconf{$chan}{$what}; + if ($was eq $val) { + &pSReply("setting $1 for $chan already '$val'."); + return; + } $was = ($was) ? "; was '$was'" : ""; &pSReply("Setting $what for $chan to '$val'$was."); -- 2.39.2