comparison 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
comparison
equal deleted inserted replaced
8:fbaf34d7bab7 9:3ef64337d86b
1 ############################################################################ 1 ############################################################################
2 # Run the game-monitor script when triggered 2 # Run the game-monitor script when triggered
3 # 3 #
4 # $Id: findplayer.pl,v 1.1 2007/08/25 05:19:37 darius Exp $ 4 # $Id$
5 ############################################################################ 5 ############################################################################
6 # 6 #
7 # Copyright (C) 2007 Daniel O'Connor. All rights reserved. 7 # Copyright (C) 2007 Daniel O'Connor. All rights reserved.
8 # 8 #
9 # Redistribution and use in source and binary forms, with or without 9 # Redistribution and use in source and binary forms, with or without
48 sub event_privmsg { 48 sub event_privmsg {
49 # $data = "nick/#channel :text" 49 # $data = "nick/#channel :text"
50 my ($server, $data, $nick, $address) = @_; 50 my ($server, $data, $nick, $address) = @_;
51 my ($target, $text) = split(/ :/, $data, 2); 51 my ($target, $text) = split(/ :/, $data, 2);
52 52
53 if (lc($target) ne "#teabf" && lc($target) ne "darius") { 53 #print CLIENTCRAP "target = \"$target\"";
54 if (lc($target) ne "#teabf" && lc($target) ne "#tea") {
54 return; 55 return;
55 } 56 }
56 #print CLIENTCRAP "target = \"$target\""; 57 #print CLIENTCRAP "target = \"$target\"";
57 58
58 # Remove colours, bold etc (taken from cleanpublic.pl) 59 # Remove colours, bold etc (taken from cleanpublic.pl)
59 $text =~ s/\x03\d?\d?(,\d?\d?)?|\x02|\x1f|\x16|\x06|\x07//g; 60 $text =~ s/\x03\d?\d?(,\d?\d?)?|\x02|\x1f|\x16|\x06|\x07//g;
60 #print CLIENTCRAP "text is $text"; 61 #print CLIENTCRAP "text is $text";
61 62
62 if ($text =~ /!fp (.*)/) { 63 if ($text =~ /^!fp *(.*)/) {
63 if ($lastran + Irssi::settings_get_int('fp_mininter') > time()) { 64 if ($lastran + Irssi::settings_get_int('fp_mininter') > time()) {
64 print CLIENTCRAP "ignoring command from $nick"; 65 print CLIENTCRAP "ignoring command from $nick";
65 return; 66 return;
66 } 67 }
67 $lastran = time(); 68 $lastran = time();
68 69
69 my $string = $1; 70 my $string = $1;
70 #$string =~ s/[^0-9a-zA-Z .,\[\]]//g; 71 $string =~ s/[^0-9a-zA-Z .,\[\]]//g;
71 # print CLIENTCRAP "Target found - $string"; 72 #print CLIENTCRAP "Target found - $string";
72 # XXX: hard coded now 73 if ($string eq "") {
73 $string = "[TEA]"; 74 $string = "[TEA]";
75 #print CLIENTCRAP "No target, using [TEA]";
76 }
74 $server->command("msg $target Looking for \"$string\" on game-monitor.com..."); 77 $server->command("msg $target Looking for \"$string\" on game-monitor.com...");
75 open (SCR, "-|", "/home/doconnor/bin/scrape-gm.py", $string); 78 open (SCR, "-|", "/home/doconnor/bin/scrape-gm.py", $string);
76 while (<SCR>) { 79 while (<SCR>) {
77 chomp; 80 chomp;
78 $server->command("msg $target $_"); 81 $server->command("msg $target $_");