pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

Perl pastebin - collaborative debugging tool View Help


Posted by Jeff W on Wed 12 Nov 06:15 (modification of post by view diff)
report abuse | download | new post

  1. #!/usr/bin/perl
  2.  
  3. use warnings;
  4. use strict;
  5.  
  6. # Just edit which channels you want it to work on and which ones not to.
  7. # Read the script is recommended, edit or add phrases to random strings if
  8. # you want. I dont really care. Its a useless script anyways :p -- Jeff W. aka vizsla or towlie
  9.  
  10. my $script = "\cC13ASL";
  11. my $version = "2.0";
  12. my $desc = "ASL responder";
  13.  
  14. Xchat::register($script,$version,$desc, \&unload);
  15.  
  16. #text events to do callbacks on and what messages to look for
  17. my $hook = Xchat::hook_print("Channel Message", \&asl_sub);
  18.  
  19. # list of phrases to be later randomized :D
  20. my @tooyoung;
  21. my @teens;
  22. my @twenties;
  23. my @fifties;
  24.  
  25. # counts when something is like an asl is captured
  26. my $counter;
  27.  
  28. # Evaluates Text Event "Channel Message".
  29. sub asl_sub {   
  30.         #current room name
  31.         my $channel = Xchat::get_info("channel");
  32.  
  33.         #If a channel is either #help or #trivia, then it wont go any further.
  34.         if ($channel =~ /^#(?:help|trivia)$/i) {
  35.                 return Xchat::EAT_NONE;
  36.         }
  37.        
  38.                 #then gets text from desired rooms
  39.                 my $text = $_[0][1];
  40.                 Xchat::strip_code($text);
  41.                 my $nick = $_[0][0];
  42.                 Xchat::strip_code($nick);
  43.  
  44. # asl regex, 129 is highest age, 2 digits, or 1 digit then any spaces or / or - or , sex mfmalefemale, and atleast 15 letters
  45. # not sure, I just wrote it this way for boredom... I forgot already what half of it means xD
  46.         if ( $text =~ /([1]{1}[0-2]{1}[0-9]{1}|[1-9]{1}[0-9]{1}|[1-9]{1})(?:\s+|\/|\-|\,)(m|f|male|female)(?:\s+|\/|\-|\,)(?:[A-Za-z]{2,15})/i ) {
  47.  
  48.                 #regex callbacks assigning
  49.                 my $age = $1;
  50.                 my $sex = $2;
  51.                 if ( $age < 13  &&  $channel !~ /^#lobby/i ) {
  52.                         my $said = &randomtooyoung(); #reference to sub
  53.                         Xchat::command("timer .4 msg $channel $nick $said");
  54.                         &hook_timer(10000);
  55.                 }
  56.                 elsif ( $age > 12  &&  $age < 20 ) {
  57.                         my $said = &randomteen();
  58.                         Xchat::command("timer .4 msg $channel $nick you are $age $said");
  59.                         &hook_timer(10000);
  60.                 }
  61.                 elsif ( $age > 19  &&  $age < 30  &&  $sex =~/^f/i ) {
  62.                         my $said = &randomtwenty();
  63.                         Xchat::command("timer .4 msg $channel $nick omg $age $said");
  64.                         &hook_timer(10000);
  65.                 }
  66.                 elsif ( $age > 29  &&  $age < 40 ) {
  67.                         Xchat::command("timer .4 msg $channel $nick you are $age years old :o");
  68.                         &hook_timer(10000);
  69.                 }
  70.                 elsif ( $age > 39  &&  $age < 50 ) {
  71.                         Xchat::command("timer .4 msg $channel $nick NO! dont have your midlife crisis :P , $age isn't that old, maybe.");
  72.                         &hook_timer(10000);
  73.                 }
  74.                 elsif ( $age > 49  &&  $age < 65 ) {
  75.                         my $said = &randomfifty();
  76.                         Xchat::command("timer .4 msg $channel $nick whoa your are $age years old o: $said");
  77.                         &hook_timer(10000);
  78.                 }
  79.                 elsif ($age > 64 && $age < 100  &&  $sex =~ /^f/i ) {
  80.                         Xchat::command("timer .4 msg $channel $nick you are officially old dont forget your medication grandma");
  81.                         &hook_timer(10000);
  82.                 }
  83.                 elsif ( $age > 64  &&  $age < 100  &&  $sex =~ /^m/i ) {
  84.                         Xchat::command("timer .4 msg $channel $nick you are officially old dont forget your medication grandpa");
  85.                         &hook_timer(10000);
  86.                 }              
  87.                 elsif ( $age > 99 ) {
  88.                         Xchat::command("timer .4 msg $channel $nick LIES! your not $age years old pfft");
  89.                         &hook_timer(10000);
  90.                 }
  91.         }
  92.         # These will only work in the room specified below #teen-chat or #lizard
  93.         elsif ( $channel =~ /^#(?:teen\-chat|lizard)$/i ) {
  94.                
  95.                 # I dont know if it works, it looks for CAPS
  96.                 if ( $text =~ /(?:[A-Z]{10,14}|[A-Z]{2,} [A-Z]{8,15})/ ) {
  97.                         Xchat::command("timer .4 bs say $channel \cB$nick\cO: Easy on the caps please...");
  98.                         &hook_timer(4000);
  99.                 }
  100.                 # If a noobs says "pm me" or something overly used...
  101.                 elsif ( $text =~ /\bpm (?:me|you|u)\b/i ) {
  102.                         Xchat::command("timer .4 bs say $channel $nick no we do not want to pm you :|");
  103.                         &hook_timer(10000);
  104.                 }
  105.                 elsif (lc( $text eq "what is love" )) {
  106.                         Xchat::command("timer .3 msg $channel Baby Don't Hurt Me, Don't Hurt Me, No More...");
  107.                         &hook_timer(5000);
  108.                 }
  109.                 elsif (lc( $text eq "kick me") ) {
  110.                         Xchat::command("cs kick $channel $nick Requested.");
  111.                         &hook_timer(10000);
  112.                 }
  113.         }
  114.         return Xchat::EAT_NONE;
  115. }
  116.  
  117. # routine to make a timer to help stop of abuse of script
  118. sub hook_timer {
  119.         $counter++;
  120.         Xchat::unhook($hook);
  121.         my ($milliseconds) = shift( @_ );
  122.         Xchat::hook_timer($milliseconds,
  123.                 sub {
  124.                         $hook = Xchat::hook_print("Channel Message", \&asl_sub);
  125.                         return Xchat::REMOVE;
  126.                 }
  127.         );
  128.         if ($counter > 10 ) {
  129.                 Xchat::command("unload asl.pl");
  130.         }
  131. }
  132.  
  133. # these subs pick a random scalar of a global array ( lines 18-29)
  134. sub randomteen {
  135.         @teens = ( "omg hawt", "get away emo n00b", "teenagers pfft >.> ...", "don't go emo on me D: \\wrists",
  136.                                 "go be a kid D:", "kids these days... >.<", "your my new pet", "meow", "www.freejavachat.com" );
  137.     return $teens[ rand scalar @teens ];
  138. }
  139. sub randomtwenty {
  140.         @twenties = ( "go to college", "go party", "you're in the prime of your life", "hawt", "will you mary me?",
  141.                                 "why give your asl?", "get a job!" );
  142.     return $twenties[ rand scalar @twenties ];
  143. }
  144. sub randomfifty {
  145.         @fifties = ( "don't forget your colonoscopy! ;o", "are you my dad?", "adopt me", "I see a bald spot",
  146.                                 "just about over the hill :P" );
  147.     return $fifties[ rand scalar @fifties ];
  148. }
  149. sub randomtooyoung {
  150.         @tooyoung = ( "goo goo gaga", "its recess! go outside and play and come back when you're of age",
  151.                                 "pedobear wants you", "you are too young for here", "I'm telling your mom!",
  152.                                 "hellokitty.com is better for you", "I like barbies too", "nap time, you're too young" );
  153.         return $tooyoung[ rand scalar @tooyoung ];
  154. }
  155.  
  156. # prints when script is unloaded :O
  157. sub unload {
  158.         Xchat::print($script . " " . $version . " unloaded..");
  159. }

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me