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