# HG changeset patch # User darius # Date 1188019177 0 # Node ID 1378b9c50305f4e0e91baed6cb154d03e14fb6a2 # Parent 43c4e676c2aa23e6b636a0d155c780f3153c448f Add IRSSI wrapper script diff -r 43c4e676c2aa -r 1378b9c50305 findplayer.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/findplayer.pl Sat Aug 25 05:19:37 2007 +0000 @@ -0,0 +1,93 @@ +############################################################################ +# Run the game-monitor script when triggered +# +# $Id: findplayer.pl,v 1.1 2007/08/25 05:19:37 darius Exp $ +############################################################################ +# +# Copyright (C) 2007 Daniel O'Connor. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +############################################################################ + +use strict; +use vars qw($VERSION %IRSSI); + +use Irssi; + +$VERSION = '1.00'; +%IRSSI = ( + authors => 'Darius', + contact => 'darius\@dons.net.au', + name => 'findplayer', + description => 'Looks for players on game-monitor', + license => 'BSD', +); + +my $lastran = 0; + +sub event_privmsg { + # $data = "nick/#channel :text" + my ($server, $data, $nick, $address) = @_; + my ($target, $text) = split(/ :/, $data, 2); + + if (lc($target) ne "#teabf" && lc($target) ne "darius") { + return; + } + #print CLIENTCRAP "target = \"$target\""; + + # Remove colours, bold etc (taken from cleanpublic.pl) + $text =~ s/\x03\d?\d?(,\d?\d?)?|\x02|\x1f|\x16|\x06|\x07//g; + #print CLIENTCRAP "text is $text"; + + if ($text =~ /!fp (.*)/) { + if ($lastran + Irssi::settings_get_int('fp_mininter') > time()) { + print CLIENTCRAP "ignoring command from $nick"; + return; + } + $lastran = time(); + + my $string = $1; + #$string =~ s/[^0-9a-zA-Z .,\[\]]//g; + # print CLIENTCRAP "Target found - $string"; + # XXX: hard coded now + $string = "[TEA]"; + $server->command("msg $target Looking for \"$string\" on game-monitor.com..."); + open (SCR, "-|", "/home/doconnor/bin/scrape-gm.py", $string); + while () { + chomp; + $server->command("msg $target $_"); + } + close SCR; + } +} + +Irssi::signal_add("event privmsg", "event_privmsg"); +Irssi::settings_add_int('misc', 'fp_mininter', 10); + +print CLIENTCRAP "findplayer loaded"; +1; + +#;;; Local Variables: *** +#;;; mode:perl *** +#;;; End: *** +