zaiger

gay.pl for irssi

Nov 17th, 2014
1,390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 131.14 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2.  
  3. # a suite of text filters to annoy people :D
  4. #
  5. # author: cj_ <[email protected]>
  6. #
  7. # "If used sparingly, and in good taste, ASCII art generally
  8. # is very well-received !"
  9. # -- Some Sucker
  10. #
  11. # credits:
  12. # ben for banner leetness
  13. # Pi for the popeye filter
  14. # j0no for entirety of 8.7 release features and bugfixes
  15. # zb for adding ansi color support and putting this in ports :D
  16. # sisko for the original color script
  17. # various ideas from: tosat, jej, twid, cappy, rob
  18. # uke for the inspiration for the checker
  19. # hlprmnky for the jigs and for debugging
  20. # various stolen things: emacs spook file, jwz's scrambler script
  21. #
  22. # (this whole thing needs to be rewritten)
  23. #
  24. # Copyright (C) 2003-2008 cj_ <[email protected]>
  25. #
  26. # This program is free software; you can redistribute it and/or
  27. # modify it under the terms of the GNU General Public License
  28. # as published by the Free Software Foundation; either version 2
  29. # of the License, or (at your option) any later version.
  30. #
  31. # This program is distributed in the hope that it will be useful,
  32. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  33. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  34. # GNU General Public License for more details.
  35. #
  36. # You should have received a copy of the GNU General Public License
  37. # along with this program; if not, write to the Free Software
  38. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  39. #
  40.  
  41. use strict;
  42. use Text::Wrap;
  43. use IPC::Open3;
  44. use vars qw/$VERSION %IRSSI $SPLASH $NAME $CONTEXT $OUTPUT/;
  45. use vars qw/$BASH_PROMPT $ANSI/;
  46.  
  47. $| = 1;
  48.  
  49. $NAME = 'gay';
  50. $VERSION = '13.0';
  51.  
  52. %IRSSI = (
  53. name => $NAME,
  54. version => $VERSION,
  55. author => 'cj_',
  56. contact => '[email protected]',
  57. download => 'http://gruntle.org/projects/irssi',
  58. description => 'a lot of annoying ascii color/art text filters',
  59. license => 'GPL',
  60. );
  61.  
  62. ##########################################
  63. # Figure out where we are being run from #
  64. # and set up the environment properly #
  65. ##########################################
  66.  
  67. if ($ENV{'REQUEST_METHOD'}) {
  68. # cgi.. color routine should use
  69. # markup instead of ansi or mirc
  70. $CONTEXT = 'cgi';
  71. $OUTPUT = 'html';
  72. } else {
  73. $OUTPUT = 'irc';
  74. eval { Irssi::Core::is_static() };
  75. if ($@) {
  76. # this indicates that there is no irssi.. HENCE
  77. # we are being run from somewhere else. do not use
  78. # Irssi extensions
  79. $CONTEXT = 'terminal';
  80. } else {
  81. # no problems? great. preload Irssi functions
  82. $CONTEXT = 'irssi';
  83. eval 'use Irssi;';
  84. }
  85. }
  86.  
  87. # being run from the command line, oh my.. use ANSI
  88. # for color sequences instead of mirc
  89. if ($CONTEXT eq 'terminal') {
  90. eval 'use Term::ANSIColor';
  91. $ANSI = $@ ? 0 : 1;
  92. $OUTPUT = 'ansi' if $ANSI;
  93. }
  94.  
  95. # a place to cache stdin data
  96. my $stdin;
  97.  
  98. # some command names based on our root name
  99. my $EXEC = $NAME . "exec";
  100. my $CAT = $NAME . "cat";
  101.  
  102. # Time::HiRes only works on some systems that support
  103. # gettimeofday system calls. safely test for this
  104. my $can_throttle = 0;
  105. eval "use Time::HiRes";
  106. unless ($@) { $can_throttle = 1 }
  107.  
  108. ### console printing functions
  109.  
  110. sub cprint_lines {
  111. my $text = shift;
  112. foreach my $line (split(/\n/, $text)) {
  113. cprint("$line\n");
  114. }
  115. }
  116.  
  117. sub cprint {
  118. my $text = shift;
  119. $text =~ s/\n//g;
  120. if ($CONTEXT eq "irssi") {
  121. Irssi::print($text);
  122. } else {
  123. print $text, "\n";
  124. }
  125. }
  126.  
  127.  
  128.  
  129. # defaults
  130. my $settings = {
  131. cowfile => "default",
  132. cowpath => undef,
  133. figfont => "standard",
  134. linewrap => 70,
  135. rainbow_offset => 0,
  136. rainbow_keepstate => 1,
  137. keepstate_file => $ENV{HOME} . "/.$NAME-state",
  138. default_style => 1,
  139. check_size => 3,
  140. check_text => 0,
  141. check_colors => "4,2",
  142. matrix_size => 6,
  143. matrix_spacing => 2,
  144. colcat_max => 2048,
  145. jive_cmd => "jive",
  146. spook_words => 6,
  147. hug_size => 5,
  148. sine_height => 5,
  149. sine_frequency => "0.3",
  150. sine_background => " ",
  151. banner_style => "phrase",
  152. };
  153.  
  154. # wrap settings routines.. irssi cares about type
  155. # perl doesn't.. go figure
  156.  
  157. sub settings_get_str {
  158. my $key = shift;
  159. if ($CONTEXT eq 'irssi') {
  160. return Irssi::settings_get_str($key);
  161. } else {
  162. return $settings->{$key};
  163. }
  164. }
  165.  
  166. sub settings_get_int {
  167. my $key = shift;
  168. if ($CONTEXT eq 'irssi') {
  169. return Irssi::settings_get_int($key);
  170. } else {
  171. return $settings->{$key};
  172. }
  173. }
  174.  
  175. sub settings_get_bool {
  176. my $key = shift;
  177. if ($CONTEXT eq 'irssi') {
  178. return Irssi::settings_get_bool($key);
  179. } else {
  180. return $settings->{$key};
  181. }
  182. }
  183.  
  184. sub settings_set_int {
  185. my $key = shift;
  186. my $val = shift;
  187. if ($CONTEXT eq 'irssi') {
  188. Irssi::settings_set_int($key, $val);
  189. } else {
  190. $settings->{$key} = $val;
  191. }
  192. }
  193.  
  194.  
  195.  
  196. #######################
  197. # define some globals #
  198. #######################
  199.  
  200. # type of cow variable
  201. my $thoughts;
  202.  
  203. # usage/contact info
  204. $SPLASH = "$IRSSI{name} $IRSSI{version} by $IRSSI{author} <$IRSSI{contact}>";
  205.  
  206. my $USAGE;
  207. if ($CONTEXT eq 'irssi' or $OUTPUT eq 'irc') {
  208. $USAGE = "/$NAME";
  209. } elsif ($CONTEXT eq 'terminal' or $OUTPUT eq 'ansi') {
  210. $USAGE = $0;
  211. }
  212.  
  213. $USAGE .= <<EOU;
  214. [-usage|-help|-version|-colors] [filters ...] [text ...]
  215.  
  216. FILTERS:
  217. [-YES] [-blink] [-jive] [-exec] [-cow] [-cowfile <cow>] [-capchk] [-think]
  218. [-fig] [-font <font>] [-box] [-3d] [-arrow] [-diag] [-banner]
  219. [-banstyle <phrase|line|letter|char:?>] [-check] [-matrix] [-strip]
  220. [-spook] [-scramble] [-mirror] [-rotate] [-rev] [-leet] [-hug] [-flip]
  221. [-fake] [-ircii] [-jigs] [-tree] [-popeye] [-sine] [-chalk]
  222. [-throttle <ms>] [-repeat <#>] [-rainbow <map>] [-skew <#>] [-msg <nick>]
  223. [-pre <str>] [-cmd <cmd>]
  224. EOU
  225.  
  226.  
  227. my $blink = "\x1b[5m";
  228.  
  229. my $ansi_map = {
  230. 0 => 'white',
  231. 1 => 'black',
  232. 2 => 'blue',
  233. 3 => 'green',
  234. 4 => 'bold red',
  235. 5 => 'red',
  236. 6 => 'magenta',
  237. 7 => 'yellow',
  238. 8 => 'bold yellow',
  239. 9 => 'bold green',
  240. 10 => 'cyan',
  241. 11 => 'bold cyan',
  242. 12 => 'bold blue',
  243. 13 => 'bold magenta',
  244. 14 => 'bold black',
  245. 15 => 'bold white',
  246. };
  247.  
  248. # This would probably be better as actual font attributes
  249. # because we might want to use 'bold' or something.
  250. # then we can just close with </font>
  251. my $html_map = {
  252. 0 => '#ffffff',
  253. 1 => '#000000',
  254. 2 => '#000088', # blue
  255. 3 => '#00ff00',
  256. 4 => '#880000',
  257. 5 => '#ff5555', # yellow?
  258. 6 => '#ff00ff',
  259. 7 => '#ff0000',
  260. 8 => '#ff9999', #bold yello?
  261. 9 => '#008800',
  262. 10 => '#004400', #cyan?
  263. 11 => '#008800', #bold cyan?
  264. 12 => '#0000ff', #bold blue',
  265. 13 => '#ff00ff', #bold magenta',
  266. 14 => '#333333', #bold black',
  267. 15 => '#ffffff', #bold white',
  268. };
  269.  
  270. # This could be better, if orkut's formatting worked as advertised.
  271. my $orkut_map = {
  272. 0 => 'white',
  273. 1 => 'black',
  274. 2 => 'navy', # blue
  275. 3 => 'lime',
  276. 4 => 'maroon',
  277. 5 => 'gold', # yellow?
  278. 6 => 'purple',
  279. 7 => 'red',
  280. 8 => 'yellow', #bold yello?
  281. 9 => 'green',
  282. 10 => 'teal', #cyan?
  283. 11 => 'aqua', #bold cyan?
  284. 12 => 'blue', #bold blue
  285. 13 => 'violet', #bold magenta
  286. 14 => 'b', #bold black
  287. 15 => 'white', #bold white
  288. };
  289.  
  290. my $colorCodeMap = {
  291. r => 5,
  292. o => 4,
  293. y => 7,
  294. Y => 8,
  295. g => 3,
  296. G => 9,
  297. c => 10,
  298. C => 11,
  299. b => 2,
  300. B => 12,
  301. m => 6,
  302. M => 13,
  303. 0 => 1,
  304. 1 => 14,
  305. 2 => 15,
  306. w => 0,
  307. };
  308.  
  309. my $has_color = 0;
  310. my $prev_fg_color;
  311. my $prev_bg_color;
  312. sub do_color {
  313. my $text = shift;
  314. my $fg_col = shift;
  315. my $bg_col = shift;
  316. my $format = shift || 'mirc';
  317.  
  318. if ($format eq 'code') {
  319. $fg_col = $colorCodeMap->{$fg_col} if defined $fg_col;
  320. $bg_col = $colorCodeMap->{$bg_col} if defined $bg_col;
  321. }
  322.  
  323. $has_color = 1;
  324.  
  325. my $ret;
  326. if ($OUTPUT eq 'irc') {
  327. $ret = "\003$fg_col";
  328.  
  329. if (defined $bg_col) {
  330. $ret .= ",$bg_col";
  331. }
  332.  
  333. # if first char is a , or number,
  334. # we need some esc char's so the color thingy
  335. # doesn't get confused
  336. my $ord = ord(substr($text, 0, 1));
  337. if (($ord >= 48 and $ord <= 57) or $ord == 44) {
  338. $ret .= "\26\26";
  339. }
  340.  
  341. # mIRC remove formatting character
  342. return ($ret . $text . "\x0F");
  343. } elsif ($OUTPUT eq 'ansi') {
  344. $ret = Term::ANSIColor::color($ansi_map->{$fg_col});
  345.  
  346. $ret = '\[' . $ret if ($BASH_PROMPT);
  347.  
  348. # hack :(
  349. if (defined $bg_col) {
  350. my $bg = $ansi_map->{$bg_col};
  351. $bg =~ s/bold //;
  352. $bg = "on_$bg";
  353. $ret .= Term::ANSIColor::color($bg);
  354. }
  355.  
  356.  
  357. $ret .= '\]' if ($BASH_PROMPT);
  358. $ret .= $text;
  359. $ret .= '\[' if ($BASH_PROMPT);
  360. $ret .= Term::ANSIColor::color("reset");
  361. $ret .= '\]' if ($BASH_PROMPT);
  362.  
  363. return $ret;
  364. } elsif ($OUTPUT eq 'html') {
  365. $bg_col ||= 1; # default to black
  366.  
  367. # this is the best place to do this, probably
  368. $text =~ s/&/&amp;/g;
  369. $text =~ s/</&lt;/g;
  370. $text =~ s/>/&gt;/g;
  371.  
  372. if ((defined($prev_bg_color) && $bg_col != $prev_bg_color) ||
  373. (defined($prev_fg_color) && $fg_col != $prev_fg_color)) {
  374. $ret .= qq(</span>);
  375. }
  376.  
  377. if ((defined($prev_bg_color) && $bg_col == $prev_bg_color) &&
  378. (defined($prev_fg_color) && $fg_col == $prev_fg_color)) {
  379. $ret .= $text;
  380. } elsif ($bg_col == 1) {
  381. # black is assumed because of a div taggy
  382. $ret .= sprintf(
  383. qq(<span style="color:%s;">%s),
  384. $html_map->{$fg_col},
  385. $text,
  386. );
  387. } else {
  388. $ret .= sprintf(
  389. qq(<span style="color:%s;background-color:%s;">%s),
  390. $html_map->{$fg_col},
  391. $html_map->{$bg_col},
  392. $text,
  393. );
  394. }
  395. $prev_bg_color = $bg_col;
  396. $prev_fg_color = $fg_col;
  397. return $ret;
  398. } elsif ($OUTPUT eq 'bbcode') {
  399. $ret = sprintf(
  400. qq([color=%s]%s[/color]),
  401. $html_map->{$fg_col},
  402. $text,
  403. );
  404.  
  405. return $ret;
  406. } elsif ($OUTPUT eq 'orkut') {
  407. # Orkut has not seen fit to make a colour white,
  408. # even though the forums don't have a white background.
  409. if ($orkut_map->{$fg_col} eq 'white') {
  410. $ret = ' ';
  411. } elsif ($orkut_map->{$fg_col} eq 'black') {
  412. $ret = $text;
  413. } else {
  414. $ret = sprintf(
  415. qq([%s]%s[/%s]),
  416. $orkut_map->{$fg_col},
  417. $text,
  418. $orkut_map->{$fg_col},
  419. );
  420. }
  421.  
  422. return $ret;
  423. } elsif ($OUTPUT eq 'aim') {
  424. # In AIM, you better set the background and font on your own
  425. # AIM uses <body> tags and a custom <font> attribute to set
  426. # colour. There's really no way to paste it in, and have it
  427. # look good.
  428.  
  429. # this is the best place to do this, probably
  430. $text =~ s/&/&amp;/g;
  431. $text =~ s/</&lt;/g;
  432. $text =~ s/>/&gt;/g;
  433.  
  434. $ret = sprintf(
  435. qq(<font color="%s">%s</font>),
  436. $html_map->{$fg_col},
  437. $text,
  438. );
  439.  
  440. return $ret;
  441. }
  442.  
  443.  
  444. return ($text);
  445. }
  446.  
  447. sub show_colmap {
  448. foreach my $color (sort { $a <=> $b } keys %$ansi_map) {
  449. my $color_name = $ansi_map->{$color};
  450. my $msg = sprintf("%2d: %s\n", $color, $color_name);
  451. my $bg = ($color == 1) ? 0 : undef; # use white background for black
  452. cprint(do_color($msg, $color, $bg));
  453. }
  454. }
  455.  
  456.  
  457. # spook array.. in a perfect world this would
  458. # be in its own file. this is stolen right out of emacs,
  459. # with some more modern stuff tacked on
  460.  
  461. my @spook_lines = (
  462. "\$400 million in gold bullion",
  463. "[Hello to all my fans in domestic surveillance]", "AK-47",
  464. "ammunition", "arrangements", "assassination", "BATF", "bomb", "CIA",
  465. "class struggle", "Clinton", "Cocaine", "colonel",
  466. "counter-intelligence", "cracking", "Croatian", "cryptographic",
  467. "Delta Force", "DES", "domestic disruption", "explosion", "FBI", "FSF",
  468. "fissionable", "Ft. Bragg", "Ft. Meade", "genetic", "Honduras",
  469. "jihad", "Kennedy", "KGB", "Khaddafi", "kibo", "Legion of Doom",
  470. "Marxist", "Mossad", "munitions", "Nazi", "Noriega", "North Korea",
  471. "NORAD", "NSA", "nuclear", "Ortega", "Panama", "Peking", "PLO",
  472. "plutonium", "Qaddafi", "quiche", "radar", "Rule Psix",
  473. "Saddam Hussein", "SDI", "SEAL Team 6", "security", "Semtex",
  474. "Serbian", "smuggle", "South Africa", "Soviet ", "spy", "strategic",
  475. "supercomputer", "terrorist", "Treasury", "Uzi", "Waco, Texas",
  476. "World Trade Center", "Liberals", "Cheney",
  477.  
  478. # mine
  479. "Eggs", "Libya", "Bush", "Kill the president", "GOP", "Republican",
  480. "Shiite", "Muslim", "Chemical Ali", "Ashcroft", "Terrorism",
  481. "Al Qaeda", "Al Jazeera", "Hamas", "Israel", "Palestine", "Arabs",
  482. "Arafat", "Patriot Act", "Voter Fraud", "Punch-cards", "Diebold",
  483. "conspiracy", "Fallujah", "IndyMedia", "Skull and Bones", "Free Masons",
  484. "Kerry", "Grass Roots", "9-11", "Rocket Propelled Grenades",
  485. "Embedded Journalism", "Lockheed-Martin", "war profiteering",
  486.  
  487.  
  488. # from blogs about the spooks
  489. "Kill the President", "anarchy", "echelon", "nuclear",
  490. "assassinate", "Roswell", "Waco", "World Trade Center", "Soros",
  491. "Whitewater", "Lebed", "HALO", "Spetznaz", "Al Amn al-Askari",
  492. "Glock 26", "Steak Knife", "Rewson", "SAFE", "Waihopai", "ASPIC",
  493. "MI6", "Information Security", "Information Warfare", "Privacy",
  494. "Information Terrorism", "Terrorism", "Defensive Information",
  495. "Defense Information Warfare", "Offensive Information",
  496. "Offensive Information Warfare", "Ortega Waco", "assasinate",
  497. "National Information Infrastructure", "InfoSec",
  498. "Computer Terrorism", "DefCon V", "Encryption", "Espionage", "NSA",
  499. "CIA", "FBI", "White House", "Undercover", "Compsec 97", "Europol",
  500. "Military Intelligence", "Verisign", "Echelon",
  501. "Ufologico Nazionale", "smuggle", "Bletchley Park", "Clandestine",
  502. "Counter Terrorism Security", "Enemy of the State", "20755-6000",
  503. "Electronic Surveillance", "Counterterrorism", "eavesdropping",
  504. "nailbomb", "Satellite imagery", "subversives", "World Domination",
  505. "wire transfer", "jihad", "fissionable", "Sayeret Mat'Kal",
  506. "HERF pipe-bomb", "2.3 Oz. cocaine",
  507. );
  508.  
  509. # leet mapping
  510. my $leet_map = {
  511. a => [ "4", "/\\", "@", "a", "A" ],
  512. b => [ "|o", "b", "B" ],
  513. c => [ "C", "c", "<" ],
  514. d => [ "d", "D", "|)" ],
  515. e => [ "e", "E", "3" ],
  516. f => [ "f", "F", "/=" ],
  517. g => [ "g", "G", "6" ],
  518. h => [ "h", "H", "|-|" ],
  519. i => [ "i", "I", "|", "1" ],
  520. j => [ "j", "J" ],
  521. k => [ "keke", "x", "X", "k", "K", "|<" ],
  522. l => [ "l", "L", "7", "|_" ],
  523. m => [ "|V|", "|\\/|", "m", "M" ],
  524. n => [ "n", "N", "|\\|" ],
  525. o => [ "0", "o", "O", "()", "[]", "<>" ],
  526. p => [ "p", "P", "9" ],
  527. q => [ "q", "Q" ],
  528. r => [ "r", "R" ],
  529. s => [ "s", "S", "5" ],
  530. t => [ "t", "T", "7" ],
  531. u => [ "|_|", "u", "U", "\\/" ],
  532. v => [ "v", "V", "\\/" ],
  533. w => [ "w", "W", "uu", "UU", "uU", "Uu", "\\/\\/" ],
  534. x => [ "x", "X", "><" ],
  535. y => [ "y", "Y" ],
  536. z => [ "z", "Z", "5" ],
  537. };
  538.  
  539. # 'jigs' mapping
  540. my $jigs_map = {
  541. 7 => "8",
  542. 8 => "9",
  543. 9 => "0",
  544. 0 => "-",
  545. '-' => "=",
  546. '=' => "7",
  547. y => "u",
  548. h => "j",
  549. n => "m",
  550. u => "i",
  551. j => "k",
  552. m => ".",
  553. i => "o",
  554. k => "l",
  555. "," => ".",
  556. o => "p",
  557. l => ";",
  558. "." => "/",
  559. p => "[",
  560. ";" => "'",
  561. "/" => "n",
  562. "[" => "]",
  563. "]" => '\\',
  564. '"' => "h",
  565. '\\' => "u",
  566. };
  567.  
  568. my @bash_map = (
  569. "a",
  570. "d",
  571. "D{[^{]*}",
  572. "e",
  573. "h",
  574. "H",
  575. "j",
  576. "l",
  577. "n",
  578. "r",
  579. "s",
  580. "t",
  581. "T",
  582. "@",
  583. "A",
  584. "u",
  585. "v",
  586. "V",
  587. "w",
  588. "W",
  589. "!",
  590. "#",
  591. "\\\$",
  592. "\\d{1,3}",
  593. "\\\\",
  594. "\\[",
  595. "\\]",
  596. );
  597.  
  598.  
  599. # random text for text substitution
  600. # needless to say if someone has this string
  601. # in their text, it'll get clobbered.
  602. my $rnd = "rAnDoM";
  603.  
  604. # markup stuff
  605. my $COWCUT = "---COWCUT---";
  606.  
  607. ###############################
  608. # these are the main commands #
  609. ###############################
  610.  
  611. sub insub {
  612. my $text = shift;
  613.  
  614. if ($text =~ /^(?:-YES )?-help/i ) { show_help() }
  615. elsif ($text =~ /^(?:-YES )?-vers/i ) { cprint($SPLASH) }
  616. elsif ($text =~ /^(?:-YES )?-update/i) { update() }
  617. elsif ($text =~ /^(?:-YES )?-usage/i ) { cprint_lines($USAGE) }
  618. elsif ($text =~ /^(?:-YES )?-colors/i ) { show_colmap() }
  619. else { process(undef, $text, @_) }
  620. }
  621.  
  622. # these are aliases that use a predefined set of filters
  623. sub insubexec { process("e", @_) } # execute
  624. sub insubcat { process("x", @_) } # byte restriction
  625. sub gv { process("v", @_) } # display version info
  626.  
  627. ###############################
  628. # this handles the processing #
  629. ###############################
  630.  
  631. sub process {
  632. my ($flags, $text, $server, $dest) = @_;
  633.  
  634. $flags ||= ""; # silence undef warnings on cmd line
  635.  
  636.  
  637. if ($CONTEXT eq 'irssi') {
  638. if (!$server || !$server->{connected}) {
  639. cprint("Not connected to server");
  640. return;
  641. }
  642.  
  643. return unless $dest;
  644. }
  645.  
  646. # set up defaults
  647. my @text;
  648. my $prefix;
  649. my $cmd;
  650. my $style = settings_get_int("default_style");
  651. my $cowfile = settings_get_str("cowfile");
  652. my $figfont = settings_get_str("figfont");
  653. my $banstyle = settings_get_str("banner_style");
  654.  
  655. my $sendto = $dest->{name} if $dest;
  656.  
  657. # allows commands to figure out target from context
  658. my $target;
  659. if ($dest && ($dest->{type} eq "CHANNEL" || $dest->{type} eq "QUERY")) {
  660. $target = $dest;
  661. } else {
  662. $target = $server;
  663. }
  664.  
  665. # parse args
  666. my @args;
  667. my $error_returned = 0;
  668. if (defined $text) {
  669. (@args, $error_returned) = shellwords($text);
  670. return if $error_returned;
  671. }
  672.  
  673. my $throttle = 0;
  674. my $force = 0;
  675. my $repeat;
  676. my $map;
  677. my $skew;
  678. while(1) {
  679. my $arg = shift(@args); last if (!defined $arg);
  680. if ($arg =~ /^-msg/) { $sendto = shift(@args); next }
  681. if ($arg =~ /^-pre/) { $prefix = shift(@args); next }
  682. if ($arg =~ /^-cmd/) { $cmd = shift(@args); next }
  683. if ($arg =~ /^-blink/) { $flags .= "b"; next }
  684. if ($arg =~ /^-jive/) { $flags .= "j"; next }
  685. if ($arg =~ /^-exec/) { $flags .= "e"; next }
  686. if ($arg =~ /^-cowfile/) { $cowfile = shift(@args); next }
  687. if ($arg =~ /^-cow/) { $flags .= "c"; next }
  688. if ($arg =~ /^-fig/) { $flags .= "f"; next }
  689. if ($arg =~ /^-font/) { $figfont = shift(@args); next }
  690. if ($arg =~ /^-banstyle/) { $banstyle = shift(@args); next }
  691. if ($arg =~ /^-utf8/) { $flags .= "8"; next }
  692. if ($arg =~ /^-box/) { $flags .= "o"; next }
  693. if ($arg =~ /^-3d/) { $flags .= "3"; next }
  694. if ($arg =~ /^-arrow/) { $flags .= "a"; next }
  695. if ($arg =~ /^-diag/) { $flags .= "D"; next }
  696. if ($arg =~ /^-banner/) { $flags .= "B"; next }
  697. if ($arg =~ /^-check/) { $flags .= "C"; next }
  698. if ($arg =~ /^-capchk/) { $flags .= "h"; next }
  699. if ($arg =~ /^-matrix/) { $flags .= "m"; next }
  700. if ($arg =~ /^-strip/) { $flags .= "n"; next }
  701. if ($arg =~ /^-spook/) { $flags .= "s"; next }
  702. if ($arg =~ /^-scramble/) { $flags .= "S"; next }
  703. if ($arg =~ /^-mirror/) { $flags .= "M"; next }
  704. if ($arg =~ /^-rotate/) { $flags .= "4"; next }
  705. if ($arg =~ /^-rev/) { $flags .= "R"; next }
  706. if ($arg =~ /^-leet/) { $flags .= "l"; next }
  707. if ($arg =~ /^-hug/) { $flags .= "H"; next }
  708. if ($arg =~ /^-flip/) { $flags .= "F"; next }
  709. if ($arg =~ /^-fake/) { $flags .= "I"; next }
  710. if ($arg =~ /^-ircii/) { $flags .= "d"; next }
  711. if ($arg =~ /^-jigs/) { $flags .= "J"; next }
  712. if ($arg =~ /^-tree/) { $flags .= "t"; next }
  713. if ($arg =~ /^-think/) { $flags .= "T"; next }
  714. if ($arg =~ /^-unused/) { $flags .= "u"; next }
  715. if ($arg =~ /^-popeye/) { $flags .= "p"; next }
  716. if ($arg =~ /^-sine/) { $flags .= "w"; next }
  717. if ($arg =~ /^-wave/) { $flags .= "w"; next } # bck compat
  718. if ($arg =~ /^-YES/i) { $force = 1; next }
  719. if ($arg =~ /^-chalk/i) { $flags .= "P"; next }
  720. if ($arg =~ /^-thro/) { $throttle = shift(@args); next }
  721. if ($arg =~ /^-repeat/) { $repeat = shift(@args); next }
  722. if ($arg =~ /^-rain/) { $map = shift(@args); $flags .= 'r'; next }
  723. if ($arg =~ /^-skew/) { $skew = shift(@args); next }
  724.  
  725. # this is getting trickier
  726. if ($arg =~ /^-(\d+)$/) {
  727. $flags .= "r";
  728. if ($1 == 1) { $style = 'rainbow' }
  729. elsif ($1 == 2) { $style = 'usa' }
  730. elsif ($1 == 3) { $map = random_colmap()}
  731. elsif ($1 == 4) { $style = 'randcol' }
  732. elsif ($1 == 5) { $style = 'grey' }
  733. elsif ($1 == 6) { $style = 'scale' }
  734. elsif ($1 == 7) { $style = 'xmas' }
  735. elsif ($1 == 8) { $style = 'canada' }
  736. next;
  737. } elsif ($arg =~ /^-4(\w+)$/) {
  738. $flags .= "r";
  739. $style = $1;
  740. next;
  741. }
  742.  
  743. # doesn't match arguments, must be text!
  744. push(@text, $arg);
  745. }
  746. $text = join(" ", @text);
  747. $text =~ s/\\n/\n/sg;
  748.  
  749. ########################################
  750. # sanity check before applying filters #
  751. ########################################
  752.  
  753. if ($flags =~ /c/ and $flags =~ /T/) {
  754. cprint("This cow cannot THINK and SPEAK at the same time.");
  755. return;
  756. }
  757.  
  758. if ($flags =~ /c/) { $thoughts = "\\" }
  759. if ($flags =~ /T/) { $thoughts = "o" }
  760.  
  761. # this stuff tries to protect you from yourself
  762. # .. using -YES will skip this
  763. unless ($force) {
  764. if ($flags =~ /h/ and $flags =~ /M/) {
  765. cprint("Combining -capchk and -mirror is bad, mkay (try -YES)");
  766. return;
  767. }
  768.  
  769. if ($flags =~ /s/ and $flags =~ /f/) {
  770. cprint("Spook and figlet is probably a bad idea (see: -YES)");
  771. return;
  772. }
  773. }
  774.  
  775. # for outlining, precedence must be set
  776. # 3dbox > arrow > box
  777. $flags =~ s/(o|a)//g if $flags =~ /3/;
  778. $flags =~ s/o//g if $flags =~ /a/;
  779.  
  780. # check should override rainbow for now
  781. $flags =~ s/r//g if $flags =~ /C/;
  782.  
  783. # ... so should capchk, unless it's a cow, in which case
  784. # we invoke cowcut-fu
  785. my $cowcut = 0;
  786. if ($flags =~ /h/) {
  787. # yes, capchk was specified
  788. if ($flags =~ /c/ and $flags =~ /r/) {
  789. $cowcut = 1;
  790. } else {
  791. $flags =~ s/r//g;
  792. }
  793. }
  794.  
  795. # capchk takes precedence over check
  796. $flags =~ s/C//g if $flags =~ /h/;
  797.  
  798. # the TREE cannot be colored
  799. $flags =~ s/r//g if $flags =~ /t/;
  800.  
  801. if ($throttle) {
  802. unless ($can_throttle) {
  803. cprint("Sorry, your system does not allow high resolution sleeps");
  804. return;
  805. }
  806.  
  807. if ($throttle < 5 or $throttle > 10_000) {
  808. cprint("Please use a throttle between 10ms and 10,000ms");
  809. return;
  810. }
  811.  
  812. $throttle = $throttle / 1000;
  813. }
  814.  
  815. if (defined $repeat) {
  816. $repeat =~ s/[^0-9]//g;
  817. if ($repeat > 1) {
  818. $text = $text x $repeat;
  819. }
  820. }
  821.  
  822.  
  823. ##############################
  824. # filter text based on flags #
  825. ##############################
  826.  
  827. my $flag_list = "348BCDFHIJMRSTabcdefhjlmnoprstuvwxP";
  828.  
  829. # flag sanity check. because there are a lot of flags,
  830. # require master list to contain all viable flags
  831. if ($flag_list =~ /(.).*\1/) {
  832. cprint("There was an internal error with flag processing: duplicate ($1)");
  833. return;
  834. }
  835.  
  836. foreach my $f (split(//, $flags)) {
  837. if ($flag_list !~ /$f/) {
  838. cprint("There was an internal error with flag processing: missing ($f)");
  839. return;
  840. }
  841. }
  842.  
  843. # validate utf8 support, only works in 5.8+
  844. my $utf8 = ($flags =~ /8/ && $] >= 5.008);
  845.  
  846. # most useful command yet
  847. if ($flags =~ /u/) {
  848. cprint("Sorry, the -unused flag is unsupported.");
  849. return;
  850. }
  851.  
  852. # where to get text
  853. $text = "$IRSSI{name} $IRSSI{version} - $IRSSI{download}/$IRSSI{name}" if $flags =~ /v/;
  854. $text = $stdin if defined($stdin);
  855. $text = execute($text) if $flags =~ /e/;
  856. $text = slurp($text, $utf8) if $flags =~ /x/;
  857. $text = spookify($text) if $flags =~ /s/;
  858.  
  859. # change the text contents itself
  860. $text = jive($text) if $flags =~ /j/;
  861. $text = scramble($text) if $flags =~ /S/;
  862. $text = leet($text) if $flags =~ /l/;
  863. $text = reverse_ascii($text) if $flags =~ /R/;
  864. $text = jigs($text) if $flags =~ /J/;
  865.  
  866. # change the text appearance
  867. $text = sine($text) if $flags =~ /w/;
  868. $text = diagonal($text) if $flags =~ /D/;
  869. $text = popeye($text) if $flags =~ /p/;
  870. $text = matrix($text) if $flags =~ /m/;
  871. $text = figlet($text, $figfont) if $flags =~ /f/;
  872. $text = banner($text, $banstyle) if $flags =~ /B/;
  873. $text = hug($text) if $flags =~ /H/;
  874. $text = rotate($text) if $flags =~ /4/;
  875. $text = gwrap($text) if $flags !~ /[f4]/;
  876. $text = chalkboard($text) if $flags =~ /P/;
  877.  
  878. # change the text presentation
  879. $text = checker($text) if $flags =~ /h/;
  880. $text = reverse_ascii($text) if $flags =~ /M/;
  881. $text = cowsay($text, $cowfile, $cowcut) if $flags =~ /(c|T)/;
  882. $text = reverse_ascii($text) if $flags =~ /M/ and $flags =~ /(c|T)/;
  883. $text = upside_down($text) if $flags =~ /F/;
  884. $text = checker($text) if $flags =~ /C/;
  885.  
  886. # draw a box, pass a style flag
  887. $text = outline($text, 0) if $flags =~ /o/;
  888. $text = outline($text, 1) if $flags =~ /3/;
  889. $text = outline($text, 2) if $flags =~ /a/;
  890.  
  891. # change the final products visual appearance
  892. $text = rainbow($text, $style, $map, $skew) if $flags =~ /r/;
  893. $text = tree($text) if $flags =~ /t/;
  894. $text = blink($text) if $flags =~ /b/;
  895.  
  896. # stuff to bust ircii :D
  897. $text = ircii_fake($text) if $flags =~ /I/;
  898. $text = ircii_drop($text) if $flags =~ /d/;
  899.  
  900. $text = prefix($text, $prefix) if $prefix;
  901. $text = strip($text) if $flags =~ /n/;
  902.  
  903. ########################
  904. # output final product #
  905. ########################
  906.  
  907. # don't go the final mile if a filter returned an error
  908. return unless (defined $text && (length($text) >= 1));
  909.  
  910. # html needs to be handled with kids gloves
  911. if ($OUTPUT eq 'html') {
  912. print qq(<div style="background-color:black;color:white;"><pre>);
  913.  
  914. # not colorized, we should look for
  915. # unescaped brackets ourselves,
  916. # since we can't reply on do_color() to handle
  917. # it.. this is ok since there won't be any html unless
  918. # it's from do_color
  919. unless ($has_color) {
  920. $text =~ s/&/&amp;/g;
  921. $text =~ s/</&lt;/g;
  922. $text =~ s/>/&gt;/g;
  923. }
  924. } elsif ($OUTPUT eq 'aim') {
  925. unless ($has_color) {
  926. $text =~ s/&/&amp;/g;
  927. $text =~ s/</&lt;/g;
  928. $text =~ s/>/&gt;/g;
  929. }
  930. }
  931.  
  932.  
  933. foreach my $line (split(/\n/, $text)) {
  934. if ($CONTEXT eq 'irssi') {
  935. $line = " " if $line eq ""; # hack
  936. my @cmd = ();
  937. push(@cmd, "msg");
  938. push(@cmd, "-channel") if ($server->{chat_type} =~ /^silc/i);
  939. push(@cmd, $sendto);
  940. $cmd = join(" ", @cmd) unless $cmd;
  941. $target->command("$cmd $line");
  942. } elsif ($CONTEXT eq 'terminal' or $CONTEXT eq 'cgi') {
  943. print $line, "\n";
  944. }
  945.  
  946. if ($throttle) {
  947. Time::HiRes::sleep($throttle);
  948. }
  949. }
  950.  
  951. if ($OUTPUT eq 'html') {
  952. print qq(</pre></div>\n);
  953. }
  954. }
  955.  
  956. ###########
  957. # FILTERS #
  958. ###########
  959.  
  960. sub prefix {
  961. my ($text, $prefix) = @_;
  962. return if (!defined $text || !defined $prefix);
  963.  
  964. my @new;
  965. foreach my $line (split(/\n/, $text)) {
  966. $line = "$prefix $line";
  967. push(@new, $line);
  968. }
  969. $text = join("\n", @new);
  970.  
  971. return $text;
  972. }
  973.  
  974. my $COWPATH;
  975. sub find_cowpath {
  976. $COWPATH = $ENV{COWPATH} || "";
  977. return if -d $COWPATH;
  978.  
  979. $COWPATH = settings_get_str("cowpath") || "";
  980. return if -d $COWPATH;
  981.  
  982. my $cowsay_cmd = whereis("cowsay");
  983. if ($cowsay_cmd) {
  984. if (open(IN, "< $cowsay_cmd")) {
  985. while (my $line = <IN>) {
  986. if ($line =~ m!^\$cowpath = \$ENV\{'COWPATH'\} \|\| '(.*?)';!) {
  987. $COWPATH = $1;
  988. last;
  989. }
  990. }
  991. close IN;
  992. }
  993. }
  994.  
  995. $COWPATH ||= "";
  996.  
  997. return if -d $COWPATH;
  998.  
  999. $COWPATH = undef;
  1000. cprint("I could not figure out your COWPATH!!");
  1001. }
  1002.  
  1003. sub cowsay {
  1004. # my cowsay implementation.. because normal cowsay
  1005. # messes up bubble-size if you have imbedded
  1006. # color codes.. this works pretty much the same,
  1007. # except it doesn't have support for stuff like
  1008. # tongue and eyes.
  1009.  
  1010. my $text = shift;
  1011. return if (!defined $text);
  1012.  
  1013. my $cowfile = shift || "default";
  1014. my $cowcut = shift;
  1015.  
  1016. # my mother tried to find my cowpath once.. once.
  1017. unless ($COWPATH) { find_cowpath() }
  1018.  
  1019. unless ($COWPATH) {
  1020. cprint("I cannot continue with cowsay, for there is no COWPATH!");
  1021. return $text;
  1022. }
  1023.  
  1024. my @output;
  1025.  
  1026. # this is the whole point of doing my own cowsay
  1027. my $length = 0;
  1028. my @text = split(/\n/, $text);
  1029. foreach my $line (@text) {
  1030. my $l = clean_length($line);
  1031. $length = $l if $l > $length;
  1032. }
  1033.  
  1034. # add filler to the end
  1035. foreach my $line (@text) {
  1036. $line .= (" " x ($length - clean_length($line)));
  1037. }
  1038.  
  1039. my $div = " " . ("-" x ($length+2));
  1040. push(@output, $div);
  1041. push(@output, $COWCUT) if $cowcut;
  1042. my $count = 0;
  1043. my $total = scalar(@text) - 1;
  1044. foreach my $line (@text) {
  1045. if ($total == 0) {
  1046. push(@output, "< $line >");
  1047. } elsif ($count == 0) {
  1048. push(@output, "/ $line \\");
  1049. } elsif ($count == $total) {
  1050. push(@output, "\\ $line /");
  1051. } else {
  1052. push(@output, "| $line |");
  1053. }
  1054. $count++;
  1055. }
  1056.  
  1057. # this is rainbow() markup for toggling colorize
  1058. push(@output, $COWCUT) if $cowcut;
  1059. push(@output, $div);
  1060.  
  1061. if ($cowfile =~ /^<rand(om)?>$/i) {
  1062. my @cowfiles;
  1063. foreach my $dir (split(/:/, $COWPATH)) {
  1064. unless (opendir(COWDIR, $dir)) {
  1065. cprint("failed to open: $dir");
  1066. return;
  1067. }
  1068.  
  1069. push(@cowfiles, grep(/\.cow$/, readdir(COWDIR)));
  1070. close COWDIR;
  1071. }
  1072.  
  1073. $cowfile = $cowfiles[rand(@cowfiles)];
  1074. }
  1075.  
  1076. my $full;
  1077. $cowfile .= ".cow" unless ($cowfile =~ /\.cow$/);
  1078. if ($cowfile =~ m!/!) {
  1079. $full = $cowfile;
  1080. } else {
  1081. foreach my $path (split(/:/, $COWPATH)) {
  1082. if (-f "$path/$cowfile") {
  1083. $full = "$path/$cowfile";
  1084. last;
  1085. }
  1086. }
  1087. }
  1088.  
  1089. unless (-f $full) {
  1090. cprint("could not find cowfile: $cowfile");
  1091. return;
  1092. }
  1093.  
  1094. my $the_cow = "";
  1095. my $eyes = "oo";
  1096. my $tongue = " ";
  1097.  
  1098. # very odd.. unless $thoughts is addressed in some
  1099. # fasion in this scope, eval doesn't notice it
  1100. # i say this is a perl bug
  1101. $thoughts = $thoughts;
  1102.  
  1103.  
  1104. unless (open(IN, "<$full")) {
  1105. cprint("couldn't read $full: $!");
  1106. return;
  1107. }
  1108. my $cow_code = join('', <IN>);
  1109. close IN;
  1110.  
  1111. eval $cow_code;
  1112.  
  1113. push(@output, split(/\n/, $the_cow));
  1114. return join("\n", @output);
  1115. }
  1116.  
  1117. sub figlet {
  1118. # pass text through figlet
  1119. my $text = shift;
  1120. return if (!defined $text);
  1121.  
  1122. my $figlet_font = shift || 'standard';
  1123. my $figlet_wrap = settings_get_int('linewrap');
  1124.  
  1125. if ($figlet_font =~ /random/i) {
  1126. chomp(my $fontdir = run(command => "figlet", args => "-I2"));
  1127.  
  1128. if (opendir(FONTDIR, $fontdir)) {
  1129. my @fonts = grep(s/\.flf$//, readdir(FONTDIR));
  1130. close FONTDIR;
  1131.  
  1132. $figlet_font = $fonts[rand(@fonts)];
  1133. } else {
  1134. cprint("could not open $fontdir");
  1135. $figlet_font = "standard";
  1136. }
  1137. }
  1138.  
  1139. my $output = run(
  1140. command => "figlet",
  1141. args => "-f $figlet_font -w $figlet_wrap",
  1142. stdin => $text,
  1143. ) || return $text;
  1144.  
  1145. $output =~ s/^\s+\n//g; # sometimes it leaves leading blanks too!
  1146. $output =~ s/\n\s+\n$//s; # figlet leaves a trailing blank line.. sometimes
  1147.  
  1148. return $output;
  1149. }
  1150.  
  1151. sub jive {
  1152. # pass text through jive filter
  1153. my $text = shift;
  1154. return if (!defined $text);
  1155.  
  1156. # see if we can find the program
  1157. my $jive_cmd = settings_get_str('jive_cmd');
  1158. $jive_cmd = -x $jive_cmd ? $jive_cmd : whereis("jive");
  1159. unless (-x $jive_cmd) {
  1160. cprint("$jive_cmd not found or not executable!");
  1161. return;
  1162. }
  1163.  
  1164. my $pid = open3(
  1165. \*WRITE, \*READ, \*ERR,
  1166. $jive_cmd
  1167. );
  1168.  
  1169. print WRITE $text;
  1170. close WRITE;
  1171.  
  1172. $text = join('', <READ>);
  1173. close READ;
  1174.  
  1175. # check for errors
  1176. cprint_lines(join('', <ERR>));
  1177. close ERR;
  1178.  
  1179. waitpid($pid, 0);
  1180.  
  1181. return $text;
  1182. }
  1183.  
  1184. sub checker {
  1185. # checker filter. thanks to uke
  1186. my $text = shift;
  1187. return if (!defined $text);
  1188.  
  1189. my $checksize = settings_get_int('check_size');
  1190. my $checktext = settings_get_int('check_text');
  1191.  
  1192. my @colors = split(/\s*,\s*/, settings_get_str("check_colors"));
  1193.  
  1194. my $rownum = 0;
  1195. my $offset = 0;
  1196. my @text = split(/\n/, $text);
  1197.  
  1198. # what is the longest line?
  1199. my $length = 0;
  1200. foreach my $line (@text) {
  1201. $length = length($line) if length($line) > $length;
  1202. }
  1203.  
  1204. foreach my $line (@text) {
  1205. # pad line with whitespace
  1206. $line .= (" " x ($length - length($line)));
  1207.  
  1208. my $newline;
  1209. my $state = 0;
  1210. for (my $i = 0; $i < length($line); $i = $i + $checksize) {
  1211. my $chunk = substr($line, $i, $checksize);
  1212. my $index = ($state + $offset); $index -= scalar(@colors) if $index >= scalar(@colors);
  1213.  
  1214. # add color
  1215. $newline .= do_color($chunk, $checktext, $colors[$index]);
  1216. $state++; $state = 0 if $state >= scalar(@colors);
  1217. }
  1218.  
  1219. $line = $newline;
  1220.  
  1221. # increment rowcount/swap offset
  1222. $rownum++;
  1223. if ($rownum == $checksize) {
  1224. $rownum = 0;
  1225. $offset++; $offset = 0 if $offset >= scalar(@colors);
  1226. }
  1227. }
  1228. return join("\n", @text);
  1229. }
  1230.  
  1231. sub get_state {
  1232. my $state;
  1233. if ($CONTEXT eq 'irssi') {
  1234. $state = settings_get_int("rainbow_offset");
  1235. } else {
  1236. my $file = settings_get_str("keepstate_file");
  1237. if (open(STATE, "< $file")) {
  1238. $state = <STATE>;
  1239. close STATE;
  1240. chomp $state;
  1241. $state =~ s/[^0-9]//g;
  1242. }
  1243. }
  1244.  
  1245. $state ||= 0;
  1246. return $state;
  1247. }
  1248.  
  1249. sub set_state {
  1250. my $state = shift;
  1251. if ($CONTEXT eq 'irssi') {
  1252. settings_set_int("rainbow_offset", $state);
  1253. } else {
  1254. my $file = settings_get_str("keepstate_file");
  1255. unlink($file);
  1256. if (open(STATE, "> $file")) {
  1257. print STATE "$state\n";
  1258. close STATE;
  1259. }
  1260. }
  1261. }
  1262.  
  1263. # New way of doing it
  1264. my $rainbowMap = {
  1265. rainbow => 'rrooyyYYGGggccCCBBbbmmMM', # -1
  1266. usa => 'oowwBB', # -2
  1267. blue => 'bB', # -4blue
  1268. green => 'gG', # -4green
  1269. purple => 'mM', # -4purple
  1270. grey => '12', # -4grey (-5)
  1271. yellow => 'yY', # -4yellow
  1272. red => 'or', # -4red
  1273. scale => 'ww22CC11CC22', # -6
  1274. xmas => 'og', # -7
  1275. canada => 'ooww', # -8
  1276. };
  1277.  
  1278. sub random_colmap {
  1279. my @map = keys %$colorCodeMap;
  1280. fisher_yates_shuffle(\@map);
  1281. return join('', @map);
  1282. }
  1283.  
  1284. sub rainbow {
  1285. my $text = shift;
  1286. my $style = shift || 'rainbow';
  1287. my $map = shift;
  1288. my $skew = shift || 1;
  1289.  
  1290. return if !defined $text;
  1291.  
  1292. my $offset = settings_get_bool('rainbow_keepstate') ? get_state() : 0;
  1293. $map = $rainbowMap->{$style} if (!defined $map && exists $rainbowMap->{$style});
  1294.  
  1295. return $text if !defined $map;
  1296.  
  1297. my $colorize = 1;
  1298. my $output = '';
  1299. foreach my $line (split(/\r?\n/, $text)) {
  1300. if ($line =~ /$COWCUT/) { $colorize++; next }
  1301. if (!$colorize % 2) { $output .= "$line\n"; next }
  1302.  
  1303. my $i = 0;
  1304. foreach my $char (split('', $line)) {
  1305. my $color = substr($map, ($offset + $i) % length($map), 1);
  1306. $output .= do_color($char, $color, undef, 'code');
  1307. $i++;
  1308. }
  1309.  
  1310. $offset += $skew;
  1311. $output .= "\n";
  1312. }
  1313.  
  1314. set_state($offset) if settings_get_bool('rainbow_keepstate');
  1315. return $output
  1316. }
  1317.  
  1318. sub blink {
  1319. # make the text blink
  1320. my $text = shift;
  1321. return if (!defined $text);
  1322.  
  1323. my @newtext;
  1324. foreach my $line (split(/\n/, $text)) {
  1325. if ($OUTPUT eq 'html') {
  1326. push(@newtext, "<blink>$line</blink>");
  1327. } else {
  1328. push(@newtext, $blink . $line);
  1329. }
  1330. }
  1331. return join("\n", @newtext);
  1332. }
  1333.  
  1334. sub clean_length {
  1335. my $text = shift;
  1336. return if (!defined $text);
  1337.  
  1338. # generic mIRC color syntax
  1339. $text =~ s/\x03\d{0,2}(,\d{0,2})?//g;
  1340.  
  1341. # bold ^b, inverse ^v, underline ^_, clear ^O
  1342. $text =~ s/\x02|\x16|\x1F|\x0F//g;
  1343.  
  1344. # ansi
  1345. $text =~ s/\x1b\[\d+(?:,\d+)?m//g;
  1346.  
  1347. #html
  1348. $text =~ s/<span[^>]+>//g;
  1349. $text =~ s/<\/span>//g;
  1350.  
  1351. if ($OUTPUT eq 'bbcode') {
  1352. $text =~ s/\[color=(#[0-9a-f]{6}|[a-z]+)\]//ig;
  1353. $text =~ s/\[\/color\]//ig;
  1354. } elsif ($OUTPUT eq 'aim') {
  1355. $text =~ s/<font[^>]+>//ig;
  1356. $text =~ s/<\/font>//ig;
  1357. } elsif ($OUTPUT eq 'orkut') {
  1358. $text =~
  1359. s/\[\/?(aqua|blue|fuchsia|gold|gray|green|lime|maroon|navy|olive|orange|pink|purple|red|silver|teal|violet|yellow|b|i|u)\]//ig;
  1360. }
  1361.  
  1362. return length($text);
  1363. }
  1364.  
  1365.  
  1366. sub matrix {
  1367. # 0-day greetz to EnCapSulaTE1!11!one
  1368. my $text = shift;
  1369. return if (!defined $text);
  1370.  
  1371. my $size = settings_get_int("matrix_size");
  1372. my $spacing = settings_get_int("matrix_spacing");
  1373.  
  1374. $size = 1 if ($size < 1);
  1375.  
  1376. # first, let's dispense with the newlinesa
  1377. # because they have no meaning up/down
  1378. $text =~ s/\n/ /sg;
  1379.  
  1380. my @text;
  1381. for (my $i = 0; $i < length($text); $i += $size) {
  1382. my $chunk = substr($text, $i, $size);
  1383. for (my $j = 0; $j < length($chunk); $j++) {
  1384. $text[$j] .= substr($chunk, $j, 1) . (" " x $spacing);
  1385. }
  1386. }
  1387. return join("\n", @text);
  1388. }
  1389.  
  1390. sub outline {
  1391. # draw a box around text.. thanks 2 twid
  1392. # for the idea
  1393. my $text = shift;
  1394. return if (!defined $text);
  1395.  
  1396. my $style = shift;
  1397. my ($_3d, $_arrow);
  1398.  
  1399. if ($style == 1) {
  1400. $_3d = 1;
  1401. } elsif ($style == 2) {
  1402. # arrow-style, thanks to rob
  1403. $_arrow = 1;
  1404. }
  1405.  
  1406. my @text = split(/\n/, $text);
  1407.  
  1408. # what is the longest line
  1409. my $length = 0;
  1410.  
  1411. foreach my $line (@text) {
  1412. $length = clean_length($line) if clean_length($line) > $length;
  1413. }
  1414.  
  1415. # add box around each line
  1416. my $lc = "|"; my $rc = "|";
  1417. if ($_arrow) { $lc = ">"; $rc = "<" }
  1418. foreach my $line (@text) {
  1419. $line = "$lc $line" . (" " x ($length - clean_length($line) + 1)) . "$rc";
  1420. $line .= " |" if ($_3d);
  1421. }
  1422.  
  1423. # top/bottom frame
  1424. my ($top_frame, $bottom_frame);
  1425. if ($_arrow) {
  1426. $top_frame = "\\" . ("^" x ($length + 2)) . "/";
  1427. $bottom_frame = "/" . ("^" x ($length + 2)) . "\\";
  1428. } else {
  1429. $top_frame = "+" . ("-" x ($length + 2)) . "+";
  1430. $bottom_frame = $top_frame;
  1431. }
  1432.  
  1433.  
  1434. if ($_3d) {
  1435. push(@text, $bottom_frame . "/");
  1436. unshift(@text, $top_frame . " |");
  1437. } else {
  1438. push(@text, $bottom_frame);
  1439. unshift(@text, $top_frame);
  1440. }
  1441.  
  1442. if ($_3d) {
  1443. unshift(@text, " /" . (" " x ($length + 2)) . "/|");
  1444. unshift(@text, " " . ("_" x ($length + 3)));
  1445. }
  1446.  
  1447.  
  1448. return join("\n", @text);
  1449. }
  1450.  
  1451. sub whereis {
  1452. # evaluate $PATH, since this doesn't seem to be inherited
  1453. # in sh subproccess in irssi.. odd
  1454. my $cmd = shift;
  1455. my $path;
  1456.  
  1457. # generate a lot of possible locations for cowsay path
  1458. $path .= $ENV{PATH};
  1459. $path .= ":/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin";
  1460. $path .= ":/usr/local/cowsay/bin:/opt/cowsay/bin";
  1461.  
  1462. foreach my $path (split(/:/, $path)) {
  1463. next unless $path;
  1464. if (-x "$path/$cmd") {
  1465. return "$path/$cmd";
  1466. }
  1467. }
  1468. }
  1469.  
  1470. sub slurp {
  1471. # read in a file with max setting (useful for catting /dev/urandom :D )
  1472. # maybe make this read in chunks, not by line, or something.. seems clumsy
  1473. my $file = shift || return;
  1474. my $utf8 = shift;
  1475.  
  1476. # expand ~
  1477. $file =~ s!^~([^/]*)!$1 ? (getpwnam($1))[7] : ($ENV{HOME} || $ENV{LOGDIR} || (getpwuid($>))[7])!ex;
  1478.  
  1479. {
  1480. my $result;
  1481. if ($utf8) { eval '$result = open(IN, "<:utf8", "$file");' }
  1482. else { $result = open(IN, "<$file"); }
  1483. unless ($result) {
  1484. cprint("could not open $file: $!");
  1485. return;
  1486. }
  1487. }
  1488.  
  1489. my $max = settings_get_int("colcat_max");
  1490. my $text;
  1491. while (my $line = <IN>) {
  1492. $text .= $line;
  1493. last if length($text) >= $max;
  1494. }
  1495. close IN;
  1496.  
  1497. return $text;
  1498. }
  1499.  
  1500. sub execute {
  1501. # execute command and return output
  1502. my $text = shift;
  1503. return if (!defined $text);
  1504.  
  1505. my $pid = open3(
  1506. \*WRITE, \*READ, \*ERR,
  1507. $text
  1508. );
  1509.  
  1510. close WRITE;
  1511.  
  1512. $text = join('', <READ>);
  1513. close READ;
  1514.  
  1515. # check for errors
  1516. cprint_lines(join('', <ERR>));
  1517. close ERR;
  1518.  
  1519. waitpid($pid, 0);
  1520.  
  1521. return $text;
  1522. }
  1523.  
  1524.  
  1525.  
  1526. sub show_help {
  1527. my $help = <<EOH;
  1528. $USAGE
  1529.  
  1530. STYLES:
  1531. -1 rainbow
  1532. -2 red white and blue
  1533. -3 random colors
  1534. -4 random alternating colors
  1535. -5 alternating gray
  1536. -6 greyscale
  1537. -7 festive
  1538. -8 o'canada
  1539.  
  1540. IRC ONLY:
  1541. /$NAME just like /say, but takes args
  1542. /$EXEC like /exec
  1543. /$CAT pipe a file
  1544. /gv say version outloud
  1545.  
  1546. SETTINGS:
  1547. cowfile
  1548. cowpath
  1549. figfont
  1550. linewrap
  1551. rainbow_offset
  1552. rainbow_keepstate
  1553. default_style
  1554. check_size
  1555. check_text
  1556. check_colors
  1557. matrix_size
  1558. matrix_spacing
  1559. colcat_max
  1560. jive_cmd
  1561. spook_words
  1562. hug_size
  1563. sine_height
  1564. sine_frequency
  1565. sine_background
  1566. EOH
  1567. cprint_lines(draw_box($SPLASH, $help, undef, 1));
  1568. }
  1569.  
  1570. sub draw_box {
  1571. # taken from a busted script distributed with irssi
  1572. # just a simple ascii line-art around help text
  1573. my ($title, $text, $footer, $color) = @_;
  1574.  
  1575. $color = 0 unless $CONTEXT eq 'irssi';
  1576.  
  1577. $footer = $title unless($footer);
  1578. my $box;
  1579. $box .= '%R,--[%n%9%U' . $title . '%U%9%R]%n' . "\n";
  1580. foreach my $line (split(/\n/, $text)) {
  1581. $box .= '%R|%n ' . $line . "\n";
  1582. }
  1583. $box .= '%R`--<%n' . $footer . '%R>->%n';
  1584. $box =~ s/%.//g unless $color;
  1585. return $box;
  1586. }
  1587.  
  1588. sub update {
  1589. unless ($CONTEXT eq 'irssi') {
  1590. warn "let's not do that outside irssi ok?\n";
  1591. return;
  1592. }
  1593.  
  1594. # automatically check for updates
  1595. my $baseURL = $IRSSI{download} . "/" . $IRSSI{name};
  1596.  
  1597. # do we have useragent?
  1598. eval "use LWP::UserAgent";
  1599. if ($@) {
  1600. cprint("LWP::UserAgent failed to load: $!");
  1601. return;
  1602. }
  1603.  
  1604. # first see what the latest version is
  1605. my $ua = LWP::UserAgent->new();
  1606. $ua->agent("$IRSSI{name}-$IRSSI{version} updater");
  1607. my $req = HTTP::Request->new(GET => "$baseURL/CURRENT");
  1608. my $res = $ua->request($req);
  1609. if (!$res->is_success()) {
  1610. cprint("Problem contacting the mothership: " . $res->status_line());
  1611. return;
  1612. }
  1613.  
  1614. my $latest_version = $res->content(); chomp $latest_version;
  1615. cprint("Your version is: $VERSION");
  1616. cprint("Current version is: $latest_version");
  1617.  
  1618. if ($VERSION >= $latest_version) {
  1619. cprint("You are up to date");
  1620. return;
  1621. }
  1622.  
  1623. # uh oh, old stuff! time to update
  1624. cprint("You are out of date, fetching latest");
  1625. $req = HTTP::Request->new(GET => "$baseURL/$IRSSI{name}-$latest_version.pl");
  1626.  
  1627. my $script_dir = Irssi::get_irssi_dir() . "/scripts";
  1628. my $saveTo = "$script_dir/downloaded-$IRSSI{name}.pl";
  1629. $res = $ua->request($req, $saveTo);
  1630. if (!$res->is_success()) {
  1631. cprint("Problem contacting the mothership: " . $res->status_line());
  1632. return;
  1633. }
  1634.  
  1635. # copy to location
  1636. rename($saveTo, "$script_dir/$IRSSI{name}.pl");
  1637.  
  1638. cprint("Updated successfully! '/run $IRSSI{name}' to load");
  1639. }
  1640.  
  1641.  
  1642. sub spookify {
  1643. # add emacs spook text. if there is previously existing text, it appends
  1644. my $text = shift;
  1645. my $count = settings_get_int('spook_words') || return $text;
  1646. my @spook_words;
  1647. for (my $i = 0; $i < $count; $i++) {
  1648. my $word = $spook_lines[int(rand(0) * scalar(@spook_lines))];
  1649. push(@spook_words, $word);
  1650. }
  1651. $text = join(" ", @spook_words) . " $text";
  1652. return $text;
  1653. }
  1654.  
  1655. sub gwrap {
  1656. # fix that shit
  1657. my $text = shift;
  1658. return if (!defined $text);
  1659.  
  1660. my $wrap = settings_get_int("linewrap") || return $text;
  1661. $Text::Wrap::columns = $wrap;
  1662. my @output;
  1663. foreach my $line (split(/\n/, $text)) {
  1664. local $^W = undef; # silence spurious warnings
  1665. if (length($line) > $wrap) {
  1666. ($line) = Text::Wrap::wrap(undef, undef, $line);
  1667. }
  1668. $line =~ s/\t/ /g;
  1669. push(@output, $line);
  1670. }
  1671.  
  1672. $text = join("\n", @output);
  1673. return $text;
  1674. }
  1675.  
  1676. sub leet {
  1677. # leet speak :(
  1678. my $text = shift;
  1679. return if (!defined $text);
  1680.  
  1681. my @output;
  1682. foreach my $line (split(/\n/, $text)) {
  1683. my $newline;
  1684. for (my $i = 0; $i < length($line); $i++) {
  1685. my $char = lc(substr($line, $i, 1));
  1686. if ($leet_map->{$char}) {
  1687. my @possibles = @{$leet_map->{$char}};
  1688. $char = $possibles[int(rand(0) * scalar(@possibles))];
  1689. }
  1690. $newline .= $char;
  1691. }
  1692. push(@output, $newline);
  1693. }
  1694. return join("\n", @output);
  1695. }
  1696.  
  1697. sub hug {
  1698. my $text = shift;
  1699. return if (!defined $text);
  1700.  
  1701. my @text = split(/\n/, $text);
  1702. my $size = settings_get_int("hug_size");
  1703.  
  1704. # what is the longest line
  1705. my $length = 0;
  1706. foreach my $line (@text) {
  1707. $length = clean_length($line) if clean_length($line) > $length;
  1708. }
  1709.  
  1710.  
  1711. my @output;
  1712. foreach my $line (@text) {
  1713. $line = ("{" x $size) . ' ' . $line . (' ' x ($length - length($line))) . ' ' . ("}" x $size);
  1714. push(@output, $line);
  1715. }
  1716.  
  1717. return join("\n", @output);
  1718. }
  1719.  
  1720. sub reverse_ascii {
  1721. #####################
  1722. # reverse ascii art #
  1723. #####################
  1724.  
  1725. my $text = shift;
  1726. return if (!defined $text);
  1727.  
  1728. my @lines = split(/\n/, $text);
  1729.  
  1730. # how big is the longest line
  1731. my $length = 0;
  1732. foreach my $line (@lines) {
  1733. my $line_length = clean_length($line);
  1734. $length = $line_length if ($line_length > $length);
  1735. }
  1736.  
  1737. my @output;
  1738. foreach my $line (@lines) {
  1739. if ($line =~ /$COWCUT/) {
  1740. push(@output, $line);
  1741. } else {
  1742. $line =~ s!/!$rnd!g; $line =~ s!\\!/!g; $line =~ s!$rnd!\\!g;
  1743. $line =~ s!{!$rnd!g; $line =~ s!}!{!g; $line =~ s!$rnd!}!g;
  1744. $line =~ s!\(!$rnd!g; $line =~ s!\)!(!g; $line =~ s!$rnd!)!g;
  1745. $line =~ s!\[!$rnd!g; $line =~ s!\]![!g; $line =~ s!$rnd!]!g;
  1746. $line =~ s!<!$rnd!g; $line =~ s!>!<!g; $line =~ s!$rnd!>!g;
  1747. push(@output, sprintf("%" . $length . "s", scalar(reverse($line))));
  1748. }
  1749. }
  1750.  
  1751. return join("\n", @output);
  1752. }
  1753.  
  1754. sub upside_down {
  1755. # kind of like reverse_ascii, only on a different axis
  1756. my $text = shift;
  1757. return if (!defined $text);
  1758.  
  1759. my @output;
  1760. foreach my $line (split(/\n/, $text)) {
  1761. $line =~ s!/!$rnd!g; $line =~ s!\\!/!g; $line =~ s!$rnd!\\!g;
  1762. $line =~ s!v!$rnd!g; $line =~ s!\^!v!g; $line =~ s!$rnd!^!g;
  1763. $line =~ s!w!$rnd!g; $line =~ s!m!w!g; $line =~ s!$rnd!m!g;
  1764. $line =~ s!_!-!g;
  1765. unshift(@output, $line);
  1766. }
  1767.  
  1768. return join("\n", @output);
  1769. }
  1770.  
  1771. # irssi is not friendly to require semantic
  1772. # so just use perl's shellwords.pl here
  1773. sub shellwords {
  1774. my $text = join('', @_);
  1775. return if (!defined $text);
  1776.  
  1777. my (@words, $snippet, $field);
  1778.  
  1779. $text =~ s/^\s+//;
  1780.  
  1781. # fix deep recursion case (can't escape newline :P)
  1782. # found by hlprmnky
  1783. if ($text =~ /(?:[^\\]|^)\x5c$/) {
  1784. cprint("Unmatched escape");
  1785. return;
  1786. }
  1787.  
  1788. while ($text ne '') {
  1789. $field = '';
  1790. for (;;) {
  1791. if ($text =~ s/^"(([^"\\]|\\.)*)"//) {
  1792. ($snippet = $1) =~ s#\\(.)#$1#g;
  1793. } elsif ($text =~ /^"/) {
  1794. cprint("Unmatched double quote");
  1795. return;
  1796. } elsif ($text =~ s/^'(([^'\\]|\\.)*)'//) {
  1797. ($snippet = $1) =~ s#\\(.)#$1#g;
  1798. } elsif ($text =~ /^'/) {
  1799. cprint("Unmatched single quote");
  1800. return;
  1801. } elsif ($text =~ s/^\\(.)//) {
  1802. $snippet = $1;
  1803. } elsif ($text =~ s/^([^\s\\'"]+)//) {
  1804. $snippet = $1;
  1805. } else {
  1806. $text =~ s/^\s+//;
  1807. last;
  1808. }
  1809.  
  1810. $field .= $snippet;
  1811. }
  1812. push(@words, $field);
  1813. }
  1814. return @words;
  1815. }
  1816.  
  1817. sub scramble {
  1818. # stupid blog meme about mixing up
  1819. # the inside letters
  1820. my $text = shift;
  1821. return if (!defined $text);
  1822.  
  1823. my @newtext;
  1824. foreach my $line (split(/\n/, $text)) {
  1825. my @newline;
  1826. foreach my $word (split(/\s+/, $line)) {
  1827. my @letters = split(//, $word);
  1828. my $first = shift(@letters);
  1829. my $last = pop(@letters);
  1830. fisher_yates_shuffle(\@letters) if scalar(@letters) > 0;
  1831. my $newline = $first . join('', @letters) . $last;
  1832. push(@newline, $newline);
  1833. }
  1834. push(@newtext, join(" ", @newline));
  1835. }
  1836.  
  1837. $text = join("\n", @newtext);
  1838. return $text;
  1839. }
  1840.  
  1841. sub fisher_yates_shuffle {
  1842. # safe randomizing
  1843. my $array = shift;
  1844. my $i;
  1845. for ($i = @$array; --$i; ) {
  1846. my $j = int rand ($i+1);
  1847. next if $i == $j;
  1848. @$array[$i,$j] = @$array[$j,$i];
  1849. }
  1850. }
  1851.  
  1852. sub ircii_fake {
  1853. # some ansi stuff to obscure the <nick>
  1854. my $text = shift;
  1855. return if (!defined $text);
  1856.  
  1857. my @new;
  1858.  
  1859. foreach my $line (split(/\n/, $text)) {
  1860. $line = "\x85\x8d$line";
  1861. push(@new, $line);
  1862. }
  1863.  
  1864. $text = join("\n", @new);
  1865.  
  1866. return $text;
  1867. }
  1868.  
  1869. sub ircii_drop {
  1870. # this is just evil. move the cursor somewhere
  1871. # inconvenient
  1872.  
  1873. my $text = shift;
  1874. return if (!defined $text);
  1875.  
  1876. $text .= ("\x84" x 23);
  1877.  
  1878. return $text;
  1879. }
  1880.  
  1881. # shift ascii homerow, code by hlprmnky
  1882. # hella copped from leet, above
  1883. sub jigs {
  1884. my $text = shift;
  1885. return if (!defined $text);
  1886.  
  1887. my @output;
  1888. foreach my $line (split(/\n/, $text)) {
  1889. my $newline;
  1890. for (my $i = 0; $i < length($line); $i++) {
  1891. my $char = lc(substr($line, $i, 1));
  1892. if ($jigs_map->{$char}) {
  1893. $char = $jigs_map->{$char};
  1894. }
  1895. $newline .= $char;
  1896. }
  1897. push(@output, $newline);
  1898. }
  1899. return join("\n", @output);
  1900. }
  1901.  
  1902. #######################
  1903. ### christmas stuff ###
  1904. #######################
  1905.  
  1906. sub tree {
  1907. # this is the hardest filter i've ever written :(
  1908. # there must be a more graceful, or at least ideomatic,
  1909. # way of doing this, but i can't think of it.
  1910.  
  1911. my $text = shift;
  1912. return if (!defined $text);
  1913.  
  1914. # bulbs.. only bright primary colors
  1915. my @bulbs = (2,4,6,8,12);
  1916.  
  1917. # don't do this in the loop or you don't get
  1918. # random numbers
  1919. srand(time());
  1920.  
  1921. # cache green
  1922. my $green = 3;
  1923.  
  1924. my @output;
  1925. foreach my $line (split(/\n/, $text)) {
  1926. # it's gotta be at least 3 chars long to work
  1927. unless (length($line) > 2) {
  1928. push(@output, $line);
  1929. next;
  1930. }
  1931.  
  1932. # the inside can't be all whitespace
  1933. if ($line =~ /^.\s+.$/) {
  1934. push(@output, $line);
  1935. next;
  1936. }
  1937.  
  1938. # split line into an array of characters
  1939. my @row = split(//, $line);
  1940.  
  1941. # determine which points can be changed
  1942. my @map;
  1943. for (my $i = 0; $i < scalar(@row); $i++) {
  1944. my $char = $row[$i];
  1945.  
  1946. if ($i == 0 or $i == $#row) {
  1947. push(@map, 0);
  1948. } elsif ($char =~ /\s/) {
  1949. push(@map, 0);
  1950. } else {
  1951. push(@map, 1);
  1952. }
  1953. }
  1954.  
  1955. # (int(rand(0) * (max - min + 1))) + min
  1956. my $max = grep(($_ == 1), @map);
  1957. my $min = 1;
  1958. my $map_pos = (int(rand(0) * ($max - $min + 1))) + $min;
  1959.  
  1960.  
  1961. # god this is such a hack...
  1962. # figure out which part of @map we mean
  1963. my $count = 0;
  1964. my $actual;
  1965. for (my $i = 0; $i < scalar(@map); $i++) {
  1966. my $map = $map[$i];
  1967.  
  1968. if ($map == 1) {
  1969. $count++;
  1970. }
  1971.  
  1972. if ($count == $map_pos) {
  1973. $actual = $i;
  1974. last;
  1975. }
  1976. }
  1977.  
  1978.  
  1979. my ($head, $bulb, $foot);
  1980. my $switch = 0;
  1981. for (my $i = 0; $i < scalar(@row); $i++) {
  1982. if ($i == $actual) {
  1983. my $color = $bulbs[rand(@bulbs)];
  1984. $bulb = do_color("*", $color);
  1985. $switch++;
  1986. } elsif ($switch == 0) {
  1987. $head .= $row[$i];
  1988. } elsif ($switch == 1) {
  1989. $foot .= $row[$i];
  1990. }
  1991. }
  1992.  
  1993. my $newline = do_color($head, $green) . $bulb . do_color($foot, $green);
  1994. push(@output, $newline);
  1995. }
  1996.  
  1997. $text = join("\n", @output);
  1998. return $text;
  1999. }
  2000.  
  2001. sub rotate {
  2002. my $text = shift;
  2003. return if (!defined $text);
  2004.  
  2005. my @lines = split(/\r?\n/, $text);
  2006. my @new;
  2007. foreach my $line (reverse @lines) {
  2008. my @cols = reverse split('', $line);
  2009. for (my $i = 0; $i < @cols; $i++) {
  2010. $new[$i] .= $cols[$i];
  2011. }
  2012. }
  2013. $text = join("\n", reverse @new);
  2014. return $text;
  2015. }
  2016.  
  2017. sub diagonal {
  2018. my $text = shift;
  2019. return if (!defined $text);
  2020.  
  2021. my $new;
  2022. for (my $i = 0; $i < length($text); $i++) {
  2023. $new .= sprintf "%s%s\n", (" " x $i), substr($text, $i, 1);
  2024. }
  2025.  
  2026. return $new;
  2027. }
  2028.  
  2029. sub popeye {
  2030. my $text = shift;
  2031. return if (!defined $text);
  2032.  
  2033. my $spacer = 0;
  2034. my $new;
  2035. foreach my $word (split(/\s+/, $text)) {
  2036. $new .= (" " x $spacer) . $word . "\n";
  2037. $spacer += length($word);
  2038. }
  2039.  
  2040. return $new;
  2041. }
  2042.  
  2043. sub sine {
  2044. my $text = shift;
  2045. return if (!defined $text);
  2046.  
  2047. my $freq = settings_get_str("sine_frequency");
  2048. my $height = settings_get_int("sine_height");
  2049. my $bg = settings_get_str("sine_background");
  2050.  
  2051. $bg ||= " ";
  2052.  
  2053. return unless ($freq > 0);
  2054.  
  2055. my @output;
  2056. my $lineNO = 0;
  2057. foreach my $line (split(/\n/, $text)) {
  2058. my @chrs = split(//, $line);
  2059. my $width = @chrs * $freq;
  2060.  
  2061. my $plot = {};
  2062. my $x = 0;
  2063. foreach my $chr (@chrs) {
  2064. my $y = int($height * sin($x)) + $height;
  2065. $plot->{$x}->{$y} = $chr;
  2066. $x += $freq;
  2067. }
  2068.  
  2069. for (my $y = 0; $y <= $height * 2; $y++) {
  2070. for (my $x = 0; $x <= $width; $x += $freq) {
  2071. if (exists $plot->{$x}->{$y}) {
  2072. $output[$lineNO] .= $plot->{$x}->{$y};
  2073. } else {
  2074. $output[$lineNO] .= $bg;
  2075. }
  2076. }
  2077.  
  2078. $lineNO++;
  2079. }
  2080. }
  2081.  
  2082. my @cleaned;
  2083. foreach my $line (@output) {
  2084. next if $line =~ /^[$bg]+$/;
  2085. $line =~ s/[$bg]+$//;
  2086. push(@cleaned, $line);
  2087. }
  2088.  
  2089. $text = join("\n", @cleaned);
  2090.  
  2091. return $text;
  2092. }
  2093.  
  2094. sub banner {
  2095. my $text = shift;
  2096. return if (!defined $text);
  2097.  
  2098. my $style = shift;
  2099.  
  2100. my @chrs = split(//, $text);
  2101. my $iter = 0;
  2102.  
  2103. my $output;
  2104. foreach my $chr (@chrs) {
  2105. $chr =~ s/[\r\n]/ /;
  2106. my $banner = perlBanner($chr);
  2107. next if (!defined $banner); # remove if you don't want to die for unknowns
  2108.  
  2109. if ($style eq "phrase") {
  2110. foreach my $bchr (split(//, $banner)) {
  2111. if ($bchr =~ s/#/$chr/) {
  2112. $iter = 0 if ++$iter >= @chrs;
  2113. }
  2114. $output .= $bchr;
  2115. }
  2116. }
  2117.  
  2118. elsif ($style eq "line") {
  2119. foreach my $line (split(/\n/, $banner)) {
  2120. if ($line =~ s/#/$chr/g) {
  2121. $iter = 0 if ++$iter > (@chrs - 1);
  2122. }
  2123. $output .= "$line\n";
  2124. }
  2125. }
  2126.  
  2127. elsif ($style eq "letter") {
  2128. $banner =~ s/#/$chr/g;
  2129. $output .= $banner;
  2130. }
  2131.  
  2132. elsif ($style =~ /char:(.)/) {
  2133. my $chr = $1;
  2134. $banner =~ s/#/$chr/g;
  2135. $output .= $banner;
  2136. }
  2137. }
  2138.  
  2139. return $output;
  2140. }
  2141.  
  2142. ####################################
  2143. # port of c banner utility to perl #
  2144. ####################################
  2145.  
  2146. # defaults/constants
  2147. my $MAXMSG = 1024;
  2148. my $DWIDTH = 132;
  2149. my $NCHARS = 128;
  2150. my $NBYTES = 9470; # This really ought to be generated from the array
  2151.  
  2152. # Pointers into data_table for each ASCII char
  2153. my @asc_ptr = (
  2154. # 0 1 2 3 4 5 6 7 Octal :(
  2155. 0, 0, 0, 0, 0, 0, 0, 0, # ^@ 000
  2156. 0, 0, 0, 0, 0, 0, 0, 0, # ^H 010
  2157. 0, 0, 0, 0, 0, 0, 0, 0, # ^P 020
  2158. 0, 0, 0, 0, 0, 0, 0, 0, # ^X 030
  2159. 1, 3, 50, 81, 104, 281, 483, 590, # 040
  2160. 621, 685, 749, 851, 862, 893, 898, 921, # ( 050
  2161. 1019, 1150, 1200, 1419, 1599, 1744, 1934, 2111, # 0 060
  2162. 2235, 2445, 2622, 2659, 9271, 2708, 9371, 2715, # 8 070
  2163. 2857, 3072, 3273, 3403, 3560, 3662, 3730, 3785, # @ 100
  2164. 3965, 4000, 4015, 4115, 4281, 4314, 4432, 4548, # H 110
  2165. 4709, 4790, 4999, 5188, 5397, 5448, 5576, 5710, # P 120
  2166. 5892, 6106, 6257, 0, 0, 0, 0, 0, # X 130
  2167. 50, 6503, 6642, 6733, 6837, 6930, 7073, 7157, # ` 140
  2168. 7380, 7452, 7499, 7584, 7689, 7702, 7797, 7869, # h 150
  2169. 7978, 8069, 8160, 8222, 8381, 8442, 8508, 8605, # p 160
  2170. 8732, 8888, 9016, 0, 0, 0, 0, 0 # x 170
  2171. );
  2172.  
  2173. # Table of stuff to print. Format:
  2174. # 128+n -> print current line n times.
  2175. # 64+n -> this is last byte of char.
  2176. # else, put m chars at position n (where m
  2177. # is the next elt in array) and goto second
  2178. # next element in array.
  2179.  
  2180. # If you add new data, please be sane and add it to the end :<
  2181.  
  2182. my @data_table = (
  2183. # 0 1 2 3 4 5 6 7 8 9
  2184. 129, 227, 130, 34, 6, 90, 19, 129, 32, 10, # 0
  2185. 74, 40, 129, 31, 12, 64, 53, 129, 30, 14, # 10
  2186. 54, 65, 129, 30, 14, 53, 67, 129, 30, 14, # 20
  2187. 54, 65, 129, 31, 12, 64, 53, 129, 32, 10, # 30
  2188. 74, 40, 129, 34, 6, 90, 19, 129, 194, 130, # 40
  2189. 99, 9, 129, 97, 14, 129, 96, 18, 129, 95, # 50
  2190. 22, 129, 95, 16, 117, 2, 129, 95, 14, 129, # 60
  2191. 96, 11, 129, 97, 9, 129, 99, 6, 129, 194, # 70
  2192. 129, 87, 4, 101, 4, 131, 82, 28, 131, 87, # 80
  2193. 4, 101, 4, 133, 82, 28, 131, 87, 4, 101, # 90
  2194. 4, 131, 193, 129, 39, 1, 84, 27, 129, 38, # 100
  2195. 3, 81, 32, 129, 37, 5, 79, 35, 129, 36, # 110
  2196. 5, 77, 38, 129, 35, 5, 76, 40, 129, 34, # 120
  2197. 5, 75, 21, 103, 14, 129, 33, 5, 74, 19, # 130
  2198. 107, 11, 129, 32, 5, 73, 17, 110, 9, 129, # 140
  2199. 32, 4, 73, 16, 112, 7, 129, 31, 4, 72, # 150
  2200. 15, 114, 6, 129, 31, 4, 72, 14, 115, 5, # 160
  2201. 129, 30, 4, 71, 15, 116, 5, 129, 27, 97, # 170
  2202. 131, 30, 4, 69, 14, 117, 4, 129, 30, 4, # 180
  2203. 68, 15, 117, 4, 132, 30, 4, 68, 14, 117, # 190
  2204. 4, 129, 27, 97, 131, 30, 5, 65, 15, 116, # 200
  2205. 5, 129, 31, 4, 65, 14, 116, 4, 129, 31, # 210
  2206. 6, 64, 15, 116, 4, 129, 32, 7, 62, 16, # 220
  2207. 115, 4, 129, 32, 9, 61, 17, 114, 5, 129, # 230
  2208. 33, 11, 58, 19, 113, 5, 129, 34, 14, 55, # 240
  2209. 21, 112, 5, 129, 35, 40, 111, 5, 129, 36, # 250
  2210. 38, 110, 5, 129, 37, 35, 109, 5, 129, 38, # 260
  2211. 32, 110, 3, 129, 40, 27, 111, 1, 129, 193, # 270
  2212. 129, 30, 4, 103, 9, 129, 30, 7, 100, 15, # 280
  2213. 129, 30, 10, 99, 17, 129, 33, 10, 97, 6, # 290
  2214. 112, 6, 129, 36, 10, 96, 5, 114, 5, 129, # 300
  2215. 39, 10, 96, 4, 115, 4, 129, 42, 10, 95, # 310
  2216. 4, 116, 4, 129, 45, 10, 95, 3, 117, 3, # 320
  2217. 129, 48, 10, 95, 3, 117, 3, 129, 51, 10, # 330
  2218. 95, 4, 116, 4, 129, 54, 10, 96, 4, 115, # 340
  2219. 4, 129, 57, 10, 96, 5, 114, 5, 129, 60, # 350
  2220. 10, 97, 6, 112, 6, 129, 63, 10, 99, 17, # 360
  2221. 129, 66, 10, 100, 15, 129, 69, 10, 103, 9, # 370
  2222. 129, 39, 9, 72, 10, 129, 36, 15, 75, 10, # 380
  2223. 129, 35, 17, 78, 10, 129, 33, 6, 48, 6, # 390
  2224. 81, 10, 129, 32, 5, 50, 5, 84, 10, 129, # 400
  2225. 32, 4, 51, 4, 87, 10, 129, 31, 4, 52, # 410
  2226. 4, 90, 10, 129, 31, 3, 53, 3, 93, 10, # 420
  2227. 129, 31, 3, 53, 3, 96, 10, 129, 31, 4, # 430
  2228. 52, 4, 99, 10, 129, 32, 4, 51, 4, 102, # 440
  2229. 10, 129, 32, 5, 50, 5, 105, 10, 129, 33, # 450
  2230. 6, 48, 6, 108, 10, 129, 35, 17, 111, 10, # 460
  2231. 129, 36, 15, 114, 7, 129, 40, 9, 118, 4, # 470
  2232. 129, 193, 129, 48, 18, 129, 43, 28, 129, 41, # 480
  2233. 32, 129, 39, 36, 129, 37, 40, 129, 35, 44, # 490
  2234. 129, 34, 46, 129, 33, 13, 68, 13, 129, 32, # 500
  2235. 9, 73, 9, 129, 32, 7, 75, 7, 129, 31, # 510
  2236. 6, 77, 6, 129, 31, 5, 78, 5, 129, 30, # 520
  2237. 5, 79, 5, 129, 20, 74, 132, 30, 4, 80, # 530
  2238. 4, 129, 31, 3, 79, 4, 129, 31, 4, 79, # 540
  2239. 4, 129, 32, 3, 78, 4, 129, 32, 4, 76, # 550
  2240. 6, 129, 33, 4, 74, 7, 129, 34, 4, 72, # 560
  2241. 8, 129, 35, 5, 72, 7, 129, 37, 5, 73, # 570
  2242. 4, 129, 39, 4, 74, 1, 129, 129, 193, 130, # 580
  2243. 111, 6, 129, 109, 10, 129, 108, 12, 129, 107, # 590
  2244. 14, 129, 97, 2, 105, 16, 129, 99, 22, 129, # 600
  2245. 102, 18, 129, 105, 14, 129, 108, 9, 129, 194, # 610
  2246. 130, 63, 25, 129, 57, 37, 129, 52, 47, 129, # 620
  2247. 48, 55, 129, 44, 63, 129, 41, 69, 129, 38, # 630
  2248. 75, 129, 36, 79, 129, 34, 83, 129, 33, 28, # 640
  2249. 90, 28, 129, 32, 23, 96, 23, 129, 32, 17, # 650
  2250. 102, 17, 129, 31, 13, 107, 13, 129, 30, 9, # 660
  2251. 112, 9, 129, 30, 5, 116, 5, 129, 30, 1, # 670
  2252. 120, 1, 129, 194, 130, 30, 1, 120, 1, 129, # 680
  2253. 30, 5, 116, 5, 129, 30, 9, 112, 9, 129, # 690
  2254. 31, 13, 107, 13, 129, 32, 17, 102, 17, 129, # 700
  2255. 32, 23, 96, 23, 129, 33, 28, 90, 28, 129, # 710
  2256. 34, 83, 129, 36, 79, 129, 38, 75, 129, 41, # 720
  2257. 69, 129, 44, 63, 129, 48, 55, 129, 52, 47, # 730
  2258. 129, 57, 37, 129, 63, 25, 129, 194, 129, 80, # 740
  2259. 4, 130, 80, 4, 129, 68, 2, 80, 4, 94, # 750
  2260. 2, 129, 66, 6, 80, 4, 92, 6, 129, 67, # 760
  2261. 7, 80, 4, 90, 7, 129, 69, 7, 80, 4, # 770
  2262. 88, 7, 129, 71, 6, 80, 4, 87, 6, 129, # 780
  2263. 72, 20, 129, 74, 16, 129, 76, 12, 129, 62, # 790
  2264. 40, 131, 76, 12, 129, 74, 16, 129, 72, 20, # 800
  2265. 129, 71, 6, 80, 4, 87, 6, 129, 69, 7, # 810
  2266. 80, 4, 88, 7, 129, 67, 7, 80, 4, 90, # 820
  2267. 7, 129, 66, 6, 80, 4, 92, 6, 129, 68, # 830
  2268. 2, 80, 4, 94, 2, 129, 80, 4, 130, 193, # 840
  2269. 129, 60, 4, 139, 41, 42, 131, 60, 4, 139, # 850
  2270. 193, 130, 34, 6, 129, 32, 10, 129, 31, 12, # 860
  2271. 129, 30, 14, 129, 20, 2, 28, 16, 129, 22, # 870
  2272. 22, 129, 24, 19, 129, 27, 15, 129, 31, 9, # 880
  2273. 129, 194, 129, 60, 4, 152, 193, 130, 34, 6, # 890
  2274. 129, 32, 10, 129, 31, 12, 129, 30, 14, 131, # 900
  2275. 31, 12, 129, 32, 10, 129, 34, 6, 129, 194, # 910
  2276. 129, 30, 4, 129, 30, 7, 129, 30, 10, 129, # 920
  2277. 33, 10, 129, 36, 10, 129, 39, 10, 129, 42, # 930
  2278. 10, 129, 45, 10, 129, 48, 10, 129, 51, 10, # 940
  2279. 129, 54, 10, 129, 57, 10, 129, 60, 10, 129, # 950
  2280. 63, 10, 129, 66, 10, 129, 69, 10, 129, 72, # 960
  2281. 10, 129, 75, 10, 129, 78, 10, 129, 81, 10, # 970
  2282. 129, 84, 10, 129, 87, 10, 129, 90, 10, 129, # 980
  2283. 93, 10, 129, 96, 10, 129, 99, 10, 129, 102, # 990
  2284. 10, 129, 105, 10, 129, 108, 10, 129, 111, 10, # 1000
  2285. 129, 114, 7, 129, 117, 4, 129, 193, 129, 60, # 1010
  2286. 31, 129, 53, 45, 129, 49, 53, 129, 46, 59, # 1020
  2287. 129, 43, 65, 129, 41, 69, 129, 39, 73, 129, # 1030
  2288. 37, 77, 129, 36, 79, 129, 35, 15, 101, 15, # 1040
  2289. 129, 34, 11, 106, 11, 129, 33, 9, 109, 9, # 1050
  2290. 129, 32, 7, 112, 7, 129, 31, 6, 114, 6, # 1060
  2291. 129, 31, 5, 115, 5, 129, 30, 5, 116, 5, # 1070
  2292. 129, 30, 4, 117, 4, 132, 30, 5, 116, 5, # 1080
  2293. 129, 31, 5, 115, 5, 129, 31, 6, 114, 6, # 1090
  2294. 129, 32, 7, 112, 7, 129, 33, 9, 109, 9, # 1100
  2295. 129, 34, 11, 106, 11, 129, 35, 15, 101, 15, # 1110
  2296. 129, 36, 79, 129, 37, 77, 129, 39, 73, 129, # 1120
  2297. 41, 69, 129, 43, 65, 129, 46, 59, 129, 49, # 1130
  2298. 53, 129, 53, 45, 129, 60, 31, 129, 193, 129, # 1140
  2299. 30, 4, 129, 30, 4, 100, 1, 129, 30, 4, # 1150
  2300. 100, 3, 129, 30, 4, 100, 5, 129, 30, 76, # 1160
  2301. 129, 30, 78, 129, 30, 80, 129, 30, 82, 129, # 1170
  2302. 30, 83, 129, 30, 85, 129, 30, 87, 129, 30, # 1180
  2303. 89, 129, 30, 91, 129, 30, 4, 132, 193, 129, # 1190
  2304. 30, 3, 129, 30, 7, 129, 30, 10, 112, 1, # 1200
  2305. 129, 30, 13, 112, 2, 129, 30, 16, 112, 3, # 1210
  2306. 129, 30, 18, 111, 5, 129, 30, 21, 111, 6, # 1220
  2307. 129, 30, 23, 112, 6, 129, 30, 14, 47, 8, # 1230
  2308. 113, 6, 129, 30, 14, 49, 8, 114, 5, 129, # 1240
  2309. 30, 14, 51, 8, 115, 5, 129, 30, 14, 53, # 1250
  2310. 8, 116, 4, 129, 30, 14, 55, 8, 116, 5, # 1260
  2311. 129, 30, 14, 56, 9, 117, 4, 129, 30, 14, # 1270
  2312. 57, 9, 117, 4, 129, 30, 14, 58, 10, 117, # 1280
  2313. 4, 129, 30, 14, 59, 10, 117, 4, 129, 30, # 1290
  2314. 14, 60, 11, 117, 4, 129, 30, 14, 61, 11, # 1300
  2315. 116, 5, 129, 30, 14, 62, 11, 116, 5, 129, # 1310
  2316. 30, 14, 63, 12, 115, 6, 129, 30, 14, 64, # 1320
  2317. 13, 114, 7, 129, 30, 14, 65, 13, 113, 8, # 1330
  2318. 129, 30, 14, 65, 15, 111, 9, 129, 30, 14, # 1340
  2319. 66, 16, 109, 11, 129, 30, 14, 67, 17, 107, # 1350
  2320. 12, 129, 30, 14, 68, 20, 103, 16, 129, 30, # 1360
  2321. 14, 69, 49, 129, 30, 14, 70, 47, 129, 30, # 1370
  2322. 14, 71, 45, 129, 30, 14, 73, 42, 129, 30, # 1380
  2323. 15, 75, 38, 129, 33, 12, 77, 34, 129, 36, # 1390
  2324. 10, 79, 30, 129, 40, 6, 82, 23, 129, 44, # 1400
  2325. 3, 86, 15, 129, 47, 1, 129, 193, 129, 129, # 1410
  2326. 38, 3, 129, 37, 5, 111, 1, 129, 36, 7, # 1420
  2327. 111, 2, 129, 35, 9, 110, 5, 129, 34, 8, # 1430
  2328. 110, 6, 129, 33, 7, 109, 8, 129, 32, 7, # 1440
  2329. 110, 8, 129, 32, 6, 112, 7, 129, 31, 6, # 1450
  2330. 113, 6, 129, 31, 5, 114, 6, 129, 30, 5, # 1460
  2331. 115, 5, 129, 30, 5, 116, 4, 129, 30, 4, # 1470
  2332. 117, 4, 131, 30, 4, 117, 4, 129, 30, 4, # 1480
  2333. 79, 2, 117, 4, 129, 30, 5, 78, 4, 117, # 1490
  2334. 4, 129, 30, 5, 77, 6, 116, 5, 129, 30, # 1500
  2335. 6, 76, 8, 115, 6, 129, 30, 7, 75, 11, # 1510
  2336. 114, 6, 129, 30, 8, 73, 15, 112, 8, 129, # 1520
  2337. 31, 9, 71, 19, 110, 9, 129, 31, 11, 68, # 1530
  2338. 26, 107, 12, 129, 32, 13, 65, 14, 82, 36, # 1540
  2339. 129, 32, 16, 61, 17, 83, 34, 129, 33, 44, # 1550
  2340. 84, 32, 129, 34, 42, 85, 30, 129, 35, 40, # 1560
  2341. 87, 27, 129, 36, 38, 89, 23, 129, 38, 34, # 1570
  2342. 92, 17, 129, 40, 30, 95, 11, 129, 42, 26, # 1580
  2343. 129, 45, 20, 129, 49, 11, 129, 193, 129, 49, # 1590
  2344. 1, 129, 49, 4, 129, 49, 6, 129, 49, 8, # 1600
  2345. 129, 49, 10, 129, 49, 12, 129, 49, 14, 129, # 1610
  2346. 49, 17, 129, 49, 19, 129, 49, 21, 129, 49, # 1620
  2347. 23, 129, 49, 14, 65, 9, 129, 49, 14, 67, # 1630
  2348. 9, 129, 49, 14, 69, 9, 129, 49, 14, 71, # 1640
  2349. 10, 129, 49, 14, 74, 9, 129, 49, 14, 76, # 1650
  2350. 9, 129, 49, 14, 78, 9, 129, 49, 14, 80, # 1660
  2351. 9, 129, 49, 14, 82, 9, 129, 49, 14, 84, # 1670
  2352. 9, 129, 30, 4, 49, 14, 86, 10, 129, 30, # 1680
  2353. 4, 49, 14, 89, 9, 129, 30, 4, 49, 14, # 1690
  2354. 91, 9, 129, 30, 4, 49, 14, 93, 9, 129, # 1700
  2355. 30, 74, 129, 30, 76, 129, 30, 78, 129, 30, # 1710
  2356. 81, 129, 30, 83, 129, 30, 85, 129, 30, 87, # 1720
  2357. 129, 30, 89, 129, 30, 91, 129, 30, 4, 49, # 1730
  2358. 14, 132, 193, 129, 37, 1, 129, 36, 3, 77, # 1740
  2359. 3, 129, 35, 5, 78, 11, 129, 34, 7, 78, # 1750
  2360. 21, 129, 33, 7, 79, 29, 129, 32, 7, 79, # 1760
  2361. 38, 129, 32, 6, 80, 4, 92, 29, 129, 31, # 1770
  2362. 6, 80, 5, 102, 19, 129, 31, 5, 80, 6, # 1780
  2363. 107, 14, 129, 31, 4, 81, 5, 107, 14, 129, # 1790
  2364. 30, 5, 81, 6, 107, 14, 129, 30, 4, 81, # 1800
  2365. 6, 107, 14, 130, 30, 4, 81, 7, 107, 14, # 1810
  2366. 129, 30, 4, 80, 8, 107, 14, 130, 30, 5, # 1820
  2367. 80, 8, 107, 14, 129, 30, 5, 79, 9, 107, # 1830
  2368. 14, 129, 31, 5, 79, 9, 107, 14, 129, 31, # 1840
  2369. 6, 78, 10, 107, 14, 129, 32, 6, 76, 11, # 1850
  2370. 107, 14, 129, 32, 8, 74, 13, 107, 14, 129, # 1860
  2371. 33, 10, 71, 16, 107, 14, 129, 33, 15, 67, # 1870
  2372. 19, 107, 14, 129, 34, 51, 107, 14, 129, 35, # 1880
  2373. 49, 107, 14, 129, 36, 47, 107, 14, 129, 37, # 1890
  2374. 45, 107, 14, 129, 39, 41, 107, 14, 129, 41, # 1900
  2375. 37, 107, 14, 129, 44, 32, 107, 14, 129, 47, # 1910
  2376. 25, 111, 10, 129, 51, 16, 115, 6, 129, 119, # 1920
  2377. 2, 129, 193, 129, 56, 39, 129, 51, 49, 129, # 1930
  2378. 47, 57, 129, 44, 63, 129, 42, 67, 129, 40, # 1940
  2379. 71, 129, 38, 75, 129, 37, 77, 129, 35, 81, # 1950
  2380. 129, 34, 16, 74, 5, 101, 16, 129, 33, 11, # 1960
  2381. 76, 5, 107, 11, 129, 32, 9, 77, 5, 110, # 1970
  2382. 9, 129, 32, 7, 79, 4, 112, 7, 129, 31, # 1980
  2383. 6, 80, 4, 114, 6, 129, 31, 5, 81, 4, # 1990
  2384. 115, 5, 129, 30, 5, 82, 4, 116, 5, 129, # 2000
  2385. 30, 4, 82, 4, 116, 5, 129, 30, 4, 82, # 2010
  2386. 5, 117, 4, 131, 30, 5, 82, 5, 117, 4, # 2020
  2387. 129, 31, 5, 81, 6, 117, 4, 129, 31, 6, # 2030
  2388. 80, 7, 117, 4, 129, 32, 7, 79, 8, 117, # 2040
  2389. 4, 129, 32, 9, 77, 9, 116, 5, 129, 33, # 2050
  2390. 11, 75, 11, 116, 4, 129, 34, 16, 69, 16, # 2060
  2391. 115, 5, 129, 35, 49, 114, 5, 129, 37, 46, # 2070
  2392. 113, 5, 129, 38, 44, 112, 6, 129, 40, 41, # 2080
  2393. 112, 5, 129, 42, 37, 113, 3, 129, 44, 33, # 2090
  2394. 114, 1, 129, 47, 27, 129, 51, 17, 129, 193, # 2100
  2395. 129, 103, 2, 129, 103, 6, 129, 104, 9, 129, # 2110
  2396. 105, 12, 129, 106, 15, 129, 107, 14, 135, 30, # 2120
  2397. 10, 107, 14, 129, 30, 17, 107, 14, 129, 30, # 2130
  2398. 25, 107, 14, 129, 30, 31, 107, 14, 129, 30, # 2140
  2399. 37, 107, 14, 129, 30, 42, 107, 14, 129, 30, # 2150
  2400. 46, 107, 14, 129, 30, 50, 107, 14, 129, 30, # 2160
  2401. 54, 107, 14, 129, 30, 58, 107, 14, 129, 59, # 2170
  2402. 32, 107, 14, 129, 64, 30, 107, 14, 129, 74, # 2180
  2403. 23, 107, 14, 129, 81, 18, 107, 14, 129, 86, # 2190
  2404. 16, 107, 14, 129, 91, 14, 107, 14, 129, 96, # 2200
  2405. 25, 129, 100, 21, 129, 104, 17, 129, 107, 14, # 2210
  2406. 129, 111, 10, 129, 114, 7, 129, 117, 4, 129, # 2220
  2407. 120, 1, 129, 193, 129, 48, 13, 129, 44, 21, # 2230
  2408. 129, 42, 26, 129, 40, 30, 92, 12, 129, 38, # 2240
  2409. 34, 88, 20, 129, 36, 37, 86, 25, 129, 35, # 2250
  2410. 39, 84, 29, 129, 34, 13, 63, 12, 82, 33, # 2260
  2411. 129, 33, 11, 67, 9, 80, 36, 129, 32, 9, # 2270
  2412. 70, 7, 79, 38, 129, 31, 8, 72, 46, 129, # 2280
  2413. 30, 7, 74, 22, 108, 11, 129, 30, 6, 75, # 2290
  2414. 19, 111, 9, 129, 30, 5, 75, 17, 113, 7, # 2300
  2415. 129, 30, 5, 74, 16, 114, 6, 129, 30, 4, # 2310
  2416. 73, 16, 115, 6, 129, 30, 4, 72, 16, 116, # 2320
  2417. 5, 129, 30, 4, 72, 15, 117, 4, 129, 30, # 2330
  2418. 4, 71, 16, 117, 4, 129, 30, 5, 70, 16, # 2340
  2419. 117, 4, 129, 30, 5, 70, 15, 117, 4, 129, # 2350
  2420. 30, 6, 69, 15, 116, 5, 129, 30, 7, 68, # 2360
  2421. 17, 115, 5, 129, 30, 9, 67, 19, 114, 6, # 2370
  2422. 129, 30, 10, 65, 22, 113, 6, 129, 31, 12, # 2380
  2423. 63, 27, 110, 9, 129, 32, 14, 60, 21, 84, # 2390
  2424. 9, 106, 12, 129, 33, 47, 85, 32, 129, 34, # 2400
  2425. 45, 86, 30, 129, 35, 43, 88, 26, 129, 36, # 2410
  2426. 40, 90, 22, 129, 38, 36, 93, 17, 129, 40, # 2420
  2427. 32, 96, 10, 129, 42, 28, 129, 44, 23, 129, # 2430
  2428. 48, 15, 129, 193, 129, 83, 17, 129, 77, 27, # 2440
  2429. 129, 36, 1, 74, 33, 129, 35, 3, 72, 37, # 2450
  2430. 129, 34, 5, 70, 41, 129, 33, 6, 69, 44, # 2460
  2431. 129, 33, 5, 68, 46, 129, 32, 5, 67, 49, # 2470
  2432. 129, 31, 5, 66, 17, 101, 16, 129, 31, 5, # 2480
  2433. 66, 11, 108, 10, 129, 30, 4, 65, 9, 110, # 2490
  2434. 9, 129, 30, 4, 64, 8, 112, 7, 129, 30, # 2500
  2435. 4, 64, 7, 114, 6, 129, 30, 4, 64, 6, # 2510
  2436. 115, 5, 129, 30, 4, 64, 5, 116, 5, 129, # 2520
  2437. 30, 4, 64, 5, 117, 4, 131, 30, 4, 65, # 2530
  2438. 4, 117, 4, 129, 30, 5, 65, 4, 116, 5, # 2540
  2439. 129, 31, 5, 66, 4, 115, 5, 129, 31, 6, # 2550
  2440. 67, 4, 114, 6, 129, 32, 7, 68, 4, 112, # 2560
  2441. 7, 129, 32, 9, 69, 5, 110, 9, 129, 33, # 2570
  2442. 11, 70, 5, 107, 11, 129, 34, 16, 72, 5, # 2580
  2443. 101, 16, 129, 35, 81, 129, 37, 77, 129, 38, # 2590
  2444. 75, 129, 40, 71, 129, 42, 67, 129, 44, 63, # 2600
  2445. 129, 47, 57, 129, 51, 49, 129, 56, 39, 129, # 2610
  2446. 193, 130, 34, 6, 74, 6, 129, 32, 10, 72, # 2620
  2447. 10, 129, 31, 12, 71, 12, 129, 30, 14, 70, # 2630
  2448. 14, 131, 31, 12, 71, 12, 129, 32, 10, 72, # 2640
  2449. 10, 129, 34, 6, 74, 6, 129, 194, 130, 34, # 2650
  2450. 6, 74, 6, 129, 32, 10, 72, 10, 129, 31, # 2660
  2451. 12, 71, 12, 129, 30, 14, 70, 14, 129, 20, # 2670
  2452. 2, 28, 16, 70, 14, 129, 22, 22, 70, 14, # 2680
  2453. 129, 24, 19, 71, 12, 129, 27, 15, 72, 10, # 2690
  2454. 129, 31, 9, 74, 6, 129, 194, 129, 53, 4, # 2700
  2455. 63, 4, 152, 193, 130, 99, 7, 129, 97, 13, # 2710
  2456. 129, 96, 16, 129, 96, 18, 129, 96, 19, 129, # 2720
  2457. 97, 19, 129, 99, 6, 110, 7, 129, 112, 6, # 2730
  2458. 129, 114, 5, 129, 34, 6, 57, 5, 115, 4, # 2740
  2459. 129, 32, 10, 54, 12, 116, 4, 129, 31, 12, # 2750
  2460. 53, 16, 117, 3, 129, 30, 14, 52, 20, 117, # 2760
  2461. 4, 129, 30, 14, 52, 23, 117, 4, 129, 30, # 2770
  2462. 14, 52, 25, 117, 4, 129, 31, 12, 52, 27, # 2780
  2463. 117, 4, 129, 32, 10, 53, 10, 70, 11, 116, # 2790
  2464. 5, 129, 34, 6, 55, 5, 73, 10, 115, 6, # 2800
  2465. 129, 74, 11, 114, 7, 129, 75, 12, 112, 9, # 2810
  2466. 129, 76, 13, 110, 10, 129, 77, 16, 106, 14, # 2820
  2467. 129, 78, 41, 129, 80, 38, 129, 81, 36, 129, # 2830
  2468. 82, 34, 129, 84, 30, 129, 86, 26, 129, 88, # 2840
  2469. 22, 129, 92, 14, 129, 194, 129, 55, 15, 129, # 2850
  2470. 50, 25, 129, 47, 32, 129, 45, 13, 70, 12, # 2860
  2471. 129, 43, 9, 76, 10, 129, 42, 6, 79, 8, # 2870
  2472. 129, 41, 5, 81, 7, 129, 40, 4, 84, 6, # 2880
  2473. 129, 39, 4, 59, 12, 85, 6, 129, 38, 4, # 2890
  2474. 55, 19, 87, 5, 129, 37, 4, 53, 23, 88, # 2900
  2475. 4, 129, 36, 4, 51, 8, 71, 6, 89, 4, # 2910
  2476. 129, 36, 4, 51, 6, 73, 4, 89, 4, 129, # 2920
  2477. 36, 4, 50, 6, 74, 4, 90, 3, 129, 35, # 2930
  2478. 4, 50, 5, 75, 3, 90, 4, 129, 35, 4, # 2940
  2479. 50, 4, 75, 4, 90, 4, 131, 35, 4, 50, # 2950
  2480. 5, 75, 4, 90, 4, 129, 36, 4, 51, 5, # 2960
  2481. 75, 4, 90, 4, 129, 36, 4, 51, 6, 75, # 2970
  2482. 4, 90, 4, 129, 36, 4, 53, 26, 90, 4, # 2980
  2483. 129, 37, 4, 54, 25, 90, 4, 129, 37, 4, # 2990
  2484. 52, 27, 90, 3, 129, 38, 4, 52, 4, 89, # 3000
  2485. 4, 129, 39, 4, 51, 4, 88, 4, 129, 40, # 3010
  2486. 4, 50, 4, 87, 5, 129, 41, 4, 50, 4, # 3020
  2487. 86, 5, 129, 42, 4, 50, 4, 85, 5, 129, # 3030
  2488. 43, 3, 50, 4, 83, 6, 129, 44, 2, 51, # 3040
  2489. 5, 80, 7, 129, 46, 1, 52, 6, 76, 9, # 3050
  2490. 129, 54, 28, 129, 56, 23, 129, 60, 16, 129, # 3060
  2491. 193, 129, 30, 4, 132, 30, 5, 129, 30, 8, # 3070
  2492. 129, 30, 12, 129, 30, 16, 129, 30, 4, 37, # 3080
  2493. 12, 129, 30, 4, 41, 12, 129, 30, 4, 44, # 3090
  2494. 13, 129, 30, 4, 48, 13, 129, 52, 13, 129, # 3100
  2495. 56, 12, 129, 58, 14, 129, 58, 4, 64, 12, # 3110
  2496. 129, 58, 4, 68, 12, 129, 58, 4, 72, 12, # 3120
  2497. 129, 58, 4, 75, 13, 129, 58, 4, 79, 13, # 3130
  2498. 129, 58, 4, 83, 13, 129, 58, 4, 87, 13, # 3140
  2499. 129, 58, 4, 91, 12, 129, 58, 4, 95, 12, # 3150
  2500. 129, 58, 4, 96, 15, 129, 58, 4, 93, 22, # 3160
  2501. 129, 58, 4, 89, 30, 129, 58, 4, 85, 36, # 3170
  2502. 129, 58, 4, 81, 38, 129, 58, 4, 77, 38, # 3180
  2503. 129, 58, 4, 73, 38, 129, 58, 4, 70, 37, # 3190
  2504. 129, 58, 4, 66, 37, 129, 58, 41, 129, 58, # 3200
  2505. 37, 129, 54, 38, 129, 30, 4, 50, 38, 129, # 3210
  2506. 30, 4, 46, 38, 129, 30, 4, 42, 38, 129, # 3220
  2507. 30, 4, 38, 39, 129, 30, 43, 129, 30, 39, # 3230
  2508. 129, 30, 35, 129, 30, 31, 129, 30, 27, 129, # 3240
  2509. 30, 24, 129, 30, 20, 129, 30, 16, 129, 30, # 3250
  2510. 12, 129, 30, 8, 129, 30, 5, 129, 30, 4, # 3260
  2511. 132, 193, 129, 30, 4, 117, 4, 132, 30, 91, # 3270
  2512. 137, 30, 4, 80, 4, 117, 4, 138, 30, 4, # 3280
  2513. 80, 5, 116, 5, 129, 30, 5, 79, 6, 116, # 3290
  2514. 5, 130, 30, 6, 78, 8, 115, 6, 129, 31, # 3300
  2515. 6, 77, 9, 115, 6, 129, 31, 7, 76, 11, # 3310
  2516. 114, 6, 129, 31, 8, 75, 14, 112, 8, 129, # 3320
  2517. 32, 8, 74, 16, 111, 9, 129, 32, 9, 73, # 3330
  2518. 19, 109, 10, 129, 33, 10, 71, 24, 106, 13, # 3340
  2519. 129, 33, 13, 68, 12, 83, 35, 129, 34, 16, # 3350
  2520. 64, 15, 84, 33, 129, 35, 43, 85, 31, 129, # 3360
  2521. 36, 41, 86, 29, 129, 37, 39, 88, 25, 129, # 3370
  2522. 38, 37, 90, 21, 129, 40, 33, 93, 15, 129, # 3380
  2523. 42, 29, 96, 9, 129, 45, 24, 129, 49, 16, # 3390
  2524. 129, 193, 129, 63, 25, 129, 57, 37, 129, 53, # 3400
  2525. 45, 129, 50, 51, 129, 47, 57, 129, 45, 61, # 3410
  2526. 129, 43, 65, 129, 41, 69, 129, 39, 73, 129, # 3420
  2527. 38, 25, 92, 21, 129, 36, 21, 97, 18, 129, # 3430
  2528. 35, 18, 102, 14, 129, 34, 16, 106, 11, 129, # 3440
  2529. 33, 14, 108, 10, 129, 32, 12, 111, 8, 129, # 3450
  2530. 32, 10, 113, 6, 129, 31, 10, 114, 6, 129, # 3460
  2531. 31, 8, 115, 5, 129, 30, 8, 116, 5, 129, # 3470
  2532. 30, 7, 116, 5, 129, 30, 6, 117, 4, 130, # 3480
  2533. 30, 5, 117, 4, 131, 31, 4, 116, 5, 129, # 3490
  2534. 32, 4, 116, 4, 129, 32, 5, 115, 5, 129, # 3500
  2535. 33, 4, 114, 5, 129, 34, 4, 112, 6, 129, # 3510
  2536. 35, 4, 110, 7, 129, 37, 4, 107, 9, 129, # 3520
  2537. 39, 4, 103, 12, 129, 41, 4, 103, 18, 129, # 3530
  2538. 43, 4, 103, 18, 129, 45, 5, 103, 18, 129, # 3540
  2539. 48, 5, 103, 18, 129, 51, 1, 129, 193, 129, # 3550
  2540. 30, 4, 117, 4, 132, 30, 91, 137, 30, 4, # 3560
  2541. 117, 4, 135, 30, 5, 116, 5, 130, 30, 6, # 3570
  2542. 115, 6, 130, 31, 6, 114, 6, 129, 31, 7, # 3580
  2543. 113, 7, 129, 32, 7, 112, 7, 129, 32, 8, # 3590
  2544. 111, 8, 129, 33, 9, 109, 9, 129, 33, 12, # 3600
  2545. 106, 12, 129, 34, 13, 104, 13, 129, 35, 15, # 3610
  2546. 101, 15, 129, 36, 19, 96, 19, 129, 37, 24, # 3620
  2547. 90, 24, 129, 39, 73, 129, 40, 71, 129, 42, # 3630
  2548. 67, 129, 44, 63, 129, 46, 59, 129, 49, 53, # 3640
  2549. 129, 52, 47, 129, 56, 39, 129, 61, 29, 129, # 3650
  2550. 193, 129, 30, 4, 117, 4, 132, 30, 91, 137, # 3660
  2551. 30, 4, 80, 4, 117, 4, 140, 30, 4, 79, # 3670
  2552. 6, 117, 4, 129, 30, 4, 77, 10, 117, 4, # 3680
  2553. 129, 30, 4, 73, 18, 117, 4, 132, 30, 4, # 3690
  2554. 117, 4, 130, 30, 5, 116, 5, 130, 30, 7, # 3700
  2555. 114, 7, 129, 30, 8, 113, 8, 129, 30, 11, # 3710
  2556. 110, 11, 129, 30, 18, 103, 18, 132, 193, 129, # 3720
  2557. 30, 4, 117, 4, 132, 30, 91, 137, 30, 4, # 3730
  2558. 80, 4, 117, 4, 132, 80, 4, 117, 4, 136, # 3740
  2559. 79, 6, 117, 4, 129, 77, 10, 117, 4, 129, # 3750
  2560. 73, 18, 117, 4, 132, 117, 4, 130, 116, 5, # 3760
  2561. 130, 114, 7, 129, 113, 8, 129, 110, 11, 129, # 3770
  2562. 103, 18, 132, 193, 129, 63, 25, 129, 57, 37, # 3780
  2563. 129, 53, 45, 129, 50, 51, 129, 47, 57, 129, # 3790
  2564. 45, 61, 129, 43, 65, 129, 41, 69, 129, 39, # 3800
  2565. 73, 129, 38, 25, 92, 21, 129, 36, 21, 97, # 3810
  2566. 18, 129, 35, 18, 102, 14, 129, 34, 16, 106, # 3820
  2567. 11, 129, 33, 14, 108, 10, 129, 32, 12, 111, # 3830
  2568. 8, 129, 32, 10, 113, 6, 129, 31, 10, 114, # 3840
  2569. 6, 129, 31, 8, 115, 5, 129, 30, 8, 116, # 3850
  2570. 5, 129, 30, 7, 116, 5, 129, 30, 6, 117, # 3860
  2571. 4, 130, 30, 5, 117, 4, 131, 30, 5, 75, # 3870
  2572. 4, 116, 5, 129, 31, 5, 75, 4, 116, 4, # 3880
  2573. 129, 31, 6, 75, 4, 115, 5, 129, 32, 7, # 3890
  2574. 75, 4, 114, 5, 129, 32, 9, 75, 4, 112, # 3900
  2575. 6, 129, 33, 11, 75, 4, 110, 7, 129, 34, # 3910
  2576. 15, 75, 4, 107, 9, 129, 35, 44, 103, 12, # 3920
  2577. 129, 36, 43, 103, 18, 129, 38, 41, 103, 18, # 3930
  2578. 129, 39, 40, 103, 18, 129, 41, 38, 103, 18, # 3940
  2579. 129, 44, 35, 129, 48, 31, 129, 52, 27, 129, # 3950
  2580. 61, 18, 129, 193, 129, 30, 4, 117, 4, 132, # 3960
  2581. 30, 91, 137, 30, 4, 80, 4, 117, 4, 132, # 3970
  2582. 80, 4, 140, 30, 4, 80, 4, 117, 4, 132, # 3980
  2583. 30, 91, 137, 30, 4, 117, 4, 132, 193, 129, # 3990
  2584. 30, 4, 117, 4, 132, 30, 91, 137, 30, 4, # 4000
  2585. 117, 4, 132, 193, 129, 44, 7, 129, 40, 13, # 4010
  2586. 129, 37, 17, 129, 35, 20, 129, 34, 22, 129, # 4020
  2587. 33, 23, 129, 32, 24, 129, 32, 23, 129, 31, # 4030
  2588. 6, 41, 13, 129, 31, 5, 42, 11, 129, 30, # 4040
  2589. 5, 44, 7, 129, 30, 4, 132, 30, 5, 130, # 4050
  2590. 31, 5, 129, 31, 6, 117, 4, 129, 31, 8, # 4060
  2591. 117, 4, 129, 32, 9, 117, 4, 129, 33, 11, # 4070
  2592. 117, 4, 129, 34, 87, 129, 35, 86, 129, 36, # 4080
  2593. 85, 129, 37, 84, 129, 38, 83, 129, 40, 81, # 4090
  2594. 129, 42, 79, 129, 45, 76, 129, 50, 71, 129, # 4100
  2595. 117, 4, 132, 193, 129, 30, 4, 117, 4, 132, # 4110
  2596. 30, 91, 137, 30, 4, 76, 8, 117, 4, 129, # 4120
  2597. 30, 4, 73, 13, 117, 4, 129, 30, 4, 70, # 4130
  2598. 18, 117, 4, 129, 30, 4, 67, 23, 117, 4, # 4140
  2599. 129, 65, 26, 129, 62, 31, 129, 59, 35, 129, # 4150
  2600. 56, 29, 89, 7, 129, 53, 29, 91, 7, 129, # 4160
  2601. 50, 29, 93, 7, 129, 47, 29, 95, 6, 129, # 4170
  2602. 30, 4, 45, 29, 96, 7, 129, 30, 4, 42, # 4180
  2603. 29, 98, 7, 129, 30, 4, 39, 30, 100, 6, # 4190
  2604. 129, 30, 4, 36, 30, 101, 7, 129, 30, 33, # 4200
  2605. 103, 7, 117, 4, 129, 30, 30, 105, 6, 117, # 4210
  2606. 4, 129, 30, 27, 106, 7, 117, 4, 129, 30, # 4220
  2607. 25, 108, 7, 117, 4, 129, 30, 22, 110, 11, # 4230
  2608. 129, 30, 19, 111, 10, 129, 30, 16, 113, 8, # 4240
  2609. 129, 30, 13, 115, 6, 129, 30, 11, 116, 5, # 4250
  2610. 129, 30, 8, 117, 4, 129, 30, 5, 117, 4, # 4260
  2611. 129, 30, 4, 117, 4, 130, 30, 4, 130, 193, # 4270
  2612. 129, 30, 4, 117, 4, 132, 30, 91, 137, 30, # 4280
  2613. 4, 117, 4, 132, 30, 4, 144, 30, 5, 130, # 4290
  2614. 30, 7, 129, 30, 8, 129, 30, 11, 129, 30, # 4300
  2615. 18, 132, 193, 129, 30, 4, 117, 4, 132, 30, # 4310
  2616. 91, 132, 30, 4, 103, 18, 129, 30, 4, 97, # 4320
  2617. 24, 129, 30, 4, 92, 29, 129, 30, 4, 87, # 4330
  2618. 34, 129, 81, 40, 129, 76, 45, 129, 70, 49, # 4340
  2619. 129, 65, 49, 129, 60, 49, 129, 55, 49, 129, # 4350
  2620. 50, 48, 129, 44, 49, 129, 39, 48, 129, 33, # 4360
  2621. 49, 129, 30, 47, 129, 34, 37, 129, 40, 26, # 4370
  2622. 129, 46, 19, 129, 52, 19, 129, 58, 19, 129, # 4380
  2623. 64, 19, 129, 70, 19, 129, 76, 19, 129, 82, # 4390
  2624. 19, 129, 30, 4, 88, 18, 129, 30, 4, 94, # 4400
  2625. 18, 129, 30, 4, 100, 18, 129, 30, 4, 106, # 4410
  2626. 15, 129, 30, 91, 137, 30, 4, 117, 4, 132, # 4420
  2627. 193, 129, 30, 4, 117, 4, 132, 30, 91, 132, # 4430
  2628. 30, 4, 107, 14, 129, 30, 4, 104, 17, 129, # 4440
  2629. 30, 4, 101, 20, 129, 30, 4, 99, 22, 129, # 4450
  2630. 96, 25, 129, 93, 28, 129, 91, 28, 129, 88, # 4460
  2631. 29, 129, 85, 29, 129, 82, 29, 129, 79, 29, # 4470
  2632. 129, 76, 29, 129, 74, 29, 129, 71, 29, 129, # 4480
  2633. 68, 29, 129, 65, 29, 129, 62, 29, 129, 60, # 4490
  2634. 29, 129, 57, 29, 129, 54, 29, 129, 51, 29, # 4500
  2635. 129, 49, 28, 129, 46, 29, 129, 43, 29, 129, # 4510
  2636. 40, 29, 117, 4, 129, 37, 29, 117, 4, 129, # 4520
  2637. 35, 29, 117, 4, 129, 32, 29, 117, 4, 129, # 4530
  2638. 30, 91, 132, 117, 4, 132, 193, 129, 63, 25, # 4540
  2639. 129, 57, 37, 129, 53, 45, 129, 50, 51, 129, # 4550
  2640. 47, 57, 129, 45, 61, 129, 43, 65, 129, 41, # 4560
  2641. 69, 129, 39, 73, 129, 38, 21, 92, 21, 129, # 4570
  2642. 36, 18, 97, 18, 129, 35, 14, 102, 14, 129, # 4580
  2643. 34, 11, 106, 11, 129, 33, 10, 108, 10, 129, # 4590
  2644. 32, 8, 111, 8, 129, 32, 6, 113, 6, 129, # 4600
  2645. 31, 6, 114, 6, 129, 31, 5, 115, 5, 129, # 4610
  2646. 30, 5, 116, 5, 130, 30, 4, 117, 4, 132, # 4620
  2647. 30, 5, 116, 5, 130, 31, 5, 115, 5, 129, # 4630
  2648. 31, 6, 114, 6, 129, 32, 6, 113, 6, 129, # 4640
  2649. 32, 8, 111, 8, 129, 33, 10, 108, 10, 129, # 4650
  2650. 34, 11, 106, 11, 129, 35, 14, 102, 14, 129, # 4660
  2651. 36, 18, 97, 18, 129, 38, 21, 92, 21, 129, # 4670
  2652. 39, 73, 129, 41, 69, 129, 43, 65, 129, 45, # 4680
  2653. 61, 129, 47, 57, 129, 50, 51, 129, 53, 45, # 4690
  2654. 129, 57, 37, 129, 63, 25, 129, 193, 129, 30, # 4700
  2655. 4, 117, 4, 132, 30, 91, 137, 30, 4, 80, # 4710
  2656. 4, 117, 4, 132, 80, 4, 117, 4, 134, 80, # 4720
  2657. 5, 116, 5, 131, 80, 6, 115, 6, 130, 81, # 4730
  2658. 6, 114, 6, 129, 81, 8, 112, 8, 129, 81, # 4740
  2659. 9, 111, 9, 129, 82, 10, 109, 10, 129, 82, # 4750
  2660. 13, 106, 13, 129, 83, 35, 129, 84, 33, 129, # 4760
  2661. 85, 31, 129, 86, 29, 129, 88, 25, 129, 90, # 4770
  2662. 21, 129, 93, 15, 129, 96, 9, 129, 193, 129, # 4780
  2663. 63, 25, 129, 57, 37, 129, 53, 45, 129, 50, # 4790
  2664. 51, 129, 47, 57, 129, 45, 61, 129, 43, 65, # 4800
  2665. 129, 41, 69, 129, 39, 73, 129, 38, 21, 92, # 4810
  2666. 21, 129, 36, 18, 97, 18, 129, 35, 14, 102, # 4820
  2667. 14, 129, 34, 11, 106, 11, 129, 33, 10, 108, # 4830
  2668. 10, 129, 32, 8, 111, 8, 129, 32, 6, 113, # 4840
  2669. 6, 129, 31, 6, 114, 6, 129, 31, 5, 115, # 4850
  2670. 5, 129, 30, 5, 116, 5, 130, 30, 4, 39, # 4860
  2671. 2, 117, 4, 129, 30, 4, 40, 4, 117, 4, # 4870
  2672. 129, 30, 4, 41, 5, 117, 4, 129, 30, 4, # 4880
  2673. 41, 6, 117, 4, 129, 30, 5, 40, 8, 116, # 4890
  2674. 5, 129, 30, 5, 39, 10, 116, 5, 129, 31, # 4900
  2675. 5, 38, 11, 115, 5, 129, 31, 18, 114, 6, # 4910
  2676. 129, 32, 17, 113, 6, 129, 32, 16, 111, 8, # 4920
  2677. 129, 33, 15, 108, 10, 129, 33, 14, 106, 11, # 4930
  2678. 129, 32, 17, 102, 14, 129, 31, 23, 97, 18, # 4940
  2679. 129, 31, 28, 92, 21, 129, 30, 82, 129, 30, # 4950
  2680. 80, 129, 30, 11, 43, 65, 129, 30, 10, 45, # 4960
  2681. 61, 129, 31, 8, 47, 57, 129, 32, 6, 50, # 4970
  2682. 51, 129, 33, 5, 53, 45, 129, 35, 4, 57, # 4980
  2683. 37, 129, 38, 2, 63, 25, 129, 193, 129, 30, # 4990
  2684. 4, 117, 4, 132, 30, 91, 137, 30, 4, 76, # 5000
  2685. 8, 117, 4, 129, 30, 4, 73, 11, 117, 4, # 5010
  2686. 129, 30, 4, 70, 14, 117, 4, 129, 30, 4, # 5020
  2687. 67, 17, 117, 4, 129, 65, 19, 117, 4, 129, # 5030
  2688. 62, 22, 117, 4, 129, 59, 25, 117, 4, 129, # 5040
  2689. 56, 28, 117, 4, 129, 53, 31, 117, 4, 129, # 5050
  2690. 50, 34, 117, 4, 129, 47, 29, 80, 5, 116, # 5060
  2691. 5, 129, 30, 4, 45, 29, 80, 5, 116, 5, # 5070
  2692. 129, 30, 4, 42, 29, 80, 5, 116, 5, 129, # 5080
  2693. 30, 4, 39, 30, 80, 6, 115, 6, 129, 30, # 5090
  2694. 4, 36, 30, 80, 6, 115, 6, 129, 30, 33, # 5100
  2695. 81, 6, 114, 6, 129, 30, 30, 81, 8, 112, # 5110
  2696. 8, 129, 30, 27, 81, 9, 111, 9, 129, 30, # 5120
  2697. 25, 82, 10, 109, 10, 129, 30, 22, 82, 13, # 5130
  2698. 106, 13, 129, 30, 19, 83, 35, 129, 30, 16, # 5140
  2699. 84, 33, 129, 30, 13, 85, 31, 129, 30, 11, # 5150
  2700. 86, 29, 129, 30, 8, 88, 25, 129, 30, 5, # 5160
  2701. 90, 21, 129, 30, 4, 93, 15, 129, 30, 4, # 5170
  2702. 96, 9, 129, 30, 4, 130, 193, 129, 30, 18, # 5180
  2703. 130, 30, 18, 89, 15, 129, 30, 18, 85, 23, # 5190
  2704. 129, 34, 11, 83, 27, 129, 34, 9, 81, 31, # 5200
  2705. 129, 33, 8, 79, 35, 129, 33, 6, 78, 16, # 5210
  2706. 106, 9, 129, 32, 6, 77, 15, 109, 7, 129, # 5220
  2707. 32, 5, 76, 14, 111, 6, 129, 31, 5, 75, # 5230
  2708. 14, 113, 5, 129, 31, 4, 74, 15, 114, 5, # 5240
  2709. 129, 31, 4, 74, 14, 115, 4, 129, 30, 4, # 5250
  2710. 73, 15, 116, 4, 129, 30, 4, 73, 14, 116, # 5260
  2711. 4, 129, 30, 4, 73, 14, 117, 4, 129, 30, # 5270
  2712. 4, 72, 15, 117, 4, 130, 30, 4, 71, 15, # 5280
  2713. 117, 4, 130, 30, 4, 70, 15, 117, 4, 129, # 5290
  2714. 30, 5, 70, 15, 117, 4, 129, 30, 5, 69, # 5300
  2715. 15, 116, 5, 129, 30, 6, 68, 16, 115, 5, # 5310
  2716. 129, 31, 6, 67, 16, 114, 6, 129, 31, 7, # 5320
  2717. 66, 17, 113, 6, 129, 32, 7, 64, 18, 111, # 5330
  2718. 8, 129, 32, 8, 62, 19, 109, 9, 129, 33, # 5340
  2719. 9, 60, 20, 107, 10, 129, 34, 11, 57, 22, # 5350
  2720. 103, 13, 129, 35, 43, 103, 18, 129, 36, 41, # 5360
  2721. 103, 18, 129, 38, 38, 103, 18, 129, 39, 35, # 5370
  2722. 103, 18, 129, 41, 31, 129, 43, 27, 129, 46, # 5380
  2723. 22, 129, 49, 14, 129, 193, 129, 103, 18, 132, # 5390
  2724. 110, 11, 129, 113, 8, 129, 114, 7, 129, 116, # 5400
  2725. 5, 130, 117, 4, 132, 30, 4, 117, 4, 132, # 5410
  2726. 30, 91, 137, 30, 4, 117, 4, 132, 117, 4, # 5420
  2727. 132, 116, 5, 130, 114, 7, 129, 113, 8, 129, # 5430
  2728. 110, 11, 129, 103, 18, 132, 193, 129, 117, 4, # 5440
  2729. 132, 56, 65, 129, 50, 71, 129, 46, 75, 129, # 5450
  2730. 44, 77, 129, 42, 79, 129, 40, 81, 129, 38, # 5460
  2731. 83, 129, 36, 85, 129, 35, 86, 129, 34, 20, # 5470
  2732. 117, 4, 129, 33, 17, 117, 4, 129, 32, 15, # 5480
  2733. 117, 4, 129, 32, 13, 117, 4, 129, 31, 12, # 5490
  2734. 129, 31, 10, 129, 31, 9, 129, 30, 9, 129, # 5500
  2735. 30, 8, 130, 30, 7, 132, 31, 6, 130, 31, # 5510
  2736. 7, 129, 32, 6, 129, 32, 7, 129, 33, 7, # 5520
  2737. 129, 34, 7, 129, 35, 8, 129, 36, 9, 117, # 5530
  2738. 4, 129, 38, 9, 117, 4, 129, 40, 10, 117, # 5540
  2739. 4, 129, 42, 12, 117, 4, 129, 44, 77, 129, # 5550
  2740. 46, 75, 129, 50, 71, 129, 56, 43, 100, 21, # 5560
  2741. 129, 117, 4, 132, 193, 129, 117, 4, 132, 115, # 5570
  2742. 6, 129, 110, 11, 129, 105, 16, 129, 101, 20, # 5580
  2743. 129, 96, 25, 129, 92, 29, 129, 87, 34, 129, # 5590
  2744. 83, 38, 129, 78, 43, 129, 74, 47, 129, 70, # 5600
  2745. 42, 117, 4, 129, 65, 42, 117, 4, 129, 60, # 5610
  2746. 43, 117, 4, 129, 56, 42, 129, 51, 42, 129, # 5620
  2747. 46, 43, 129, 42, 43, 129, 37, 44, 129, 33, # 5630
  2748. 43, 129, 30, 42, 129, 33, 34, 129, 38, 25, # 5640
  2749. 129, 42, 16, 129, 47, 15, 129, 52, 15, 129, # 5650
  2750. 57, 15, 129, 61, 16, 129, 66, 16, 129, 71, # 5660
  2751. 16, 129, 76, 16, 129, 80, 16, 129, 85, 16, # 5670
  2752. 117, 4, 129, 90, 16, 117, 4, 129, 95, 16, # 5680
  2753. 117, 4, 129, 100, 21, 129, 105, 16, 129, 110, # 5690
  2754. 11, 129, 114, 7, 129, 117, 4, 132, 193, 129, # 5700
  2755. 117, 4, 132, 115, 6, 129, 110, 11, 129, 105, # 5710
  2756. 16, 129, 101, 20, 129, 96, 25, 129, 92, 29, # 5720
  2757. 129, 87, 34, 129, 83, 38, 129, 78, 43, 129, # 5730
  2758. 74, 47, 129, 70, 42, 117, 4, 129, 65, 42, # 5740
  2759. 117, 4, 129, 60, 43, 117, 4, 129, 56, 42, # 5750
  2760. 129, 51, 42, 129, 46, 43, 129, 42, 43, 129, # 5760
  2761. 37, 44, 129, 33, 43, 129, 30, 42, 129, 33, # 5770
  2762. 34, 129, 38, 25, 129, 42, 16, 129, 47, 15, # 5780
  2763. 129, 52, 15, 129, 57, 15, 129, 61, 16, 129, # 5790
  2764. 65, 17, 129, 60, 27, 129, 56, 36, 129, 51, # 5800
  2765. 42, 129, 46, 43, 129, 42, 43, 129, 37, 44, # 5810
  2766. 129, 33, 43, 129, 30, 42, 129, 33, 34, 129, # 5820
  2767. 38, 25, 129, 42, 16, 129, 47, 15, 129, 52, # 5830
  2768. 15, 129, 57, 15, 129, 61, 16, 129, 66, 16, # 5840
  2769. 129, 71, 16, 129, 76, 16, 129, 80, 16, 129, # 5850
  2770. 85, 16, 117, 4, 129, 90, 16, 117, 4, 129, # 5860
  2771. 95, 16, 117, 4, 129, 100, 21, 129, 105, 16, # 5870
  2772. 129, 110, 11, 129, 114, 7, 129, 117, 4, 132, # 5880
  2773. 193, 129, 30, 4, 117, 4, 132, 30, 4, 115, # 5890
  2774. 6, 129, 30, 4, 112, 9, 129, 30, 6, 109, # 5900
  2775. 12, 129, 30, 9, 106, 15, 129, 30, 11, 103, # 5910
  2776. 18, 129, 30, 14, 100, 21, 129, 30, 4, 38, # 5920
  2777. 9, 98, 23, 129, 30, 4, 40, 10, 95, 26, # 5930
  2778. 129, 30, 4, 43, 9, 92, 29, 129, 46, 9, # 5940
  2779. 89, 32, 129, 49, 8, 86, 28, 117, 4, 129, # 5950
  2780. 51, 9, 83, 28, 117, 4, 129, 54, 9, 80, # 5960
  2781. 28, 117, 4, 129, 57, 8, 77, 28, 117, 4, # 5970
  2782. 129, 59, 9, 74, 28, 129, 62, 37, 129, 64, # 5980
  2783. 33, 129, 66, 28, 129, 63, 28, 129, 60, 28, # 5990
  2784. 129, 57, 28, 129, 54, 33, 129, 51, 39, 129, # 6000
  2785. 48, 29, 83, 9, 129, 30, 4, 45, 29, 86, # 6010
  2786. 9, 129, 30, 4, 42, 29, 89, 9, 129, 30, # 6020
  2787. 4, 39, 29, 92, 8, 129, 30, 4, 36, 29, # 6030
  2788. 94, 9, 129, 30, 32, 97, 9, 129, 30, 29, # 6040
  2789. 100, 8, 117, 4, 129, 30, 26, 103, 8, 117, # 6050
  2790. 4, 129, 30, 23, 105, 9, 117, 4, 129, 30, # 6060
  2791. 20, 108, 13, 129, 30, 18, 111, 10, 129, 30, # 6070
  2792. 15, 113, 8, 129, 30, 12, 116, 5, 129, 30, # 6080
  2793. 9, 117, 4, 129, 30, 6, 117, 4, 129, 30, # 6090
  2794. 4, 117, 4, 132, 193, 129, 117, 4, 132, 114, # 6100
  2795. 7, 129, 111, 10, 129, 108, 13, 129, 105, 16, # 6110
  2796. 129, 102, 19, 129, 100, 21, 129, 96, 25, 129, # 6120
  2797. 93, 28, 129, 90, 31, 129, 87, 34, 129, 84, # 6130
  2798. 30, 117, 4, 129, 30, 4, 81, 30, 117, 4, # 6140
  2799. 129, 30, 4, 78, 30, 117, 4, 129, 30, 4, # 6150
  2800. 75, 30, 117, 4, 129, 30, 4, 72, 30, 129, # 6160
  2801. 30, 69, 129, 30, 66, 129, 30, 63, 129, 30, # 6170
  2802. 60, 129, 30, 57, 129, 30, 54, 129, 30, 51, # 6180
  2803. 129, 30, 48, 129, 30, 51, 129, 30, 4, 73, # 6190
  2804. 12, 129, 30, 4, 76, 12, 129, 30, 4, 80, # 6200
  2805. 12, 129, 30, 4, 83, 12, 129, 87, 12, 129, # 6210
  2806. 90, 12, 117, 4, 129, 94, 11, 117, 4, 129, # 6220
  2807. 97, 12, 117, 4, 129, 101, 12, 117, 4, 129, # 6230
  2808. 104, 17, 129, 108, 13, 129, 111, 10, 129, 115, # 6240
  2809. 6, 129, 117, 4, 134, 193, 129, 30, 1, 103, # 6250
  2810. 18, 129, 30, 4, 103, 18, 129, 30, 7, 103, # 6260
  2811. 18, 129, 30, 9, 103, 18, 129, 30, 12, 110, # 6270
  2812. 11, 129, 30, 15, 113, 8, 129, 30, 18, 114, # 6280
  2813. 7, 129, 30, 21, 116, 5, 129, 30, 24, 116, # 6290
  2814. 5, 129, 30, 27, 117, 4, 129, 30, 30, 117, # 6300
  2815. 4, 129, 30, 33, 117, 4, 129, 30, 4, 37, # 6310
  2816. 28, 117, 4, 129, 30, 4, 40, 28, 117, 4, # 6320
  2817. 129, 30, 4, 42, 29, 117, 4, 129, 30, 4, # 6330
  2818. 45, 29, 117, 4, 129, 30, 4, 48, 29, 117, # 6340
  2819. 4, 129, 30, 4, 51, 29, 117, 4, 129, 30, # 6350
  2820. 4, 54, 29, 117, 4, 129, 30, 4, 57, 29, # 6360
  2821. 117, 4, 129, 30, 4, 59, 30, 117, 4, 129, # 6370
  2822. 30, 4, 62, 30, 117, 4, 129, 30, 4, 65, # 6380
  2823. 30, 117, 4, 129, 30, 4, 68, 30, 117, 4, # 6390
  2824. 129, 30, 4, 71, 30, 117, 4, 129, 30, 4, # 6400
  2825. 74, 30, 117, 4, 129, 30, 4, 77, 30, 117, # 6410
  2826. 4, 129, 30, 4, 80, 30, 117, 4, 129, 30, # 6420
  2827. 4, 83, 30, 117, 4, 129, 30, 4, 86, 35, # 6430
  2828. 129, 30, 4, 89, 32, 129, 30, 4, 91, 30, # 6440
  2829. 129, 30, 4, 94, 27, 129, 30, 5, 97, 24, # 6450
  2830. 129, 30, 5, 100, 21, 129, 30, 7, 103, 18, # 6460
  2831. 129, 30, 8, 106, 15, 129, 30, 11, 109, 12, # 6470
  2832. 129, 30, 18, 112, 9, 129, 30, 18, 115, 6, # 6480
  2833. 129, 30, 18, 117, 4, 129, 30, 18, 120, 1, # 6490
  2834. 129, 193, 129, 42, 8, 129, 38, 16, 129, 36, # 6500
  2835. 20, 129, 34, 24, 71, 5, 129, 33, 26, 69, # 6510
  2836. 10, 129, 32, 28, 68, 13, 129, 31, 30, 68, # 6520
  2837. 14, 129, 31, 9, 52, 9, 68, 15, 129, 30, # 6530
  2838. 8, 54, 8, 69, 14, 129, 30, 7, 55, 7, # 6540
  2839. 71, 4, 78, 6, 129, 30, 6, 56, 6, 79, # 6550
  2840. 5, 129, 30, 6, 56, 6, 80, 4, 130, 31, # 6560
  2841. 5, 56, 5, 80, 4, 129, 31, 5, 56, 5, # 6570
  2842. 79, 5, 129, 32, 5, 55, 5, 78, 6, 129, # 6580
  2843. 33, 5, 54, 5, 77, 7, 129, 34, 6, 52, # 6590
  2844. 6, 74, 9, 129, 35, 48, 129, 33, 49, 129, # 6600
  2845. 32, 49, 129, 31, 49, 129, 30, 49, 129, 30, # 6610
  2846. 47, 129, 30, 45, 129, 30, 41, 129, 30, 6, # 6620
  2847. 129, 30, 4, 129, 30, 3, 129, 30, 2, 129, # 6630
  2848. 193, 129, 30, 4, 117, 4, 130, 31, 90, 136, # 6640
  2849. 37, 5, 72, 5, 129, 35, 5, 74, 5, 129, # 6650
  2850. 33, 5, 76, 5, 129, 32, 5, 77, 5, 129, # 6660
  2851. 31, 5, 78, 5, 129, 31, 4, 79, 4, 129, # 6670
  2852. 30, 5, 79, 5, 131, 30, 6, 78, 6, 129, # 6680
  2853. 30, 7, 77, 7, 129, 31, 8, 75, 8, 129, # 6690
  2854. 31, 11, 72, 11, 129, 32, 15, 67, 15, 129, # 6700
  2855. 33, 48, 129, 34, 46, 129, 35, 44, 129, 37, # 6710
  2856. 40, 129, 39, 36, 129, 42, 30, 129, 46, 22, # 6720
  2857. 129, 193, 129, 48, 18, 129, 43, 28, 129, 41, # 6730
  2858. 32, 129, 39, 36, 129, 37, 40, 129, 35, 44, # 6740
  2859. 129, 34, 46, 129, 33, 13, 68, 13, 129, 32, # 6750
  2860. 9, 73, 9, 129, 32, 7, 75, 7, 129, 31, # 6760
  2861. 6, 77, 6, 129, 31, 5, 78, 5, 129, 30, # 6770
  2862. 5, 79, 5, 129, 30, 4, 80, 4, 133, 31, # 6780
  2863. 3, 79, 4, 129, 31, 4, 79, 4, 129, 32, # 6790
  2864. 3, 78, 4, 129, 32, 4, 76, 6, 129, 33, # 6800
  2865. 4, 74, 7, 129, 34, 4, 72, 8, 129, 35, # 6810
  2866. 5, 72, 7, 129, 37, 5, 73, 4, 129, 39, # 6820
  2867. 4, 74, 1, 129, 129, 193, 129, 46, 22, 129, # 6830
  2868. 42, 30, 129, 39, 36, 129, 37, 40, 129, 35, # 6840
  2869. 44, 129, 34, 46, 129, 33, 48, 129, 32, 15, # 6850
  2870. 67, 15, 129, 31, 11, 72, 11, 129, 31, 8, # 6860
  2871. 75, 8, 129, 30, 7, 77, 7, 129, 30, 6, # 6870
  2872. 78, 6, 129, 30, 5, 79, 5, 131, 31, 4, # 6880
  2873. 79, 4, 129, 31, 5, 78, 5, 129, 32, 5, # 6890
  2874. 77, 5, 129, 33, 5, 76, 5, 129, 35, 5, # 6900
  2875. 74, 5, 117, 4, 129, 37, 5, 72, 5, 117, # 6910
  2876. 4, 129, 30, 91, 136, 30, 4, 130, 193, 129, # 6920
  2877. 48, 18, 129, 43, 28, 129, 41, 32, 129, 39, # 6930
  2878. 36, 129, 37, 40, 129, 35, 44, 129, 34, 46, # 6940
  2879. 129, 33, 13, 55, 4, 68, 13, 129, 32, 9, # 6950
  2880. 55, 4, 73, 9, 129, 32, 7, 55, 4, 75, # 6960
  2881. 7, 129, 31, 6, 55, 4, 77, 6, 129, 31, # 6970
  2882. 5, 55, 4, 78, 5, 129, 30, 5, 55, 4, # 6980
  2883. 79, 5, 129, 30, 4, 55, 4, 80, 4, 132, # 6990
  2884. 30, 4, 55, 4, 79, 5, 129, 31, 3, 55, # 7000
  2885. 4, 78, 5, 129, 31, 4, 55, 4, 77, 6, # 7010
  2886. 129, 32, 3, 55, 4, 75, 7, 129, 32, 4, # 7020
  2887. 55, 4, 73, 9, 129, 33, 4, 55, 4, 68, # 7030
  2888. 13, 129, 34, 4, 55, 25, 129, 35, 5, 55, # 7040
  2889. 24, 129, 37, 5, 55, 22, 129, 39, 4, 55, # 7050
  2890. 20, 129, 55, 18, 129, 55, 16, 129, 55, 11, # 7060
  2891. 129, 193, 129, 80, 4, 129, 30, 4, 80, 4, # 7070
  2892. 130, 30, 78, 129, 30, 82, 129, 30, 85, 129, # 7080
  2893. 30, 87, 129, 30, 88, 129, 30, 89, 129, 30, # 7090
  2894. 90, 130, 30, 4, 80, 4, 115, 6, 129, 30, # 7100
  2895. 4, 80, 4, 117, 4, 129, 80, 4, 105, 6, # 7110
  2896. 117, 4, 129, 80, 4, 103, 10, 116, 5, 129, # 7120
  2897. 80, 4, 102, 19, 129, 80, 4, 101, 19, 129, # 7130
  2898. 101, 19, 129, 101, 18, 129, 102, 16, 129, 103, # 7140
  2899. 12, 129, 105, 6, 129, 193, 129, 12, 10, 59, # 7150
  2900. 11, 129, 9, 16, 55, 19, 129, 7, 20, 53, # 7160
  2901. 23, 129, 6, 7, 23, 5, 32, 6, 51, 27, # 7170
  2902. 129, 4, 7, 25, 16, 50, 29, 129, 3, 6, # 7180
  2903. 27, 16, 49, 31, 129, 2, 6, 28, 16, 48, # 7190
  2904. 33, 129, 1, 6, 27, 18, 47, 35, 129, 1, # 7200
  2905. 6, 27, 31, 71, 12, 129, 1, 5, 26, 15, # 7210
  2906. 44, 10, 75, 8, 129, 1, 5, 25, 14, 45, # 7220
  2907. 7, 77, 7, 129, 1, 5, 25, 13, 45, 5, # 7230
  2908. 79, 5, 129, 1, 5, 24, 14, 45, 4, 80, # 7240
  2909. 4, 129, 1, 5, 24, 13, 45, 4, 80, 4, # 7250
  2910. 129, 1, 5, 23, 14, 45, 4, 80, 4, 129, # 7260
  2911. 1, 5, 23, 13, 45, 4, 80, 4, 129, 1, # 7270
  2912. 6, 22, 13, 45, 5, 79, 5, 129, 1, 6, # 7280
  2913. 21, 14, 45, 7, 77, 7, 129, 1, 7, 21, # 7290
  2914. 13, 46, 8, 75, 8, 129, 1, 8, 20, 13, # 7300
  2915. 46, 12, 71, 12, 129, 1, 10, 18, 15, 47, # 7310
  2916. 35, 129, 2, 30, 48, 33, 129, 3, 29, 49, # 7320
  2917. 32, 129, 4, 27, 50, 31, 129, 5, 25, 51, # 7330
  2918. 27, 80, 2, 86, 4, 129, 7, 21, 53, 23, # 7340
  2919. 80, 3, 85, 6, 129, 9, 17, 55, 19, 80, # 7350
  2920. 12, 129, 12, 12, 59, 11, 81, 11, 129, 82, # 7360
  2921. 10, 129, 84, 7, 129, 86, 4, 129, 193, 129, # 7370
  2922. 30, 4, 117, 4, 130, 30, 91, 136, 30, 4, # 7380
  2923. 72, 5, 129, 30, 4, 74, 5, 129, 75, 5, # 7390
  2924. 129, 76, 5, 129, 76, 6, 129, 77, 6, 130, # 7400
  2925. 77, 7, 130, 76, 8, 129, 30, 4, 75, 9, # 7410
  2926. 129, 30, 4, 72, 12, 129, 30, 54, 129, 30, # 7420
  2927. 53, 130, 30, 52, 129, 30, 51, 129, 30, 49, # 7430
  2928. 129, 30, 46, 129, 30, 42, 129, 30, 4, 130, # 7440
  2929. 193, 129, 30, 4, 80, 4, 129, 30, 4, 80, # 7450
  2930. 4, 100, 6, 129, 30, 54, 98, 10, 129, 30, # 7460
  2931. 54, 97, 12, 129, 30, 54, 96, 14, 131, 30, # 7470
  2932. 54, 97, 12, 129, 30, 54, 98, 10, 129, 30, # 7480
  2933. 54, 100, 6, 129, 30, 4, 130, 193, 129, 7, # 7490
  2934. 6, 129, 4, 11, 129, 3, 13, 129, 2, 14, # 7500
  2935. 129, 1, 15, 130, 1, 3, 6, 9, 129, 1, # 7510
  2936. 3, 7, 6, 129, 1, 3, 130, 1, 4, 129, # 7520
  2937. 1, 5, 80, 4, 129, 1, 7, 80, 4, 100, # 7530
  2938. 6, 129, 2, 82, 98, 10, 129, 3, 81, 97, # 7540
  2939. 12, 129, 4, 80, 96, 14, 129, 5, 79, 96, # 7550
  2940. 14, 129, 7, 77, 96, 14, 129, 10, 74, 97, # 7560
  2941. 12, 129, 14, 70, 98, 10, 129, 19, 65, 100, # 7570
  2942. 6, 129, 193, 129, 30, 4, 117, 4, 130, 30, # 7580
  2943. 91, 136, 30, 4, 57, 9, 129, 30, 4, 55, # 7590
  2944. 12, 129, 52, 17, 129, 50, 20, 129, 48, 24, # 7600
  2945. 129, 46, 27, 129, 44, 21, 69, 6, 129, 41, # 7610
  2946. 22, 70, 6, 80, 4, 129, 30, 4, 39, 21, # 7620
  2947. 72, 6, 80, 4, 129, 30, 4, 36, 22, 73, # 7630
  2948. 11, 129, 30, 26, 75, 9, 129, 30, 23, 76, # 7640
  2949. 8, 129, 30, 21, 78, 6, 129, 30, 19, 79, # 7650
  2950. 5, 129, 30, 16, 80, 4, 129, 30, 14, 80, # 7660
  2951. 4, 129, 30, 12, 129, 30, 10, 129, 30, 7, # 7670
  2952. 129, 30, 5, 129, 30, 4, 130, 193, 129, 30, # 7680
  2953. 4, 117, 4, 130, 30, 91, 136, 30, 4, 130, # 7690
  2954. 193, 129, 30, 4, 80, 4, 130, 30, 54, 136, # 7700
  2955. 30, 4, 72, 5, 129, 30, 4, 74, 5, 129, # 7710
  2956. 75, 5, 129, 76, 5, 129, 30, 4, 75, 7, # 7720
  2957. 129, 30, 4, 74, 9, 129, 30, 54, 132, 30, # 7730
  2958. 53, 129, 30, 52, 129, 30, 51, 129, 30, 48, # 7740
  2959. 129, 30, 4, 72, 5, 129, 30, 4, 74, 5, # 7750
  2960. 129, 75, 5, 129, 76, 5, 129, 30, 4, 75, # 7760
  2961. 7, 129, 30, 4, 74, 9, 129, 30, 54, 132, # 7770
  2962. 30, 53, 129, 30, 52, 129, 30, 51, 129, 30, # 7780
  2963. 48, 129, 30, 4, 130, 193, 129, 30, 4, 80, # 7790
  2964. 4, 130, 30, 54, 136, 30, 4, 72, 5, 129, # 7800
  2965. 30, 4, 74, 5, 129, 75, 5, 129, 76, 5, # 7810
  2966. 129, 76, 6, 129, 77, 6, 130, 77, 7, 130, # 7820
  2967. 76, 8, 129, 30, 4, 75, 9, 129, 30, 4, # 7830
  2968. 72, 12, 129, 30, 54, 129, 30, 53, 130, 30, # 7840
  2969. 52, 129, 30, 51, 129, 30, 49, 129, 30, 46, # 7850
  2970. 129, 30, 42, 129, 30, 4, 130, 193, 129, 48, # 7860
  2971. 18, 129, 43, 28, 129, 41, 32, 129, 39, 36, # 7870
  2972. 129, 37, 40, 129, 35, 44, 129, 34, 46, 129, # 7880
  2973. 33, 13, 68, 13, 129, 32, 9, 73, 9, 129, # 7890
  2974. 32, 7, 75, 7, 129, 31, 6, 77, 6, 129, # 7900
  2975. 31, 5, 78, 5, 129, 30, 5, 79, 5, 129, # 7910
  2976. 30, 4, 80, 4, 132, 30, 5, 79, 5, 130, # 7920
  2977. 31, 5, 78, 5, 129, 31, 6, 77, 6, 129, # 7930
  2978. 32, 7, 75, 7, 129, 32, 9, 73, 9, 129, # 7940
  2979. 33, 13, 68, 13, 129, 34, 46, 129, 35, 44, # 7950
  2980. 129, 37, 40, 129, 39, 36, 129, 41, 32, 129, # 7960
  2981. 43, 28, 129, 48, 18, 129, 193, 129, 1, 3, # 7970
  2982. 80, 4, 130, 1, 83, 137, 37, 5, 72, 5, # 7980
  2983. 129, 35, 5, 74, 5, 129, 33, 5, 76, 5, # 7990
  2984. 129, 32, 5, 77, 5, 129, 31, 5, 78, 5, # 8000
  2985. 129, 31, 4, 79, 4, 129, 30, 5, 79, 5, # 8010
  2986. 131, 30, 6, 78, 6, 129, 30, 7, 77, 7, # 8020
  2987. 129, 31, 8, 75, 8, 129, 31, 11, 72, 11, # 8030
  2988. 129, 32, 15, 67, 15, 129, 33, 48, 129, 34, # 8040
  2989. 46, 129, 35, 44, 129, 37, 40, 129, 39, 36, # 8050
  2990. 129, 42, 30, 129, 46, 22, 129, 193, 129, 46, # 8060
  2991. 22, 129, 42, 30, 129, 39, 36, 129, 37, 40, # 8070
  2992. 129, 35, 44, 129, 34, 46, 129, 33, 48, 129, # 8080
  2993. 32, 15, 67, 15, 129, 31, 11, 72, 11, 129, # 8090
  2994. 31, 8, 75, 8, 129, 30, 7, 77, 7, 129, # 8100
  2995. 30, 6, 78, 6, 129, 30, 5, 79, 5, 131, # 8110
  2996. 31, 4, 79, 4, 129, 31, 5, 78, 5, 129, # 8120
  2997. 32, 5, 77, 5, 129, 33, 5, 76, 5, 129, # 8130
  2998. 35, 5, 74, 5, 129, 37, 5, 72, 5, 129, # 8140
  2999. 1, 83, 136, 1, 3, 80, 4, 130, 193, 129, # 8150
  3000. 30, 4, 80, 4, 130, 30, 54, 136, 30, 4, # 8160
  3001. 68, 6, 129, 30, 4, 70, 6, 129, 71, 7, # 8170
  3002. 129, 72, 7, 129, 73, 7, 129, 74, 7, 129, # 8180
  3003. 74, 8, 129, 75, 8, 130, 69, 15, 129, 67, # 8190
  3004. 17, 129, 66, 18, 129, 65, 19, 130, 65, 18, # 8200
  3005. 130, 66, 16, 129, 67, 13, 129, 69, 8, 129, # 8210
  3006. 193, 129, 30, 13, 64, 8, 129, 30, 13, 61, # 8220
  3007. 14, 129, 30, 13, 59, 18, 129, 30, 13, 57, # 8230
  3008. 22, 129, 33, 8, 56, 24, 129, 32, 7, 55, # 8240
  3009. 26, 129, 32, 6, 54, 28, 129, 31, 6, 53, # 8250
  3010. 16, 77, 6, 129, 31, 5, 53, 14, 79, 4, # 8260
  3011. 129, 30, 5, 52, 14, 80, 4, 129, 30, 5, # 8270
  3012. 52, 13, 80, 4, 129, 30, 4, 52, 13, 80, # 8280
  3013. 4, 129, 30, 4, 52, 12, 80, 4, 129, 30, # 8290
  3014. 4, 51, 13, 80, 4, 130, 30, 4, 50, 13, # 8300
  3015. 79, 5, 129, 30, 4, 50, 13, 78, 5, 129, # 8310
  3016. 30, 5, 49, 14, 77, 6, 129, 31, 4, 49, # 8320
  3017. 13, 76, 6, 129, 31, 5, 48, 14, 75, 7, # 8330
  3018. 129, 32, 5, 47, 14, 73, 8, 129, 32, 6, # 8340
  3019. 45, 16, 71, 13, 129, 33, 27, 71, 13, 129, # 8350
  3020. 34, 26, 71, 13, 129, 35, 24, 71, 13, 129, # 8360
  3021. 37, 20, 129, 39, 16, 129, 43, 9, 129, 193, # 8370
  3022. 129, 80, 4, 131, 41, 56, 129, 37, 60, 129, # 8380
  3023. 35, 62, 129, 33, 64, 129, 32, 65, 129, 31, # 8390
  3024. 66, 129, 30, 67, 130, 30, 11, 80, 4, 129, # 8400
  3025. 30, 9, 80, 4, 129, 30, 8, 80, 4, 129, # 8410
  3026. 31, 7, 80, 4, 129, 31, 6, 129, 32, 5, # 8420
  3027. 129, 33, 5, 129, 35, 4, 129, 38, 3, 129, # 8430
  3028. 193, 129, 80, 4, 130, 42, 42, 129, 38, 46, # 8440
  3029. 129, 35, 49, 129, 33, 51, 129, 32, 52, 129, # 8450
  3030. 31, 53, 130, 30, 54, 129, 30, 12, 129, 30, # 8460
  3031. 9, 129, 30, 8, 129, 30, 7, 130, 31, 6, # 8470
  3032. 130, 32, 6, 129, 33, 5, 129, 34, 5, 129, # 8480
  3033. 35, 5, 80, 4, 129, 37, 5, 80, 4, 129, # 8490
  3034. 30, 54, 136, 30, 4, 130, 193, 129, 80, 4, # 8500
  3035. 130, 77, 7, 129, 74, 10, 129, 70, 14, 129, # 8510
  3036. 66, 18, 129, 62, 22, 129, 59, 25, 129, 55, # 8520
  3037. 29, 129, 51, 33, 129, 47, 37, 129, 44, 32, # 8530
  3038. 80, 4, 129, 40, 32, 80, 4, 129, 36, 32, # 8540
  3039. 129, 32, 33, 129, 30, 31, 129, 33, 24, 129, # 8550
  3040. 36, 17, 129, 40, 12, 129, 44, 12, 129, 48, # 8560
  3041. 12, 129, 51, 13, 129, 55, 13, 129, 59, 13, # 8570
  3042. 80, 4, 129, 63, 13, 80, 4, 129, 67, 17, # 8580
  3043. 129, 71, 13, 129, 74, 10, 129, 78, 6, 129, # 8590
  3044. 80, 4, 131, 193, 129, 80, 4, 130, 77, 7, # 8600
  3045. 129, 74, 10, 129, 70, 14, 129, 66, 18, 129, # 8610
  3046. 62, 22, 129, 59, 25, 129, 55, 29, 129, 51, # 8620
  3047. 33, 129, 47, 37, 129, 44, 32, 80, 4, 129, # 8630
  3048. 40, 32, 80, 4, 129, 36, 32, 129, 32, 33, # 8640
  3049. 129, 30, 31, 129, 33, 24, 129, 36, 17, 129, # 8650
  3050. 40, 12, 129, 44, 12, 129, 47, 13, 129, 44, # 8660
  3051. 20, 129, 40, 28, 129, 36, 31, 129, 32, 32, # 8670
  3052. 129, 30, 30, 129, 33, 24, 129, 36, 17, 129, # 8680
  3053. 40, 12, 129, 44, 12, 129, 48, 12, 129, 51, # 8690
  3054. 13, 129, 55, 13, 129, 59, 13, 80, 4, 129, # 8700
  3055. 63, 13, 80, 4, 129, 67, 17, 129, 71, 13, # 8710
  3056. 129, 74, 10, 129, 78, 6, 129, 80, 4, 131, # 8720
  3057. 193, 129, 30, 4, 80, 4, 130, 30, 4, 79, # 8730
  3058. 5, 129, 30, 5, 77, 7, 129, 30, 6, 74, # 8740
  3059. 10, 129, 30, 8, 72, 12, 129, 30, 11, 69, # 8750
  3060. 15, 129, 30, 13, 67, 17, 129, 30, 4, 37, # 8760
  3061. 8, 64, 20, 129, 30, 4, 39, 8, 62, 22, # 8770
  3062. 129, 41, 8, 59, 25, 129, 43, 8, 57, 27, # 8780
  3063. 129, 45, 8, 55, 22, 80, 4, 129, 47, 27, # 8790
  3064. 80, 4, 129, 49, 23, 129, 47, 22, 129, 44, # 8800
  3065. 23, 129, 42, 22, 129, 30, 4, 39, 27, 129, # 8810
  3066. 30, 4, 37, 31, 129, 30, 27, 62, 8, 129, # 8820
  3067. 30, 25, 64, 8, 129, 30, 22, 66, 8, 80, # 8830
  3068. 4, 129, 30, 20, 68, 8, 80, 4, 129, 30, # 8840
  3069. 17, 70, 8, 80, 4, 129, 30, 15, 73, 11, # 8850
  3070. 129, 30, 12, 75, 9, 129, 30, 10, 77, 7, # 8860
  3071. 129, 30, 7, 79, 5, 129, 30, 5, 80, 4, # 8870
  3072. 129, 30, 4, 80, 4, 130, 193, 129, 4, 5, # 8880
  3073. 80, 4, 129, 2, 9, 80, 4, 129, 1, 11, # 8890
  3074. 77, 7, 129, 1, 12, 74, 10, 129, 1, 12, # 8900
  3075. 70, 14, 129, 1, 12, 66, 18, 129, 1, 11, # 8910
  3076. 62, 22, 129, 2, 9, 59, 25, 129, 4, 11, # 8920
  3077. 55, 29, 129, 7, 12, 51, 33, 129, 10, 12, # 8930
  3078. 47, 37, 129, 14, 12, 44, 32, 80, 4, 129, # 8940
  3079. 17, 13, 40, 32, 80, 4, 129, 21, 13, 36, # 8950
  3080. 32, 129, 25, 40, 129, 29, 32, 129, 33, 24, # 8960
  3081. 129, 36, 17, 129, 40, 12, 129, 44, 12, 129, # 8970
  3082. 48, 12, 129, 51, 13, 129, 55, 13, 129, 59, # 8980
  3083. 13, 80, 4, 129, 63, 13, 80, 4, 129, 67, # 8990
  3084. 17, 129, 71, 13, 129, 74, 10, 129, 78, 6, # 9000
  3085. 129, 80, 4, 131, 193, 129, 30, 1, 71, 13, # 9010
  3086. 129, 30, 3, 71, 13, 129, 30, 6, 71, 13, # 9020
  3087. 129, 30, 9, 75, 9, 129, 30, 11, 77, 7, # 9030
  3088. 129, 30, 14, 79, 5, 129, 30, 17, 79, 5, # 9040
  3089. 129, 30, 19, 80, 4, 129, 30, 22, 80, 4, # 9050
  3090. 129, 30, 25, 80, 4, 129, 30, 27, 80, 4, # 9060
  3091. 129, 30, 4, 36, 24, 80, 4, 129, 30, 4, # 9070
  3092. 38, 25, 80, 4, 129, 30, 4, 41, 24, 80, # 9080
  3093. 4, 129, 30, 4, 44, 24, 80, 4, 129, 30, # 9090
  3094. 4, 46, 25, 80, 4, 129, 30, 4, 49, 25, # 9100
  3095. 80, 4, 129, 30, 4, 52, 24, 80, 4, 129, # 9110
  3096. 30, 4, 54, 30, 129, 30, 4, 57, 27, 129, # 9120
  3097. 30, 4, 59, 25, 129, 30, 4, 62, 22, 129, # 9130
  3098. 30, 4, 65, 19, 129, 30, 5, 67, 17, 129, # 9140
  3099. 30, 5, 70, 14, 129, 30, 7, 73, 11, 129, # 9150
  3100. 30, 9, 76, 8, 129, 30, 13, 78, 6, 129, # 9160
  3101. 30, 13, 81, 3, 129, 30, 13, 129, 193, 2, # 9170
  3102. 9, 59, 25, 129, 4, 11, 55, 29, 129, 7, # 9180
  3103. 12, 51, 33, 129, 10, 12, 47, 37, 129, 14, # 9190
  3104. 12, 44, 32, 80, 4, 129, 17, 13, 40, 32, # 9200
  3105. 80, 4, 129, 21, 13, 36, 32, 129, 25, 40, # 9210
  3106. 129, 29, 32, 129, 33, 24, 129, 36, 17, 129, # 9220
  3107. 40, 12, 129, 44, 12, 129, 48, 12, 129, 51, # 9230
  3108. 13, 129, 55, 13, 129, 59, 13, 80, 4, 129, # 9240
  3109. 63, 13, 80, 4, 129, 67, 17, 129, 71, 13, # 9250
  3110. 129, 74, 10, 129, 78, 6, 129, 80, 4, 131, # 9260
  3111. 193, 129, 65, 21, 129, 64, 23, 129, 63, 25, # 9270
  3112. 129, 62, 27, 129, 61, 29, 129, 60, 31, 129, # 9280
  3113. 59, 16, 76, 16, 129, 58, 16, 77, 16, 129, # 9290
  3114. 57, 16, 78, 16, 129, 56, 16, 78, 16, 129, # 9300
  3115. 55, 16, 79, 16, 129, 54, 16, 80, 16, 129, # 9310
  3116. 53, 16, 81, 16, 129, 52, 16, 82, 16, 129, # 9320
  3117. 51, 16, 83, 16, 129, 50, 16, 84, 16, 129, # 9330
  3118. 49, 16, 85, 16, 129, 48, 16, 86, 16, 129, # 9340
  3119. 47, 16, 87, 16, 129, 46, 16, 88, 16, 129, # 9350
  3120. 45, 16, 89, 16, 129, 46, 14, 90, 14, 129, # 9360
  3121. 193, 129, 46, 14, 90, 14, 129, 45, 16, 89, # 9370
  3122. 16, 129, 46, 16, 88, 16, 129, 47, 16, 87, # 9380
  3123. 16, 129, 48, 16, 86, 16, 129, 49, 16, 85, # 9390
  3124. 16, 129, 50, 16, 84, 16, 129, 51, 16, 83, # 9400
  3125. 16, 129, 52, 16, 82, 16, 129, 53, 16, 81, # 9410
  3126. 16, 129, 54, 16, 80, 16, 129, 55, 16, 79, # 9420
  3127. 16, 129, 56, 16, 78, 16, 129, 57, 16, 78, # 9430
  3128. 16, 129, 58, 16, 77, 16, 129, 59, 16, 76, # 9440
  3129. 16, 129, 60, 31, 129, 61, 29, 129, 62, 27, # 9450
  3130. 129, 63, 25, 129, 64, 23, 129, 65, 21, 129, # 9460
  3131. 193 # 9470
  3132. );
  3133.  
  3134. sub perlBanner {
  3135. my $message = shift;
  3136. return if (!defined $message);
  3137.  
  3138. my $width = 50;
  3139.  
  3140. my $output;
  3141.  
  3142. my @print;
  3143. for (my $i = 0; $i < $width; $i++) {
  3144. my $j = $i * 132 / $width;
  3145. $print[$j] = 1;
  3146. }
  3147.  
  3148. # Have now read in the data. Next get the message to be printed.
  3149. my @message;
  3150. {
  3151. $message =~ s/\n//g;
  3152. @message = split(//, $message);
  3153. }
  3154.  
  3155. # check message to make sure it's legal
  3156. for (my $i = 0; $i < @message; $i++) {
  3157. my $chr = $message[$i];
  3158. my $asc = ord($chr);
  3159. if ($asc >= $NCHARS || $asc_ptr[$asc] == 0) {
  3160. cprint("the character '$chr' is not in my character set");
  3161. return undef;
  3162. }
  3163. }
  3164.  
  3165. # Now have message. Print it one character at a time.
  3166. my @line;
  3167. for (my $i = 0; $i < @message; $i++) {
  3168. for (my $j = 0; $j < $DWIDTH; $j++) {
  3169. $line[$j] = ' ';
  3170. }
  3171.  
  3172. my $chr = $message[$i];
  3173. my $asc = ord($chr);
  3174.  
  3175. my $pc = $asc_ptr[$asc];
  3176. my $term = 0;
  3177. my $max = 0;
  3178. my $linen = 0;
  3179.  
  3180. while (!$term) {
  3181. if ($pc < 0 || $pc > $NBYTES) {
  3182. cprint("I'm somewhere where I don't know where I am! banner array position: $pc (lol)");
  3183. return undef;
  3184. }
  3185.  
  3186. my $x = $data_table[$pc] & 0377;
  3187. if ($x >= 128) {
  3188. if ($x > 192) {
  3189. $term++;
  3190. }
  3191.  
  3192. $x = $x & 63;
  3193. while ($x--) {
  3194. if ($print[$linen++]) {
  3195. for (my $j = 0; $j <= $max; $j++) {
  3196. if ($print[$j]) {
  3197. $output .= $line[$j];
  3198. }
  3199. }
  3200.  
  3201. $output .= "\n";
  3202. }
  3203. }
  3204.  
  3205. for (my $j = 0; $j < $DWIDTH; $j++) {
  3206. $line[$j] = ' ';
  3207. }
  3208.  
  3209. $pc++;
  3210. } else {
  3211. my $y = $data_table[$pc + 1];
  3212. $max = $x + $y;
  3213. while ($x < $max) {
  3214. $line[$x++] = '#';
  3215. }
  3216. $pc += 2;
  3217. }
  3218. }
  3219. }
  3220.  
  3221. return $output;
  3222. }
  3223.  
  3224. sub chalkboard {
  3225. my $message = shift;
  3226.  
  3227. my $boardTemplate = <<CHALKBOARD;
  3228. _____________________________________________________________
  3229. | \$text1 ^^^^^^^^\\ |
  3230. | \$text2 | | |
  3231. | \$text3 |_ __ | |
  3232. | \$text4 (.(. ) | |
  3233. | \$partial _ (_ ) |
  3234. | \\\\ /___/' / |
  3235. | _\\\\_ \\ | |
  3236. | (( ) /====| |
  3237. | \\ <.__._- \\ |
  3238. |___________________________________________ <//___. ||
  3239. CHALKBOARD
  3240.  
  3241. my @message;
  3242. for (my $i = 1; $i <= (int(225 / (length($message) + 1)) + 1); $i++) {
  3243. push(@message, uc($message));
  3244. }
  3245. $message = substr(join(' ', @message), 0, 225);
  3246. my $text = {};
  3247. for (my $i = 1; $i <= 5; $i++) {
  3248. $text->{$i} = substr($message, (($i - 1) * 46), 46);
  3249. }
  3250.  
  3251.  
  3252. my $output = $boardTemplate;
  3253. $message = uc($message) . (' ' x (46 - length($message)));
  3254. my $partial = substr($message, 0, 41);
  3255. $partial = uc($partial) . (' ' x (41 - length($partial)));
  3256. $output =~ s/\$text([1-4])/$text->{$1}/g;
  3257. $output =~ s/\$partial/$partial/g;
  3258.  
  3259. return $output;
  3260. }
  3261.  
  3262.  
  3263. # run a command and return output
  3264. sub run {
  3265. my %params = @_;
  3266.  
  3267. my $command = $params{command};
  3268. my $args = $params{args};
  3269. my $stdin = $params{stdin};
  3270.  
  3271. # see if we can find the program
  3272. $command = whereis($command);
  3273.  
  3274. if (!-x $command) {
  3275. cprint("$command not found or not executable!");
  3276. return;
  3277. }
  3278.  
  3279. my $pid = open3(\*WRITE, \*READ, \*ERR, "$command $args");
  3280.  
  3281. if ($stdin) { print WRITE $stdin }
  3282. close WRITE;
  3283.  
  3284. my $output = join('', <READ>);
  3285. close READ;
  3286.  
  3287. # check for errors
  3288. while (my $line = <ERR>) {
  3289. next if $line eq "Message: "; # hack for banner :(
  3290. cprint_lines($line);
  3291. }
  3292. close ERR;
  3293.  
  3294. waitpid($pid, 0);
  3295.  
  3296. return $output;
  3297. }
  3298.  
  3299. sub strip {
  3300. my $text = shift;
  3301. return if (!defined $text);
  3302.  
  3303. my $output;
  3304. foreach my $line (split(/\r?\n/, $text)) {
  3305. $output .= "$line\n" unless ($line =~ /^\s*$/);
  3306. }
  3307.  
  3308. return $output;
  3309. }
  3310.  
  3311. if ($CONTEXT eq 'terminal') {
  3312. my $callback = \&insub;
  3313.  
  3314. my @args;
  3315. foreach my $arg (@ARGV) {
  3316. if ($arg =~ /^-html/o) { $OUTPUT = 'html' }
  3317. elsif ($arg =~ /^-ansi/o) { $OUTPUT = 'ansi' if $ANSI }
  3318. elsif ($arg =~ /^-bash/o) { $BASH_PROMPT = 1 }
  3319. elsif ($arg =~ /^-cat/o) { $callback = \&insubcat }
  3320. elsif ($arg =~ /^-stdin/o) { $stdin = join('', <STDIN>) }
  3321. elsif ($arg =~ /^-aim/o) { $OUTPUT = 'aim' }
  3322. elsif ($arg =~ /^-bbcode/o) { $OUTPUT = 'bbcode' }
  3323. elsif ($arg =~ /^-orkut/o) { $OUTPUT = 'orkut' }
  3324. elsif ($arg =~ /^-mirc/o) { $OUTPUT = 'irc' }
  3325. else { push(@args, $arg) }
  3326. }
  3327.  
  3328. if (@args) {
  3329. $callback->(join(' ', @args));
  3330. } else {
  3331. printf "%s\n", $USAGE;
  3332. }
  3333.  
  3334. exit(0);
  3335. } elsif ($CONTEXT eq 'cgi') {
  3336. eval 'use CGI';
  3337. if ($@) {
  3338. printf STDERR "error: CGI module unloadable.\n";
  3339. exit(1);
  3340. }
  3341.  
  3342. print CGI::header, qq(<html><body text="white" bgcolor="black">\n);
  3343.  
  3344. insub(CGI::param("args"));
  3345.  
  3346. print "</body></html>\n";
  3347.  
  3348. exit(0);
  3349. } elsif ($CONTEXT eq 'irssi') {
  3350. # command bindings.. basically there
  3351. # is only one "real" command, the rest
  3352. # are aliases for preset filters. so,
  3353. # only do this if we are in Irssi
  3354. Irssi::command_bind($NAME, \&insub);
  3355. Irssi::command_bind($EXEC, \&insubexec);
  3356. Irssi::command_bind($CAT, \&insubcat);
  3357. Irssi::command_bind("gv", \&gv);
  3358.  
  3359.  
  3360. # if run in Irssi, establish settings and
  3361. # provide default values
  3362.  
  3363. # cowsay
  3364. Irssi::settings_add_str($IRSSI{name}, 'cowfile', $settings->{cowfile});
  3365. Irssi::settings_add_str($IRSSI{name}, 'cowpath', $settings->{cowpath});
  3366.  
  3367. # figlet
  3368. Irssi::settings_add_str($IRSSI{name}, 'figfont', $settings->{figfont});
  3369. Irssi::settings_add_int($IRSSI{name}, 'linewrap', $settings->{linewrap});
  3370.  
  3371. # rainbow
  3372. Irssi::settings_add_int($IRSSI{name}, 'rainbow_offset', $settings->{rainbow_offset});
  3373. Irssi::settings_add_bool($IRSSI{name}, 'rainbow_keepstate', $settings->{rainbowkeepstate});
  3374. Irssi::settings_add_int($IRSSI{name}, 'default_style', $settings->{default_style});
  3375.  
  3376. # checkers
  3377. Irssi::settings_add_int($IRSSI{name}, 'check_size', $settings->{check_size});
  3378. Irssi::settings_add_int($IRSSI{name}, 'check_text', $settings->{check_text});
  3379. Irssi::settings_add_str($IRSSI{name}, 'check_colors', $settings->{check_colors});
  3380.  
  3381. # the matrix
  3382. Irssi::settings_add_int($IRSSI{name}, 'matrix_size', $settings->{matrix_size});
  3383. Irssi::settings_add_int($IRSSI{name}, 'matrix_spacing', $settings->{matrix_spacing});
  3384.  
  3385. # sine wave settings
  3386. Irssi::settings_add_int($IRSSI{name}, 'sine_height', $settings->{sine_height});
  3387. Irssi::settings_add_str($IRSSI{name}, 'sine_frequency', $settings->{sine_frequency});
  3388. Irssi::settings_add_str($IRSSI{name}, 'sine_background', $settings->{sine_background});
  3389.  
  3390. # misc
  3391. Irssi::settings_add_int($IRSSI{name}, 'colcat_max', $settings->{colcat_max});
  3392. Irssi::settings_add_str($IRSSI{name}, 'jive_cmd', $settings->{jive_cmd});
  3393. Irssi::settings_add_int($IRSSI{name}, 'spook_words', $settings->{spook_words});
  3394. Irssi::settings_add_int($IRSSI{name}, 'hug_size', $settings->{hug_size});
  3395. Irssi::settings_add_str($IRSSI{name}, 'banner_style', $settings->{banner_style});
  3396.  
  3397. cprint("$SPLASH. '/$NAME help' for usage");
  3398. }
  3399.  
  3400. # note, do not add an __END__ here, because irssi does not like it. thx plz
  3401.  
  3402.  
  3403.  
  3404. =head1 NAME
  3405.  
  3406. insub
  3407.  
  3408. =head1 SYNOPSIS
  3409.  
  3410. a bunch of annoying text filters, generally used to add color to ascii
  3411. art.
  3412.  
  3413. =head1 DESCRIPTION
  3414.  
  3415. =over 4
  3416.  
  3417. =item * Using insub inside PS1 bash prompt
  3418.  
  3419. In your .bashrc, or wherever you like to set your prompt, add code such as
  3420. the following:
  3421.  
  3422. export PROMPT_COMMAND="PS1=\$(echo 'prompt> ' | <script> -bash -1 -stdin)"
  3423.  
  3424. You may use Bash PS1 escaped characters directly in your prompt, such as
  3425. this:
  3426.  
  3427. export PROMPT_COMMAND="PS1=\$(echo '\u@\h: \w\$ ' | <script> -bash -1 -stdin)"
  3428.  
  3429. The problem with this however, is that the escaped characters are expanded
  3430. after script. If you want per-character colouring, you will need to be
  3431. more sneaky. This will use per-character colouring for the same prompt as
  3432. above:
  3433.  
  3434. export PROMPT_COMMAND="PS1=\$(echo \"\$USER@\$(hostname -s): \$(pwd|sed \
  3435. \"s?^\$HOME?\~?\")\\\\\$ \" | <script> -bash -1 -stdin)"
  3436.  
  3437. On my system it takes about a second and a half for the whole thing to
  3438. process. This may be a few milliseconds faster, but won't adapt if your
  3439. $USER, hostname, or $HOME should change during your session.
  3440.  
  3441. export PROMPT_COMMAND="PS1=\$(echo \"$USER@$(hostname -s): \$(pwd|sed \
  3442. \"s?^$HOME?\~?\")\\\\\$ \" | <script> -bash -1 -stdin)"
  3443.  
  3444. Hopefully, this documentation has been useful. D:
  3445.  
  3446. =back
  3447.  
  3448. =cut
Advertisement
Add Comment
Please, Sign In to add comment