]> git.99rst.org Git - irssi-scripts.irssi.org.git/commitdiff
Added filters
authorBruno Cattáneo <redacted>
Fri, 22 Dec 2017 18:07:53 +0000 (15:07 -0300)
committerBruno Cattáneo <redacted>
Fri, 22 Dec 2017 18:07:53 +0000 (15:07 -0300)
scripts/toilet.pl

index 16d35f5ea533549537acc09c9ecf05b044d35633..36548d77db006a57211fa64fd39192f542613193 100644 (file)
@@ -2,6 +2,9 @@
 # 2017-09-09 bcattaneo:
 #  - initial release
 #
+# 2017-12-22 bcattaneo:
+#  - Added filters
+#
 
 use IPC::Open3;
 use strict;
@@ -13,56 +16,68 @@ use Irssi qw(command_bind active_win);
 #      /toilet [message]
 #
 # Settings:
-#      /set toilet_gay [ON/OFF]
+#      /set toilet_filters [Filters (separated with ":")]
 #      /set toilet_font [Font name]
 #
+# Example:
+#      /set toilet_filters border:metal
+#      /set toilet_font small
+#      /toilet Hello!
+#
 
-our $VERSION = '1.0.0';
+our $VERSION = '1.1.0';
 our %IRSSI = (
-  authors     => 'bcattaneo',
-  contact     => 'c@ttaneo.uy',
-  name        => 'toilet',
-  url         => 'http://github.com/bcattaneo',
-  description => 'Simple toilet implementation for Irssi',
-  license     => 'Public Domain',
-  #changed     => "2017-09-09",
+       authors     => 'bcattaneo',
+       contact     => 'c@ttaneo.uy',
+       name        => 'toilet',
+       url         => 'http://github.com/bcattaneo',
+       description => 'Simple toilet implementation for Irssi',
+       license     => 'Public Domain',
+       changed     => "2017-12-22",
 
-  # safe implementation borrowed from figlet.pl:
+       # safe implementation borrowed from figlet.pl:
        # Author: https://juerd.nl/site.plp/irssi
-  # https://github.com/irssi/scripts.irssi.org/blob/master/scripts/figlet.pl
-
+       # https://github.com/irssi/scripts.irssi.org/blob/master/scripts/figlet.pl
+       
 );
 
-Irssi::settings_add_bool('toilet', 'toilet_gay' => 0);
+Irssi::settings_add_str('toilet', 'toilet_filters' => '');
+#Irssi::settings_add_bool('toilet', 'toilet_gay' => 0);
 Irssi::settings_add_str('toilet', 'toilet_font' => '');
 
-command_bind(
-  toilet => sub {
-    my ($msg) = @_;
-    my @toilet;
-    my $i = 0;
-    my @parm;
-    push(@parm,'toilet');
-    push(@parm,'--irc');
-    my $gay = Irssi::settings_get_bool('toilet_gay');
-    my $font = Irssi::settings_get_str('toilet_font');
-    if ($gay == 1) {
-      push(@parm,'--gay');
-    }
-    if ($font ne '') {
-      push(@parm,'-f'.$font);
-    }
-    my $pid = open3(undef, *TOILET, *TOILET, @parm, $msg);
-    while (<TOILET>) {
-      chomp;
-      $toilet[$i++] .= $_;
-    }
-    close TOILET;
-    waitpid $pid, 0;
-    for (@toilet) {
-      (my $copy = $_) =~ s/\cC\d*(?:,\d*)?|[\cB\cO\c_]//g;
-      next unless $copy =~ /\S/;
-      active_win->command("say $_");
-    }
-  }
-);
+command_bind
+(
+       toilet => sub
+       {
+               my ($msg) = @_;
+               my @toilet;
+               my $i = 0;
+               my @parm;
+               push(@parm,'toilet');
+               push(@parm,'--irc');
+               my $filters = Irssi::settings_get_str('toilet_filters');
+               my $font = Irssi::settings_get_str('toilet_font');
+               if ($filters ne '')
+               {
+                       push(@parm,'-F'.$filters);
+               }
+               if ($font ne '')
+               {
+                       push(@parm,'-f'.$font);
+               }
+               my $pid = open3(undef, *TOILET, *TOILET, @parm, $msg);
+               while (<TOILET>)
+               {
+                       chomp;
+                       $toilet[$i++] .= $_;
+               }
+               close TOILET;
+               waitpid $pid, 0;
+               for (@toilet)
+               {
+                       (my $copy = $_) =~ s/\cC\d*(?:,\d*)?|[\cB\cO\c_]//g;
+                       next unless $copy =~ /\S/;
+                       active_win->command("say $_");
+               }
+       }
+);
\ No newline at end of file
git clone https://git.99rst.org/PROJECT