changeset 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 fbaf34d7bab7
children 0e18c714b69d
files findplayer.pl
diffstat 1 files changed, 10 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/findplayer.pl	Tue Feb 26 16:49:48 2008 +1030
+++ b/findplayer.pl	Fri Feb 29 10:20:28 2008 +1030
@@ -1,7 +1,7 @@
 ############################################################################
 # Run the game-monitor script when triggered
 #
-# $Id: findplayer.pl,v 1.1 2007/08/25 05:19:37 darius Exp $
+# $Id$
 ############################################################################
 #
 # Copyright (C) 2007 Daniel O'Connor. All rights reserved.
@@ -50,7 +50,8 @@
   my ($server, $data, $nick, $address) = @_;
   my ($target, $text) = split(/ :/, $data, 2);
 
-  if (lc($target) ne "#teabf" && lc($target) ne "darius") {
+  #print CLIENTCRAP "target = \"$target\"";
+  if (lc($target) ne "#teabf" && lc($target) ne "#tea") {
     return;
   }
   #print CLIENTCRAP "target = \"$target\"";
@@ -59,7 +60,7 @@
   $text =~ s/\x03\d?\d?(,\d?\d?)?|\x02|\x1f|\x16|\x06|\x07//g;
   #print CLIENTCRAP "text is $text";
 
-  if ($text =~ /!fp (.*)/) {
+  if ($text =~ /^!fp *(.*)/) {
     if ($lastran + Irssi::settings_get_int('fp_mininter') > time()) {
       print CLIENTCRAP "ignoring command from $nick";
       return;
@@ -67,10 +68,12 @@
     $lastran = time();
 
     my $string = $1;
-    #$string =~ s/[^0-9a-zA-Z .,\[\]]//g;
-    # print CLIENTCRAP "Target found - $string";
-    # XXX: hard coded now
-    $string = "[TEA]";
+    $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>) {