Public feed #381403

Something

public text v1 · immutable
Raw Edit
·published 2007-03-04 20:48 UTC
rendered paste body
#!/usr/bin/perl -w

use diagnostics;

#
# The configuration section ends here
#

IRC::register("Rutger's helper script", "1.1", "", "");
IRC::print("\0035:: Loaded helper script ::\003 \n");
IRC::add_message_handler("PRIVMSG", "privmsg_handler");
IRC::add_command_handler("nicksound", "nicksound_command_handler");

$sound_on = 1;

sub privmsg_handler
{
    my $line = shift(@_);
    if ($sound_on) {
	my $mynick = IRC::get_info(1);
	$mynick =~ tr/A-Z/a-z/;
	$line =~ tr/A-Z/a-z/;
	if (index($line, $mynick) != -1) {
#	    system("logger \"$line\"");
	    system("aplay ~/sounds/yahoo.wav &");
	} elsif ((index($line, "#m38c") != -1) or
		 (index($line, "#donderdag") != -1)) {
#	    system("logger \" + $line + \"");
	    system("aplay -q ~/sounds/Sonar.au &");
#	    IRC::print($line)
#	    system("say \"$line\"")
	}
    }
}

sub nicksound_command_handler
{
  my $state = shift;
  if (uc $state eq 'ON' )
  {
        IRC::print "\0034:: Smet's NickSound is turned ON ::\003 \n";
        $sound_on = 1;
        return 1;
  }
  else
  {
          if (uc $state eq 'OFF')
	  {
                IRC::print "\0034:: Smet's NickSound is turned OFF ::\003 \n";
                $sound_on = 0;
                return 1;
          }
  }
  IRC::print "USAGE: NICKSOUND [ON/OFF]\n";
  IRC::print "   OR: NS [ON/OFF]\n Turns nickname notification on or off\n";
  return 1;
}