From f26eeb0ff4c4dc35f972adacb7213fb0e6d9cd3a Mon Sep 17 00:00:00 2001 From: Gregory Bartholomew Date: Jun 18 2022 02:18:19 +0000 Subject: Improve proposed/agreed readout --- diff --git a/bot/commands.pm b/bot/commands.pm index 1910a2e..403e0c8 100644 --- a/bot/commands.pm +++ b/bot/commands.pm @@ -57,11 +57,8 @@ use constant PUBLISH => 'publish'; # the name of the custom card attribute to get the assigned editor from use constant EDITOR => 'editor'; -# the format to use for the publication dates in the schedule readout -use constant FORMAT => '%a %d %b %Y'; - # the key for the 'agreed' readout -use constant KEY => String::Tagged->from_sprintf(' {šŸ”¹= %s, šŸ”ø= %s }', +use constant KEY => String::Tagged->from_sprintf("\x{2003}{šŸ”¹= %s, šŸ”ø= %s }", String::Tagged->new_tagged( 'forum calendar update succeeded', 'italic', 1 ), @@ -73,10 +70,19 @@ use constant KEY => String::Tagged->from_sprintf(' {šŸ”¹= %s, šŸ”ø= %s }', # returns the due date in a custom format # this is a private subroutine my sub _fmtdd { - my $date; - my $zero = '??? ?? ??? ????'; - - return $zero unless $_[0] && $_[0] =~ m{(\d{4})-(\d{2})-(\d{2})}a; + my $obj; + my @str = ("\x{1f15e}", "0000-00-00"); + my $day = { + '0' => "\x{1f164}", # šŸ…¤ + '1' => "\x{1f15c}", # šŸ…œ + '2' => "\x{1f163}", # šŸ…£ + '3' => "\x{1f166}", # šŸ…¦ + '4' => "\x{1f161}", # šŸ…” + '5' => "\x{1f155}", # šŸ…• + '6' => "\x{1f162}", # šŸ…¢ + }; + + return $str unless $_[0] && $_[0] =~ m{(\d{4})-(\d{2})-(\d{2})}a; eval { $date = DateTime->new( 'year' => $1, @@ -85,9 +91,14 @@ my sub _fmtdd { 'time_zone' => 0, ); }; - warn $! if $@; + if ($@) { + warn $!; + } else { + $str[0] = $day->{$date->strftime('%w')}; + $str[1] = $date->strftime('%F'); + } - return ($@) ? $zero : $date->strftime(FORMAT); + return @str; } # returns the schedule as set in kanban @@ -95,30 +106,33 @@ my sub _fmtdd { # - article titles in italic text # this is a private subroutine my sub _sched { - my $delim = ' ‖ '; my $start = shift; - my @cards = @_; - my $sched = String::Tagged->new('#' . $start . ' PUBLISHING SCHEDULE: '); + my @cards = sort { card($a, PUBLISH) cmp card($b, PUBLISH) } @_; + my $sched = String::Tagged->new('#' . $start . ' '); + + $sched .= String::Tagged->new_tagged('PUBLISHING SCHEDULE', 'bold', 1); + $sched .= ":\x{2003}"; return $sched . 'There are no articles to be edited.' unless @cards; - my $style = String::Tagged->new('%s: #%s %s%s (editor: %s)'); + my $style = String::Tagged->new('%s %s %s: %s (editor: %s)%s'); while ($_ = shift @cards) { - my ($i, $subj, $date, $edtr) = card $_, 'id', 'title', PUBLISH, EDITOR; + my ($i, $subj, $publ, $edtr) = card $_, 'id', 'title', PUBLISH, EDITOR; + my ($day, $date) = _fmtdd($publ); + my $offset = index($edtr, '@')+1; $sched .= String::Tagged->from_sprintf($style, - String::Tagged->new_tagged( - _fmtdd($date), 'bold', 1 - ), + $day, + $date, $i, String::Tagged->new_tagged( $subj, 'italic', 1 ), + substr($edtr, $offset, 1) . "\x{2060}" . substr($edtr, $offset+1), (($start eq 'agreed') ? post($_) : ''), - $edtr, ); } continue { - # add a separator if there are more cards - $sched .= $delim if @cards; + # add a space if there are more cards + $sched .= "\x{2003}" if @cards; } return $sched; @@ -212,7 +226,7 @@ sub eotw { return sprintf('#info %s will be editor of the week starting %s', $user, - $date->strftime(FORMAT), + $date->strftime('%F'), ); } diff --git a/bot/commands/matrix.pm b/bot/commands/matrix.pm index 2397127..53d62bd 100644 --- a/bot/commands/matrix.pm +++ b/bot/commands/matrix.pm @@ -66,6 +66,8 @@ sub colorize { $$html =~ s{\(fpca: unsigned\)}{$&}g; $$html =~ s{\(fpca: unknown\)}{$&}g; $$html =~ s{\(fpca: signed\)}{$&}g; + + $$html =~ s{[\x{1f150}-\x{1f169}]}{$&}g; } sub event_handler { diff --git a/bot/commands/pagure.pm b/bot/commands/pagure.pm index 7be5bf9..d6ff5cc 100644 --- a/bot/commands/pagure.pm +++ b/bot/commands/pagure.pm @@ -158,7 +158,7 @@ sub card { return $ret; } else { - return @ret; + return (@ret == 1) ? $ret[0] : @ret; } }