All pastes #1175036 Raw Edit

malay !@

public text v1 · immutable
#1175036 ·published 2008-08-16 23:52 UTC
rendered paste body
#!/usr/bin/perl
# MALAYTALKS TWO POINT IZZO (by ian)
# usage: /malay <string> or $malaytalk(string)
# fear the malay code:

use LWP::Simple;

my $help = 'Usage: /malay <string>';

$VERSION = 1.0;
%IRSSI = (
   authors     => "xixel+neuLOL",
   name        => "malay.pl",
   description => "diS SCriPt traNSlates tEXt in MAlay~^_^",
   license     => "GNU GPLv2 or later",
   url         => "blah"
);

%malay = (
  'hehe' => 'lorrr',
  'what' => 'wat',
  'll' => 'l',
  'heh' => 'ahax',
  'the' => 'da',
  'me' => 'meh',
  'please' => 'pls',
  'are' => 'r',
  'you' => 'u',
  'im' => 'ims',
  '\'' => '`',
);

%randmalay = (
  'lol' => 'ahakx|ahakz',
  'haha' => 'kowkow|k0wk0w',
  'love' => 'lub|luv',
  'uck' => 'ux|uxor'
);

@malay_end = ('..~~!','~^_^','~!',"..\262");

Irssi::command_bind('malay',
  sub {
    my ($args, $server, $item) = @_;

    if($args eq 'help') {
      print $help;
      return;
    }

    my $data = $args;

    # first set of replacements
    foreach $eng (keys %malay) {
      $mal = $malay{$eng};
      $data =~ s/$eng/$mal/ig;
    }

    # replacements with multiple (random) choices
    foreach $reng (keys %randmalay) {
      $rmal = $randmalay{$reng};
      @randvals = split(/\|/, $rmal);
      $rmal = $randvals[int(rand(@randvals))];
      $data =~ s/$reng/$rmal/ig;
    }

    # add 's' randomly to end of words
    my @data2 = split(/ /, $data);
    my $data3 = '';
    my $z = 0;
    foreach $s (@data2) {
      if($data3=='') { my $first = 1; }
      if(int(rand(5))==1 && $s =~ m/[a-zA-Z]/) { $data3 .= $s.'s'; }
      else { $data3 .= $s; }
      if(@data2 > 0 && $z+1 != @data2) { $data3 .= ' '; }
      $z++;
    }
    $data = $data3;

    # add something to the end of the lines at random
    $end = int(rand(@malay_end));
    $data = $data.$malay_end[$end];

    my $a, $b, $c, $x, $l = length($data);

    # randomize capitalization
    for($i=0; $i<=length($data); $i++) {
      $x = substr($data,$i,1);
      if($x =~ m/[a-z]/ && int(rand(3))==1) {
        $x =~ tr/[a-z]/[A-Z]/;
      }
      $a .= $x;
    }

    # randomize boldness
    for($i=0; $i<=length($a); $i++) {
      $x = substr($a,$i,1);
      if(int(rand(3))==1) {
        $x = "\002".$x."\002";
      }
      $b .= $x;
    }

    # randomize underline
    for($i=0; $i<=length($b); $i++) {
      $x = substr($b,$i,1);
      if(int(rand(3))==1 && $x !~ m/ /) {
        $x = "\037".$x."\037";
      }
      $c .= $x;
    }

    my $data = $c;
    if($data) {
      Irssi::active_win->command('/say '.$data);
      $x='',$a='',$b='',$c='',$data='';
    }
  }
);