--- ChivanetModcon/modcon 2025/02/01 03:17:46 1.5 +++ ChivanetModcon/modcon 2025/02/04 18:55:12 1.6 @@ -4,13 +4,16 @@ # ChivaNet Moderator Console # Copyright (C) 2025 Coherent Logic Development LLC # -# $Id: modcon,v 1.5 2025/02/01 03:17:46 snw Exp $ +# $Id: modcon,v 1.6 2025/02/04 18:55:12 snw Exp $ # # Author: Serena Willis # # Licensed AGPL-3.0 # # $Log: modcon,v $ +# Revision 1.6 2025/02/04 18:55:12 snw +# Updates +# # Revision 1.5 2025/02/01 03:17:46 snw # Fix session list # @@ -33,6 +36,7 @@ use JSON; use Data::Dumper; use Term::ReadKey; use Getopt::Long; +use Text::Glob qw(match_glob); my $sso_account = ''; my $apikey = ''; @@ -251,30 +255,44 @@ sub send_im { } sub ls { - my ($description, @entries) = @_; + my ($description, $match, @entries) = @_; + + if($match eq "") { + $match = '*'; + } + print "Directory of [$description] matching \'$match\':\n\n"; + my @sorted = sort(@entries); my $maxlen = 0; + foreach my $entry (@sorted) { my $len = length($entry); if ($len > $maxlen) { $maxlen = $len; } } + $maxlen = $maxlen + 2; + my $ct = $#sorted + 1; foreach my $entry (@sorted) { - if($col + $maxlen >= $wchar) { - print "\n"; - $col = 0; + if(match_glob($match, $entry)) { + if($col + $maxlen >= $wchar) { + print "$entry\n"; + $col = 0; + } + else { + printf("%-$maxlen\s", $entry); + $col = $col + $maxlen; + } } else { - printf("%-$maxlen\s", $entry); - $col = $col + $maxlen; - } - } - print "\n$ct items in $description\n"; + $ct = $ct - 1; + } + } + print "\n\n$ct matching items in directory\n"; } sub prompt { @@ -422,8 +440,8 @@ sub prompt { @path = @oldpath; } else { - $mode = "SSO"; - @path = ('sso', $user); + $mode = "RAS"; + @path = ('ras', $user); } } else { @@ -489,7 +507,12 @@ sub prompt { print "sessions: must be in ras mode\n"; } else { - ls "active RAS sessions", list_ras_sessions(); + if($cmd[1]) { + ls "active RAS sessions", $cmd[1], list_ras_sessions(); + } + else { + ls "active RAS sessions", '*', list_ras_sessions(); + } } } elsif ($cmd[0] eq "lssn") { @@ -498,7 +521,12 @@ sub prompt { } else { my @sns = list_ras_screennames($user); - ls "RAS screen names for $user", @sns; + if($cmd[1]) { + ls "RAS screen names for $user", $match, @sns; + } + else { + ls "RAS screen names for $user", '*', @sns; + } } } elsif ($cmd[0] eq "ls") { @@ -530,7 +558,12 @@ sub prompt { my $col = 0; my $pstr = join('/', @path); my $pfin = "/$pstr"; - ls $pfin, @entries; + if($cmd[1]) { + ls $pfin, $cmd[1], @entries; + } + else { + ls $pfin, '*', @entries; + } } }