diff options
Diffstat (limited to 'kanotix-irc/skel/.weechat/perl/autoload')
-rwxr-xr-x | kanotix-irc/skel/.weechat/perl/autoload/sound.pl | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/kanotix-irc/skel/.weechat/perl/autoload/sound.pl b/kanotix-irc/skel/.weechat/perl/autoload/sound.pl new file mode 100755 index 0000000..ee6749c --- /dev/null +++ b/kanotix-irc/skel/.weechat/perl/autoload/sound.pl @@ -0,0 +1,50 @@ +#!/usr/bin/perl +## ============================================================================= +## sound.pl (c) February 2005 by FlashCode <flashcode@flashtux.org> +## Updated on 2005-06-04 by FlashCode <flashcode@flashtux.org> +## Perl script for WeeChat. +## +## Play a sound when highlighted/private msg, or for ctcp sound event +## You have to configure $sound_cmd_highlight and $sound_cmd_ctcp below. +## ============================================================================= +my $version = "0.2"; +my $sound_cmd_highlight = "esdplay ~/highlight_sound.wav >/dev/null 2>&1 &"; +my $sound_cmd_ctcp = "esdplay \$filename >/dev/null 2>&1 &"; +weechat::register ("Sound", $version, "", "Sound for highlights/privates & CTCP sound events"); + +weechat::add_message_handler("PRIVMSG", "sound"); +weechat::add_command_handler ("sound", sound_cmd); + +sub sound +{ + $server = $_[0]; + if ($_[1] =~ /(.*) PRIVMSG (.*)/) + { + my $host = $1; + my $msg = $2; + if ($host ne "localhost") + { + system($sound_cmd_highlight) if (index($msg, weechat::get_info("nick", $server)) != -1); + if ($msg =~ /\001SOUND ([^ ]*)\001/) + { + my $filename = $1; + my $command = $sound_cmd_ctcp; + $command =~ s/(\$\w+)/$1/gee; + system($command); + } + } + } + return 0; +} + +sub sound_cmd +{ + if ($#_ == 1) + { + my $filename = $_[1].".wav"; + my $command = $sound_cmd_ctcp; + $command =~ s/(\$\w+)/$1/gee; + system($command); + weechat::command("PRIVMSG ".weechat::get_info("channel")." :\001SOUND $filename\001") if (@_); + } +} |