]> git.vpit.fr Git - perl/scripts/xchat.git/blobdiff - net.pl
Add better context handling helpers
[perl/scripts/xchat.git] / net.pl
diff --git a/net.pl b/net.pl
index 13d73eda0b32fe70f5f2f8fc36526f4fb41b0854..80535e18ae7d5035c49051118d740d1c2ccc5b1a 100755 (executable)
--- a/net.pl
+++ b/net.pl
@@ -10,7 +10,8 @@ use Xchat qw<:all>;
 
 use lib get_info 'xchatdir';
 use Xchat::XPI;
-use Xchat::XPI::Net qw<resolve whois>;
+use Xchat::XPI::Net   qw<resolve whois>;
+use Xchat::XPI::Utils qw<save_context>;
 
 our $VERSION = '0.02';
 
@@ -59,7 +60,7 @@ hook_command 'DIG', sub {
 sub dig_print {
  my $p = $_[0];
  my ($context, $req) = @{$_[1]};
- my $oldctxt = get_context;
+ my $guard = save_context;
  set_context $context;
  if ($p) {
   my @a = $p->answer;
@@ -78,7 +79,6 @@ sub dig_print {
  } else {
   print $ph 'Request ' . $req->{host} . " timed out\n";
  }
- set_context $oldctxt;
 }
 
 hook_command 'NETWHOIS', sub {
@@ -99,7 +99,7 @@ hook_command 'NETWHOIS', sub {
 sub netwhois_print {
  my $raw = $_[0];
  my ($context, $req) = @{$_[1]};
- my $oldctxt = get_context;
+ my $guard = save_context;
  set_context $context;
  if ($raw) {
   $raw =~ s/.*(Domain|inetnum)/$1/s;
@@ -112,7 +112,6 @@ sub netwhois_print {
  } else {
   output '*', 'No results for ' . $req->{host};
  }
- set_context $oldctxt;
 }
 
 hook_command 'TLD', sub {