Mercurial > ~darius > hgwebdir.cgi > scrape-gm
comparison findplayer.pl @ 4:1378b9c50305
Add IRSSI wrapper script
author | darius |
---|---|
date | Sat, 25 Aug 2007 05:19:37 +0000 |
parents | |
children | 3ef64337d86b |
comparison
equal
deleted
inserted
replaced
3:43c4e676c2aa | 4:1378b9c50305 |
---|---|
1 ############################################################################ | |
2 # Run the game-monitor script when triggered | |
3 # | |
4 # $Id: findplayer.pl,v 1.1 2007/08/25 05:19:37 darius Exp $ | |
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 | |
53 if (lc($target) ne "#teabf" && lc($target) ne "darius") { | |
54 return; | |
55 } | |
56 #print CLIENTCRAP "target = \"$target\""; | |
57 | |
58 # Remove colours, bold etc (taken from cleanpublic.pl) | |
59 $text =~ s/\x03\d?\d?(,\d?\d?)?|\x02|\x1f|\x16|\x06|\x07//g; | |
60 #print CLIENTCRAP "text is $text"; | |
61 | |
62 if ($text =~ /!fp (.*)/) { | |
63 if ($lastran + Irssi::settings_get_int('fp_mininter') > time()) { | |
64 print CLIENTCRAP "ignoring command from $nick"; | |
65 return; | |
66 } | |
67 $lastran = time(); | |
68 | |
69 my $string = $1; | |
70 #$string =~ s/[^0-9a-zA-Z .,\[\]]//g; | |
71 # print CLIENTCRAP "Target found - $string"; | |
72 # XXX: hard coded now | |
73 $string = "[TEA]"; | |
74 $server->command("msg $target Looking for \"$string\" on game-monitor.com..."); | |
75 open (SCR, "-|", "/home/doconnor/bin/scrape-gm.py", $string); | |
76 while (<SCR>) { | |
77 chomp; | |
78 $server->command("msg $target $_"); | |
79 } | |
80 close SCR; | |
81 } | |
82 } | |
83 | |
84 Irssi::signal_add("event privmsg", "event_privmsg"); | |
85 Irssi::settings_add_int('misc', 'fp_mininter', 10); | |
86 | |
87 print CLIENTCRAP "findplayer loaded"; | |
88 1; | |
89 | |
90 #;;; Local Variables: *** | |
91 #;;; mode:perl *** | |
92 #;;; End: *** | |
93 |