@@ -6,6 +6,7 @@ package Synergy::VestaUtil;
66use experimental qw( signatures) ;
77use utf8;
88
9+ use List::Util qw( uniq) ;
910use MIME::Base64 ();
1011
1112my %CHAR_FOR = (
@@ -182,8 +183,8 @@ sub _text_to_board ($self, $text) {
182183sub text_to_board ($self , $text ) {
183184 $text = uc $text ;
184185
185- unless ( $ self-> _text_is_valid ($text )) {
186- return (undef , " Sorry, I can't post that to the board. " );
186+ if ( my $text_problem = $ self-> _problem_with_text ($text )) {
187+ return (undef , $text_problem );
187188 }
188189
189190 my $post = $self -> _text_to_board($text );
@@ -195,11 +196,19 @@ sub text_to_board ($self, $text) {
195196 return $post ;
196197}
197198
198- sub _text_is_valid ($self , $text ) {
199+ sub _problem_with_text ($self , $text ) {
200+ if (length $text > 6 * 22) {
201+ return " That text is too long. The limit is 132 characters (six rows of 22)."
202+ }
203+
199204 # This feels pretty thing. -- rjbs, 2021-05-31
200- return if $text =~ m { [^ 0-9A-Z!@#\$\(\)\-\+ &=;:'"%,./?°🟥🟧🟨🟩🟦🟪⬜️]} ;
201- return if length $text > 6 * 22;
202- return 1;
205+ my $unwanted = $text =~ s { [ 0-9A-Z!@#\$\(\)\-\+ &=;:'"%,./?°🟥🟧🟨🟩🟦🟪⬜️]} {} gr ;
206+
207+ return unless $unwanted ;
208+
209+ $unwanted = join q{ } , sort (uniq(split //, $unwanted ));
210+
211+ return " That text contains characters you can't use. Here they are: $unwanted " ;
203212}
204213
2052141;
0 commit comments