annotate findplayer.pl @ 5:294581b9c72f

Restrict searches to Australia.
author darius
date Fri, 19 Oct 2007 07:53:00 +0000
parents 1378b9c50305
children 3ef64337d86b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
1 ############################################################################
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
2 # Run the game-monitor script when triggered
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
3 #
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
4 # $Id: findplayer.pl,v 1.1 2007/08/25 05:19:37 darius Exp $
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
5 ############################################################################
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
6 #
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
7 # Copyright (C) 2007 Daniel O'Connor. All rights reserved.
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
8 #
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
9 # Redistribution and use in source and binary forms, with or without
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
10 # modification, are permitted provided that the following conditions
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
11 # are met:
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
12 # 1. Redistributions of source code must retain the above copyright
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
13 # notice, this list of conditions and the following disclaimer.
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
14 # 2. Redistributions in binary form must reproduce the above copyright
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
15 # notice, this list of conditions and the following disclaimer in the
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
16 # documentation and/or other materials provided with the distribution.
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
17 #
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
18 # THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
19 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
20 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
21 # ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
22 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
23 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
24 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
25 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
26 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
27 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
28 # SUCH DAMAGE.
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
29 #
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
30 ############################################################################
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
31
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
32 use strict;
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
33 use vars qw($VERSION %IRSSI);
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
34
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
35 use Irssi;
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
36
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
37 $VERSION = '1.00';
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
38 %IRSSI = (
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
39 authors => 'Darius',
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
40 contact => 'darius\@dons.net.au',
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
41 name => 'findplayer',
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
42 description => 'Looks for players on game-monitor',
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
43 license => 'BSD',
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
44 );
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
45
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
46 my $lastran = 0;
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
47
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
48 sub event_privmsg {
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
49 # $data = "nick/#channel :text"
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
50 my ($server, $data, $nick, $address) = @_;
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
51 my ($target, $text) = split(/ :/, $data, 2);
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
52
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
53 if (lc($target) ne "#teabf" && lc($target) ne "darius") {
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
54 return;
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
55 }
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
56 #print CLIENTCRAP "target = \"$target\"";
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
57
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
58 # Remove colours, bold etc (taken from cleanpublic.pl)
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
59 $text =~ s/\x03\d?\d?(,\d?\d?)?|\x02|\x1f|\x16|\x06|\x07//g;
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
60 #print CLIENTCRAP "text is $text";
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
61
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
62 if ($text =~ /!fp (.*)/) {
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
63 if ($lastran + Irssi::settings_get_int('fp_mininter') > time()) {
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
64 print CLIENTCRAP "ignoring command from $nick";
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
65 return;
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
66 }
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
67 $lastran = time();
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
68
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
69 my $string = $1;
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
70 #$string =~ s/[^0-9a-zA-Z .,\[\]]//g;
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
71 # print CLIENTCRAP "Target found - $string";
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
72 # XXX: hard coded now
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
73 $string = "[TEA]";
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
74 $server->command("msg $target Looking for \"$string\" on game-monitor.com...");
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
75 open (SCR, "-|", "/home/doconnor/bin/scrape-gm.py", $string);
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
76 while (<SCR>) {
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
77 chomp;
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
78 $server->command("msg $target $_");
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
79 }
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
80 close SCR;
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
81 }
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
82 }
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
83
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
84 Irssi::signal_add("event privmsg", "event_privmsg");
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
85 Irssi::settings_add_int('misc', 'fp_mininter', 10);
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
86
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
87 print CLIENTCRAP "findplayer loaded";
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
88 1;
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
89
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
90 #;;; Local Variables: ***
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
91 #;;; mode:perl ***
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
92 #;;; End: ***
1378b9c50305 Add IRSSI wrapper script
darius
parents:
diff changeset
93