# # script for catching someshit # use strict; use warnings; use Time::Local; my @channels = ('#duckhunt'); my $regex = '^.*-.,¸¸.-·°'`'°·-.,¸¸.-·°'`'°·.*\_O<.*QUACK$'; my $rregX = '^jmjl.*>.*CLACK.*Your gun is jammed, you must reload to unjam it\.\.\..*$'; my $RregX = '^jmjl.*>.*Crr..CLICK.*You unjam your gun\..*$'; my $ducks = '^jmjl.*>.*BANG.*The duck survived ! Try again.*\_O<.*$'; # nick my $nick = 'DuckHunt'; #my $failregex = '^.*PraiseIt.*broke out.*' . $nick . '.*$'; my %SCRIPT = ( authors => "Julián Marcos", contact => "jmjl\@tilde.club", name => "auto!b\@ng", description => "Dumb script for a dumb game", license => "private domain", written => "In time", changed => "In time" ); my $VERSION = "0"; sub hook_print_cb { my ( $data, $buffer, $date, $tags, $displayed, $highlight, $prefix, $message ) = @_; # Get the name of the nick and server my $channel = weechat::buffer_get_string($buffer, "localvar_channel"); my $server = weechat::buffer_get_string($buffer,'localvar_server'); my $incoming_nick = ''; # Bail out if this doesn't seem to be a channel name return 1 unless $channel =~ /^\#.*$/; my $valid_channel = '0'; foreach (@channels) { if ($channel eq $_) { $valid_channel = 1; last; } } if ($valid_channel == 0) { return 1; } # Get the current nick from the tags if ($tags =~ /^.*nick_(.*?),.*$/) { $incoming_nick = $1; } # Freshen the timestamp if this is our nick, however, does not work # from WITHIN weechat as it doesn't see it as a message, only when # sent from twitch or such if ( lc($incoming_nick) eq lc($nick) ) { $last_epoch = time(); } my $current_epoch = time(); my $delta_epoch = $current_epoch - $last_epoch; #weechat::print("", "incoming_nick: [$incoming_nick] le: [$last_epoch] ce: [$current_epoch] delta: [$delta_epoch]"); #weechat::print("", "delta: [$delta_epoch] is less than timeout [$timeout], proceedding"); if ($message =~ $regex) { weechat::command($buffer, "!bang"); } if ($message =~ $rregX) { weechat::command($buffer, "!reload"); } if ($message =~ $RregX) { weechat::command($buffer, "!bang"); } return 1; } # Weechat specifics weechat::register($SCRIPT{'name'}, $SCRIPT{'authors'}, $VERSION, $SCRIPT{'license'}, $SCRIPT{'description'}, '', ''); weechat::hook_print("", "notify_message", "", 1, "hook_print_cb", "");