Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- # RamenServ
- # Takanya's Script
- # for Perl/HexChat
- # By TakatsukiYayoi
- #
- # What this does:
- # >> gives out ramen to anyone entering
- # !ramen in the channel
- #
- # <donttouch>
- # For good Perl programming
- use strict;
- use warnings;
- # Use the Xchat module (this is an XChat script, d'oh!)
- use Xchat qw( :all );
- # Use a few other modules this thing needs
- use DBD::SQLite; # For stats tracking (Yes, Yayoi loves SQLite :D)
- use Time::HiRes qw( gettimeofday ); # For last command usage tracking
- # </donttouch>
- # Put your ramen flavors here.
- # Format is ("a flavor","another flavor","another flavor")
- # As many as you want.
- # The script will write "<n> bowl(s) of <flavor> ramen",
- # So you might want to consider that.
- my @flavors = ("pork","salt","miso","tonkatsu","soy","chicken","beef");
- # ------ MAIN CODE BE HERE ------
- my $customer = ""; # We'll use this later.
- my $noMoarOrders = 0; # We'll use this later.
- # Register this script
- register ( "Takanya\'s RamenServ", "0.0.02", "Ramen for everyone!", "" );
- # Listen for channel messages
- hook_print ('Channel Message',\&order_ramen);
- # Tell the user that the script is armed and ready
- Xchat::prnt ("Takanya is ready to serve ramen!");
- # Quick Check: respond only is the message is "!ramen"
- sub order_ramen { $customer = $_[0][0]; &cook_ramen if ($_[0][1] =~ m/^!ramen$/i && !($noMoarOrders)); }
- # Main sub
- sub cook_ramen {
- my $bowls = &eggroll(5);
- $bowls++; # This means no zero bowls given
- my $flavor = &eggroll(scalar(@flavors) - 1);
- my $ss = ($bowls == 1) ? "" : "s";
- $bowls = ($bowls == 1) ? "a" : $bowls;
- &delaycommand ("me gives $customer $bowls bowl$ss of $flavors[$flavor] ramen.");
- # CBACBACBACBACBATOSTATS
- # Arm the floodprot timer
- $noMoarOrders = 1;
- hook_timer( 1500, sub { $noMoarOrders = 0; return REMOVE; });
- return EAT_NONE;
- }
- # Randomizer
- sub eggroll {
- my $maxvalue=$_[0];
- int(rand($maxvalue));
- }
- # Blatant copypasta
- sub delaycommand {
- my $command = $_[0];
- hook_timer( 0,
- sub {
- command($command);
- return REMOVE;
- }
- );
- return EAT_NONE;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement