Merge branch 'master' of /home/magne/remoteglot
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 13 Nov 2016 18:14:06 +0000 (19:14 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 13 Nov 2016 18:14:06 +0000 (19:14 +0100)
1  2 
remoteglot.pl

diff --cc remoteglot.pl
@@@ -94,36 -94,39 +94,39 @@@ if (defined($engine2)) 
  print "Chess engine ready.\n";
  
  # now talk to FICS
- my $t = Net::Telnet->new(Timeout => 10, Prompt => '/fics% /');
- $t->input_log(\*FICSLOG);
- $t->open($remoteglotconf::server);
- $t->print($remoteglotconf::nick);
- $t->waitfor('/Press return to enter the server/');
- $t->cmd("");
- # set some options
- $t->cmd("set shout 0");
- $t->cmd("set seek 0");
- $t->cmd("set style 12");
- my $ev1 = AnyEvent->io(
-       fh => fileno($t),
-       poll => 'r',
-       cb => sub {    # what callback to execute
-               while (1) {
-                       my $line = $t->getline(Timeout => 0, errmode => 'return');
-                       return if (!defined($line));
-                       chomp $line;
-                       $line =~ tr/\r//d;
-                       handle_fics($line);
-               }
-       }
- );
+ my ($t, $ev1);
+ if (defined($remoteglotconf::server)) {
+       $t = Net::Telnet->new(Timeout => 10, Prompt => '/fics% /');
+       $t->input_log(\*FICSLOG);
+       $t->open($remoteglotconf::server);
+       $t->print($remoteglotconf::nick);
+       $t->waitfor('/Press return to enter the server/');
+       $t->cmd("");
+       # set some options
+       $t->cmd("set shout 0");
+       $t->cmd("set seek 0");
+       $t->cmd("set style 12");
+       $ev1 = AnyEvent->io(
+               fh => fileno($t),
+               poll => 'r',
+               cb => sub {    # what callback to execute
+                       while (1) {
+                               my $line = $t->getline(Timeout => 0, errmode => 'return');
+                               return if (!defined($line));
+                               chomp $line;
+                               $line =~ tr/\r//d;
+                               handle_fics($line);
+                       }
+               }
+       );
+ }
  if (defined($remoteglotconf::target)) {
 -      if ($remoteglotconf::target =~ /^http:/) {
 +      if ($remoteglotconf::target =~ /^https?:/) {
                fetch_pgn($remoteglotconf::target);
-       } else {
+       } elsif (defined($t)) {
                $t->cmd("observe $remoteglotconf::target");
        }
  }