Mercurial > ~darius > hgwebdir.cgi > scrape-gm
view findplayer.pl @ 9:3ef64337d86b
- Listen on #tea & #teabf
- Only match !fp at the beginning of the line
- Allow users to specify a search string but default to [tea] if none is specified.
author | darius@inchoate.localdomain |
---|---|
date | Fri, 29 Feb 2008 10:20:28 +1030 |
parents | 1378b9c50305 |
children | 22a51e8c0a69 |
line wrap: on
line source
############################################################################ # Run the game-monitor script when triggered # # $Id$ ############################################################################ # # 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); #print CLIENTCRAP "target = \"$target\""; if (lc($target) ne "#teabf" && lc($target) ne "#tea") { 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"; if ($string eq "") { $string = "[TEA]"; #print CLIENTCRAP "No target, using [TEA]"; } $server->command("msg $target Looking for \"$string\" on game-monitor.com..."); open (SCR, "-|", "/home/doconnor/bin/scrape-gm.py", $string); while (<SCR>) { 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: ***