Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
488
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 4.93 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. #
  4.  
  5. # irc-flash@digdilem.org - poke Flash_ at irc.quakenet.org - #3am
  6.  
  7. # If used in your own work, please include my name in it somewhere, thanks.
  8.  
  9. # 12th March, 2005
  10.  
  11. #
  12.  
  13. # Commands: (also adds buttons)
  14.  
  15. # "/rgive Nick"         - Give random object to Nick from objects.txt
  16.  
  17. # "/rslap Nick"         - As above, but abuse them with it first
  18.  
  19. # "/rmake Nick"         - Gives three random objects, asks Nick to build something
  20.  
  21. #
  22.  
  23. # v.0.9 - Also allows other people to prompt you to act with !slap, !give and !make
  24.  
  25. #
  26.  
  27. # Where is the objects.txt file? (Default - Xchat's windows' home)
  28.  
  29. # (This is the file containing random objects to give/slap with)
  30.  
  31. # Default - Windows XP's home directory for Xchat 2 - the same
  32.  
  33. # one perl scripts are loaded by default.
  34.  
  35. $objfile = "$ENV{'HOME'}/.xchat2/objects.txt";
  36.  
  37. # Alternative for some windows that don't expand home directory: (Change username)
  38.  
  39. #$objectfile = "C:/Documents\ and\ Settings/username/Application\ Data/Xchat\ 2/objects.txt";
  40.  
  41. # If you still can't get it finding that file, plonk it somewhere else - it doesn't
  42.  
  43. # need to be in that dir.
  44.  
  45.  
  46.  
  47. # Do you want this script to add its own easy-use buttons below userlist?
  48.  
  49. # (Change to 0 if not)
  50.  
  51. $flslap_buttons=1;
  52.  
  53. #
  54.  
  55. # Do you want others to be able to prompt you? !slap, !give and !make
  56.  
  57. $flap_silly_triggers=1;
  58.  
  59.  
  60.  
  61. #================== End of user config===========
  62.  
  63. $flslap_version = "0.9";
  64.  
  65.  
  66. Xchat::register( "Slap/Give Script", $flslap_version, "/rgive, /rmake and /rslap", "" );
  67. Xchat::print "\002\0034---------------";
  68.  
  69. Xchat::print "\002\0034:: Slap/Give Script $flslap_version loading ::";
  70. Xchat::print "\002\0034---------------\n";
  71.  
  72.  
  73.  
  74. IRC::add_message_handler("PRIVMSG", "watch_slaptriggers");
  75.  
  76. IRC::add_command_handler("give", "give");
  77.  
  78. IRC::add_command_handler("slap", "slap");
  79. #Xchat::hook_command("rslaps", "rslap");
  80. #trop d'erreur affiché dans Universnet pour /rmake
  81.  
  82. #IRC::add_command_handler("rmake", "rmake");
  83.  
  84.  
  85.  
  86. sub give {             # Randomly give an item to person from objects.txt      
  87.  
  88.          open (IN, "<$objfile") or (Xchat::print"Cannot open that file, wah! (Path: $objfile)");
  89.  
  90.          rand($.) < 1 && ($line = $_) while <IN>; # Pick random line
  91.  
  92.          close(IN);
  93.  
  94.          chomp($line);
  95.  
  96.          # Change wording if required
  97.  
  98.          IRC::command("/me gives $_[0] $line.");
  99.  
  100.          return 1;
  101.  
  102. }
  103.  
  104. sub slap {             # Randomly slap somebody with an item to person from objects.txt
  105.  
  106.          open (IN, "<$objfile") or (Xchat::print"Cannot open that file, wah! (Path: $objfile)");
  107.  
  108.          rand($.) < 1 && ($line = $_) while <IN>; # Pick random line
  109.  
  110.          close(IN);
  111.  
  112.          chomp($line);
  113.  
  114.          # Change wording if required
  115.  
  116.          IRC::command("/me slaps $_[0] around the head with $line.");
  117.  
  118.          return 1;
  119.  
  120. }
  121.  
  122.  
  123.  
  124. sub rmake {
  125.  
  126.          open (IN, "<$objfile") or (Xchat::print"Cannot open that file, wah! (Path: $objfile)");
  127.  
  128.          rand($.) < 1 && ($line = $_) while <IN>; # Pick random line
  129.  
  130.          close(IN);
  131.  
  132.          open (IN, "<$objfile") or (Xchat::print"Cannot open that file, wah! (Path: $objfile)");
  133.  
  134.          rand($.) < 1 && ($line2 = $_) while <IN>; # Pick random line
  135.  
  136.          close(IN);
  137.  
  138.          open (IN, "<$objfile") or (Xchat::print"Cannot open that file, wah! (Path: $objfile)");
  139.  
  140.          rand($.) < 1 && ($line3 = $_) while <IN>; # Pick random line
  141.  
  142.          close(IN);
  143.  
  144.          chomp($line);
  145.  
  146.          chomp($line2);
  147.  
  148.          chomp($line3);
  149.  
  150.          # Change wording if required
  151.  
  152.          IRC::command("/me gives $_[0] $line, $line2 and $line3 - what can you make of them?");
  153.  
  154.          return 1;
  155.  
  156. }
  157.  
  158.  
  159.  
  160. # Add buttons if required
  161.  
  162. if ($flslap_buttons =~ /1/) {
  163.  
  164.         IRC::command "/delbutton RandGive";
  165.  
  166.         IRC::command "/delbutton RandSlap";
  167.  
  168.         IRC::command "/delbutton RandMake";
  169.  
  170.        
  171.  
  172.         IRC::command "/addbutton RandGive rgive %s";
  173.  
  174.         IRC::command "/addbutton RandSlap rslap %s";        
  175.  
  176.         IRC::command "/addbutton RandMake rmake %s";
  177.  
  178. }
  179.  
  180.  
  181.  
  182. sub watch_slaptriggers {
  183.  
  184.        if ($flap_silly_triggers) {
  185.  
  186.                foreach $line (@_) {
  187.  
  188.                         $line =~ m/\:(.*?)\!(.*?)\sPRIVMSG\s(.*?)\s\:(.*)?/;
  189.  
  190.                                        
  191.  
  192.                         $m_nick = $1;
  193.  
  194.                         $m_send = $2;
  195.  
  196.                         $m_chan = $3;
  197.  
  198.                         $m_line = $4;
  199.  
  200.                                        
  201.  
  202.                         $m_line =~ s/^\s+//; # Remove trailing whitespace
  203.  
  204.                         $m_line =~ s/\s+$//;
  205.  
  206.                        
  207.  
  208.                         if ($m_line =~ m/!slap/gi) { rslap($m_nick); }
  209.  
  210.                         if ($m_line =~ m/!give/gi) { rgive($m_nick); }
  211.  
  212.                         if ($m_line =~ m/!make/gi) { rmake($m_nick); }
  213.  
  214.                         }
  215.  
  216.        }
  217.  
  218. }
  219.  
  220. # Seed rand once
  221.  
  222. srand;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement