]> git.vpit.fr Git - perl/scripts/xchat.git/blobdiff - Xchat/XPI/Net.pm
Pretend that the xchat functions in XPI are called from the script
[perl/scripts/xchat.git] / Xchat / XPI / Net.pm
index 96c4af30f71f4803986e8752adc3b4e0222ae828..d4823a82b622e01037ed6c0374e8f69f3d1a5999 100644 (file)
@@ -3,12 +3,15 @@ package Xchat::XPI::Net;
 use strict;
 use warnings;
 
+use Xchat qw<:all>;
+
+use lib get_info 'xchatdir';
+use Xchat::XPI::Utils qw<called_from_script>;
+
 use IO::Socket::INET;
 
 use Net::DNS;
 
-use Xchat qw<:all>;
-
 our $VERSION = '0.03';
 
 my $res;
@@ -32,10 +35,12 @@ sub resolve {
  return unless $sock;
  $sock->autoflush(1);
 
- return Xchat::hook_fd($sock, \&_dns_recv, {
-  flags => FD_READ,
-  data  => [ $callback, $args ],
- });
+ return called_from_script {
+  Xchat::hook_fd($sock, \&_dns_recv, {
+   flags => FD_READ,
+   data  => [ $callback, $args ],
+  });
+ }
 }
 
 sub _dns_recv {
@@ -107,10 +112,12 @@ sub whois {
  print $sock "$host\x0D\x0A";
  $sock->shutdown(1); # stop writing
 
- return Xchat::hook_fd($sock, \&_whois_recv, {
-  flags => FD_READ,
-  data  => [ $callback, $args ],
- });
+ return called_from_script {
+  Xchat::hook_fd($sock, \&_whois_recv, {
+   flags => FD_READ,
+   data  => [ $callback, $args ],
+  });
+ }
 }
 
 sub _whois_recv {